]> code.delx.au - gnu-emacs/blobdiff - lisp/play/gamegrid.el
Expunge "allow" + infinitive without direct object from source and doc.
[gnu-emacs] / lisp / play / gamegrid.el
index 7817d71bc7ea2941ec85833df434d0ec3d6ee762..2c557ba7547920543925c59ec97119cf7e5a2c57 100644 (file)
@@ -1,6 +1,6 @@
 ;;; gamegrid.el --- library for implementing grid-based games on Emacs
 
-;; Copyright (C) 1997-1998, 2001-2014 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2001-2016 Free Software Foundation, Inc.
 
 ;; Author: Glynn Clements <glynn@sensei.co.uk>
 ;; Version: 1.02
@@ -379,7 +379,7 @@ static unsigned char gamegrid_bits[] = {
     (dotimes (i height)
       (insert line))
     ;; Adjust the height of the default face to the height of the
-    ;; images. Unlike XEmacs, Emacs doesn't allow to make the default
+    ;; images. Unlike XEmacs, Emacs doesn't allow making the default
     ;; face buffer-local; so we do this with an overlay.
     (when (eq gamegrid-display-mode 'glyph)
       (overlay-put (make-overlay (point-min) (point-max))
@@ -462,45 +462,44 @@ FILE is created there."
 ;;        `gamegrid-add-score' was supposed to be used in the past and
 ;;        is covered here for backward-compatibility.
 ;;
-;;     2. The helper program "update-game-score" is setuid and the
-;;        file FILE does already exist in a system wide shared game
-;;        directory.  This should be the normal case on POSIX systems,
-;;        if the game was installed system wide.  Use
+;;     2. The helper program "update-game-score" is setgid or setuid
+;;        and the file FILE does already exist in a system wide shared
+;;        game directory.  This should be the normal case on POSIX
+;;        systems, if the game was installed system wide.  Use
 ;;        "update-game-score" to add the score to the file in the
 ;;        shared game directory.
 ;;
-;;     3. "update-game-score" is setuid, but the file FILE does *not*
-;;        exist in the system wide shared game directory.  Use
+;;     3. "update-game-score" is setgid/setuid, but the file FILE does
+;;        *not* exist in the system wide shared game directory.  Use
 ;;        `gamegrid-add-score-insecure' to create--if necessary--and
 ;;        update FILE.  This is for the case that a user has installed
 ;;        a game on her own.
 ;;
-;;     4. "update-game-score" is not setuid.  Use it to create/update
-;;        FILE in the user's home directory.  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 ((setuid
+  (let ((gamegrid-shared-game-dir
         (not (zerop (logand (file-modes
                              (expand-file-name "update-game-score"
                                                exec-directory))
-                            #o4000)))))
+                            #o6000)))))
     (cond ((file-name-absolute-p file)
           (gamegrid-add-score-insecure file score))
-         ;; Use the setuid "update-game-score" program to update a
-         ;; pre-existing system-wide score file.
-         ((and setuid
+         ((and gamegrid-shared-game-dir
                (file-exists-p (expand-file-name file shared-game-score-directory)))
+          ;; Use the setgid (or setuid) "update-game-score" program
+          ;; to update a system-wide score file.
           (gamegrid-add-score-with-update-game-score-1 file
-           (expand-file-name file shared-game-score-directory) score setuid))
-         ;; We have setuid, but the score file does not exist.
-         ;; FIXME - Why not try to create it?
-         ;; Maybe the logic is that this is being called by a game
-         ;; that is not part of the standard Emacs install?
-         ;; I see no reason why we should not try to use a shared
-         ;; score file though, and fall back to a private one if we
-         ;; lack permission to create a shared file.
-         (setuid
+           (expand-file-name file shared-game-score-directory) score))
+         ;; Else: Add the score to a score file in the user's home
+         ;; directory.
+         (gamegrid-shared-game-dir
+          ;; If `gamegrid-shared-game-dir' is non-nil, then
+          ;; "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))
@@ -516,8 +515,7 @@ FILE is created there."
               (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
-                                                        &optional setuid)
+(defun gamegrid-add-score-with-update-game-score-1 (file target score)
   (let ((default-directory "/")
        (errbuf (generate-new-buffer " *update-game-score loss*"))
         (marker-string (concat
@@ -539,7 +537,7 @@ FILE is created there."
         (expand-file-name "update-game-score" exec-directory)
         nil errbuf nil
         "-m" (int-to-string gamegrid-score-file-length)
-        "-d" (if setuid
+        "-d" (if gamegrid-shared-game-dir
                  (expand-file-name shared-game-score-directory)
                (file-name-directory target))
         file