all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* 26.1; Tetris score is no longer updated due to commit 995be66f0f0d26d1a96cbb8dfb429c3941157771
@ 2019-03-30 22:32 Tadeus Prastowo
  2019-03-31  3:32 ` bug#35056: " Paul Eggert
  0 siblings, 1 reply; 5+ messages in thread
From: Tadeus Prastowo @ 2019-03-30 22:32 UTC (permalink / raw)
  To: Paul Eggert; +Cc: Glenn Morris, emacs-devel

Hi Paul,

Could you comment on this bug report that pertains to your commit
about two years ago, please?

http://lists.gnu.org/archive/html/bug-gnu-emacs/2019-03/msg01042.html

Thank you.

PS: CCing Glenn because my search for the score updating problem on
bug-gnu-emacs, help-gnu-emacs, and emacs-devel mailing lists turned up
this relevant thread:
http://lists.gnu.org/archive/html/bug-gnu-emacs/2017-02/msg01066.html

--
Best regards,
Tadeus



^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#35056: 26.1; Tetris score is no longer updated due to commit 995be66f0f0d26d1a96cbb8dfb429c3941157771
  2019-03-30 22:32 26.1; Tetris score is no longer updated due to commit 995be66f0f0d26d1a96cbb8dfb429c3941157771 Tadeus Prastowo
@ 2019-03-31  3:32 ` Paul Eggert
  2019-03-31 19:41   ` Tadeus Prastowo
  2019-03-31 22:54   ` Richard Stallman
  0 siblings, 2 replies; 5+ messages in thread
From: Paul Eggert @ 2019-03-31  3:32 UTC (permalink / raw)
  To: Tadeus Prastowo; +Cc: 35056

