summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@gnu.org>2002-04-29 22:53:44 +0000
committerColin Walters <walters@gnu.org>2002-04-29 22:53:44 +0000
commit55dcde3e25519c50dfc0c138187c77d7b130b5d6 (patch)
treee42f850538b6b96a3c336d35f033cde1421874e6
parent548827cfcdbf1aa8cfda3adff87a6525967d8ac2 (diff)
downloademacs-55dcde3e25519c50dfc0c138187c77d7b130b5d6.tar.gz
(gamegrid-add-score-with-update-game-score): Test whether or not
update-game-score is setuid, and do the right thing.
-rw-r--r--lisp/play/gamegrid.el33
1 files changed, 20 insertions, 13 deletions
diff --git a/lisp/play/gamegrid.el b/lisp/play/gamegrid.el
index aff6a9bdec8..054358940d0 100644
--- a/lisp/play/gamegrid.el
+++ b/lisp/play/gamegrid.el
@@ -413,18 +413,24 @@ static char *noname[] = {
(gamegrid-add-score-with-update-game-score file score))))
(defun gamegrid-add-score-with-update-game-score (file score)
- (let ((result nil)
- (errbuf (generate-new-buffer " *update-game-score loss*"))
- (target (if game-score-directory
- file
- (let ((f (expand-file-name "~/.emacs.d/games")))
- (unless (eq (car-safe (file-attributes f))
- t)
- (make-directory f))
- (setq f (expand-file-name file f))
- (unless (file-exists-p f)
- (write-region "" nil f nil 'silent nil 'excl))
- f))))
+ (let* ((result nil)
+ (errbuf (generate-new-buffer " *update-game-score loss*"))
+ (have-shared-game-dir
+ (not (zerop (logand (file-modes
+ (expand-file-name "update-game-score"
+ exec-directory))
+ #o4000))))
+ (target (if have-shared-game-dir
+ (expand-file-name file game-score-directory)
+ (let ((f (expand-file-name game-score-directory)))
+ (when (file-writable-p f)
+ (unless (eq (car-safe (file-attributes f))
+ t)
+ (make-directory f))
+ (setq f (expand-file-name file f))
+ (unless (file-exists-p f)
+ (write-region "" nil f nil 'silent nil 'excl)))
+ f))))
(let ((default-directory "/"))
(apply
'call-process
@@ -432,7 +438,8 @@ static char *noname[] = {
(list
(expand-file-name "update-game-score" exec-directory)
nil errbuf nil
- "-m" (int-to-string gamegrid-score-file-length) file
+ "-m" (int-to-string gamegrid-score-file-length)
+ "-d" (expand-file-name game-score-directory) file
(int-to-string score)
(concat
(user-full-name)