[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 1827197: Use update-game-score more often with Tetr
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] master 1827197: Use update-game-score more often with Tetris |
Date: |
Sun, 31 Mar 2019 23:02:08 -0400 (EDT) |
branch: master
commit 1827197e911414284b4935a2d71257401629930c
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
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 430a207..4a9dac7 100644
--- a/lisp/play/gamegrid.el
+++ b/lisp/play/gamegrid.el
@@ -565,8 +565,8 @@ FILE is created there."
;; 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 @@ FILE is created there."
;; 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 @@ FILE is created there."
(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 "/")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 1827197: Use update-game-score more often with Tetris,
Paul Eggert <=