[-- Attachment #1: Type: text/plain, Size: 1047 bytes --]

Apparently the problem is that there are two formats of Tetris game-score files. 
One format is used by play/gamegrid.el itself, the other is used by the 
update-game-score command. I didn't know that; I thought that the only reason to 
use update-game-score was to get setuid/setgid permissions, and that the file 
format didn't change.

To some extent the file-format problem is Just One Of Those Things: if up 
upgrade Emacs and it changes the file format, Emacs is not smart enough to deal 
with the format change and so it loses your old Tetris scores.

That being said, Emacs could try harder to use the update-game-score program if 
it's installed. Is it in your installation? If so, please try the attached 
patch. If not, please try redoing 'configure' so that update-game-score is built 
and installed, and then try the attached patch.

I suppose it would be possible to do more-serious hacking in gamegrid.el to deal 
with the incompatible file formats (convert formats back and forth, say), but 
that would be beyond my call of duty.


[-- Attachment #2: 0001-Use-update-game-score-more-often-with-Tetris.patch --]
[-- Type: text/x-patch, Size: 3703 bytes --]

From 9f14fc6f61c8c6609a24efa1024ef8a68d16a92f Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sat, 30 Mar 2019 20:26:15 -0700
Subject: [PATCH] Use update-game-score more often with Tetris

* lisp/play/gamegrid.el (gamegrid-add-score-with-update-game-score):
Go back to previous way of deciding whether to invoke
update-game-score, except do not try to invoke it if file-modes
fails on it (Bug#35056).
---
 lisp/play/gamegrid.el | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/lisp/play/gamegrid.el b/lisp/play/gamegrid.el
index 430a2071bf..4a9dac7f74 100644
--- a/lisp/play/gamegrid.el
+++ b/lisp/play/gamegrid.el
@@ -565,8 +565,8 @@ gamegrid-add-score
 
 ;; On POSIX systems there are four cases to distinguish:
 
-;;     1. FILE is an absolute filename.  Then it should be a file in
-;;        temporary file directory.  This is the way,
+;;     1. FILE is an absolute filename or "update-game-score" does not exist.
+;;	  Then FILE should be a file in a temporary file directory.  This is how
 ;;        `gamegrid-add-score' was supposed to be used in the past and
 ;;        is covered here for backward-compatibility.
 ;;
@@ -583,21 +583,18 @@ gamegrid-add-score
 ;;        update FILE.  This is for the case that a user has installed
 ;;        a game on her own.
 ;;
-;;     4. "update-game-score" does not exist or is not setgid/setuid.
-;;        Create/update FILE in the user's home directory, without
-;;        using "update-game-score".  There is presumably no shared
-;;        game directory.
+;;     4. "update-game-score" is not setgid/setuid.  Use it to
+;;        create/update FILE in the user's home directory.  There is
+;;        presumably no shared game directory.
 
 (defvar gamegrid-shared-game-dir)
 
 (defun gamegrid-add-score-with-update-game-score (file score)
-  (let ((gamegrid-shared-game-dir
-	 (not (zerop (logand (or (file-modes
-				  (expand-file-name "update-game-score"
-						    exec-directory))
-				  0)
-			     #o6000)))))
-    (cond ((file-name-absolute-p file)
+  (let* ((update-game-score-modes
+	  (file-modes (expand-file-name "update-game-score" exec-directory)))
+	 (gamegrid-shared-game-dir
+	  (not (zerop (logand #o6000 (or update-game-score-modes 0))))))
+    (cond ((or (not update-game-score-modes) (file-name-absolute-p file))
 	   (gamegrid-add-score-insecure file score))
 	  ((and gamegrid-shared-game-dir
 		(file-exists-p (expand-file-name file shared-game-score-directory)))
@@ -607,12 +604,23 @@ gamegrid-add-score-with-update-game-score
 	    (expand-file-name file shared-game-score-directory) score))
 	  ;; Else: Add the score to a score file in the user's home
 	  ;; directory.
-	  (t
+	  (gamegrid-shared-game-dir
+	   ;; If gamegrid-shared-game-dir is non-nil the
+	   ;; "update-gamescore" program is setuid, so don't use it.
 	   (unless (file-exists-p
 		    (directory-file-name gamegrid-user-score-file-directory))
 	     (make-directory gamegrid-user-score-file-directory t))
 	   (gamegrid-add-score-insecure file score
-					gamegrid-user-score-file-directory)))))
+					gamegrid-user-score-file-directory))
+	  (t
+	   (unless (file-exists-p
+		    (directory-file-name gamegrid-user-score-file-directory))
+	     (make-directory gamegrid-user-score-file-directory t))
+	   (let ((f (expand-file-name file
+				      gamegrid-user-score-file-directory)))
+	     (unless (file-exists-p f)
+	       (write-region "" nil f nil 'silent nil 'excl))
+	     (gamegrid-add-score-with-update-game-score-1 file f score))))))
 
 (defun gamegrid-add-score-with-update-game-score-1 (file target score)
   (let ((default-directory "/")
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#35056: 26.1; Tetris score is no longer updated due to commit 995be66f0f0d26d1a96cbb8dfb429c3941157771
  2019-03-31  3:32 ` bug#35056: " Paul Eggert
@ 2019-03-31 19:41   ` Tadeus Prastowo
  2019-03-31 22:54   ` Richard Stallman
  1 sibling, 0 replies; 5+ messages in thread
From: Tadeus Prastowo @ 2019-03-31 19:41 UTC (permalink / raw)
  To: Paul Eggert; +Cc: 35056

On Sun, Mar 31, 2019 at 5:32 AM Paul Eggert <eggert@cs.ucla.edu> wrote:
>
> Apparently the problem is that there are two formats of Tetris game-score files.
> One format is used by play/gamegrid.el itself, the other is used by the
> update-game-score command. I didn't know that; I thought that the only reason to
> use update-game-score was to get setuid/setgid permissions, and that the file
> format didn't change.

Perhaps you need to make a test unit to ensure there is no regression
in the future.

> To some extent the file-format problem is Just One Of Those Things: if up
> upgrade Emacs and it changes the file format, Emacs is not smart enough to deal
> with the format change and so it loses your old Tetris scores.
>
> That being said, Emacs could try harder to use the update-game-score program if
> it's installed. Is it in your installation? If so, please try the attached
> patch. If not, please try redoing 'configure' so that update-game-score is built
> and installed, and then try the attached patch.

I apply your patch to Emacs 26.1 source
(http://ftp.gnu.org/gnu/emacs/emacs-26.1.tar.xz), and run the
following configure command:
configure --prefix=/mnt/core/Codebases/installzone/emacs
--with-xwidgets --disable-silent-rules --with-gameuser=yes
And, then the following make command:
make
make install

I played Tetris, scoring higher than the lowest recorded in my high
score file, and I confirm that your patch allows the score to be
recorded after year 2018 went by without any new record due to the bug
introduced by commit 995be66f0f0d26d1a96cbb8dfb429c3941157771.

> I suppose it would be possible to do more-serious hacking in gamegrid.el to deal
> with the incompatible file formats (convert formats back and forth, say), but
> that would be beyond my call of duty.

I like your patch: if it ain't broken, don't fix it, dude ;)

--
Best regards,
Tadeus





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#35056: 26.1; Tetris score is no longer updated due to commit 995be66f0f0d26d1a96cbb8dfb429c3941157771
  2019-03-31  3:32 ` bug#35056: " Paul Eggert
  2019-03-31 19:41   ` Tadeus Prastowo
@ 2019-03-31 22:54   ` Richard Stallman
  2019-04-01  3:03     ` Paul Eggert
  1 sibling, 1 reply; 5+ messages in thread
From: Richard Stallman @ 2019-03-31 22:54 UTC (permalink / raw)
  To: Paul Eggert; +Cc: tadeus.prastowo, 35056

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > One format is used by play/gamegrid.el itself, the other is used by the 
  > update-game-score command. I didn't know that; I thought that the only reason to 
  > use update-game-score was to get setuid/setgid permissions, and that the file 
  > format didn't change.

We could change play/gamegrid.el to use the update-game-score format
and convert the old format when encountered.


-- 
Dr Richard Stallman
President, Free Software Foundation (https://gnu.org, https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)







^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#35056: 26.1; Tetris score is no longer updated due to commit 995be66f0f0d26d1a96cbb8dfb429c3941157771
  2019-03-31 22:54   ` Richard Stallman
@ 2019-04-01  3:03     ` Paul Eggert
  0 siblings, 0 replies; 5+ messages in thread
From: Paul Eggert @ 2019-04-01  3:03 UTC (permalink / raw)
  To: rms; +Cc: tadeus.prastowo, 35056-done

Richard Stallman wrote:
> We could change play/gamegrid.el to use the update-game-score format
> and convert the old format when encountered.

Yes, that would be an improvement over what the patch does. In the meantime I 
installed the patch since it fixes the problem at hand, and I am marking the bug 
as done.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-04-01  3:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-30 22:32 26.1; Tetris score is no longer updated due to commit 995be66f0f0d26d1a96cbb8dfb429c3941157771 Tadeus Prastowo
2019-03-31  3:32 ` bug#35056: " Paul Eggert
2019-03-31 19:41   ` Tadeus Prastowo
2019-03-31 22:54   ` Richard Stallman
2019-04-01  3:03     ` Paul Eggert

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.