aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2011-03-11 14:19:08 +0200
committerEli Zaretskii2011-03-11 14:19:08 +0200
commit2920e68d73e0009f368e817207964efaff751f85 (patch)
tree26c29a20149fc8539acb28ee9237310e311d9c04
parent69cc79e9e067543c5b20adcea1d756f1dd9569dc (diff)
downloademacs-2920e68d73e0009f368e817207964efaff751f85.tar.gz
emacs-2920e68d73e0009f368e817207964efaff751f85.zip
Fix comparisons of file ownership on MS-Windows for the Administrator user.
lisp/files.el (file-ownership-preserved-p): Pass `integer' as an explicit 2nd argument to `file-attributes'. If the file's owner is the Administrators group on Windows, and the current user is Administrator, consider that a match. lisp/server.el (server-ensure-safe-dir): Consider server directory safe on MS-Windows if its owner is the Administrators group while the current Emacs user is Administrator. Use `=' to compare numerical UIDs, since they could be integers or floats.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/files.el10
-rw-r--r--lisp/server.el8
3 files changed, 27 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1b8a7641b35..6685e355360 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12011-03-11 Eli Zaretskii <eliz@gnu.org>
2
3 * files.el (file-ownership-preserved-p): Pass `integer' as an
4 explicit 2nd argument to `file-attributes'. If the file's owner
5 is the Administrators group on Windows, and the current user is
6 Administrator, consider that a match.
7
8 * server.el (server-ensure-safe-dir): Consider server directory
9 safe on MS-Windows if its owner is the Administrators group while
10 the current Emacs user is Administrator. Use `=' to compare
11 numerical UIDs, since they could be integers or floats.
12
12011-03-07 Chong Yidong <cyd@stupidchicken.com> 132011-03-07 Chong Yidong <cyd@stupidchicken.com>
2 14
3 * Version 23.3 released. 15 * Version 23.3 released.
diff --git a/lisp/files.el b/lisp/files.el
index 88063aed2b9..91fed0d1274 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3752,11 +3752,17 @@ we do not remove backup version numbers, only true file version numbers."
3752 (let ((handler (find-file-name-handler file 'file-ownership-preserved-p))) 3752 (let ((handler (find-file-name-handler file 'file-ownership-preserved-p)))
3753 (if handler 3753 (if handler
3754 (funcall handler 'file-ownership-preserved-p file) 3754 (funcall handler 'file-ownership-preserved-p file)
3755 (let ((attributes (file-attributes file))) 3755 (let ((attributes (file-attributes file 'integer)))
3756 ;; Return t if the file doesn't exist, since it's true that no 3756 ;; Return t if the file doesn't exist, since it's true that no
3757 ;; information would be lost by an (attempted) delete and create. 3757 ;; information would be lost by an (attempted) delete and create.
3758 (or (null attributes) 3758 (or (null attributes)
3759 (= (nth 2 attributes) (user-uid))))))) 3759 (= (nth 2 attributes) (user-uid))
3760 ;; Files created on Windows by Administrator (RID=500)
3761 ;; have the Administrators group (RID=544) recorded as
3762 ;; their owner. Rewriting them will still preserve the
3763 ;; owner.
3764 (and (eq system-type 'windows-nt)
3765 (= (user-uid) 500) (= (nth 2 attributes) 544)))))))
3760 3766
3761(defun file-name-sans-extension (filename) 3767(defun file-name-sans-extension (filename)
3762 "Return FILENAME sans final \"extension\". 3768 "Return FILENAME sans final \"extension\".
diff --git a/lisp/server.el b/lisp/server.el
index f62a7c73abc..816a072bf75 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -474,7 +474,13 @@ See variable `server-auth-dir' for details."
474 (file-name-as-directory dir)) 474 (file-name-as-directory dir))
475 :warning) 475 :warning)
476 (throw :safe t)) 476 (throw :safe t))
477 (unless (eql uid (user-uid)) ; is the dir ours? 477 (unless (or (= uid (user-uid)) ; is the dir ours?
478 (and w32
479 ;; Files created on Windows by
480 ;; Administrator (RID=500) have
481 ;; the Administrators (RID=544)
482 ;; group recorded as the owner.
483 (= uid 544) (= (user-uid) 500)))
478 (throw :safe nil)) 484 (throw :safe nil))
479 (when w32 ; on NTFS? 485 (when w32 ; on NTFS?
480 (throw :safe t)) 486 (throw :safe t))