Commit 2920e68d authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

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.
parent 69cc79e9
2011-03-11 Eli Zaretskii <eliz@gnu.org>
* 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.
* 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.
2011-03-07 Chong Yidong <cyd@stupidchicken.com>
* Version 23.3 released.
......
......@@ -3752,11 +3752,17 @@ we do not remove backup version numbers, only true file version numbers."
(let ((handler (find-file-name-handler file 'file-ownership-preserved-p)))
(if handler
(funcall handler 'file-ownership-preserved-p file)
(let ((attributes (file-attributes file)))
(let ((attributes (file-attributes file 'integer)))
;; Return t if the file doesn't exist, since it's true that no
;; information would be lost by an (attempted) delete and create.
(or (null attributes)
(= (nth 2 attributes) (user-uid)))))))
(= (nth 2 attributes) (user-uid))
;; Files created on Windows by Administrator (RID=500)
;; have the Administrators group (RID=544) recorded as
;; their owner. Rewriting them will still preserve the
;; owner.
(and (eq system-type 'windows-nt)
(= (user-uid) 500) (= (nth 2 attributes) 544)))))))
(defun file-name-sans-extension (filename)
"Return FILENAME sans final \"extension\".
......
......@@ -474,7 +474,13 @@ See variable `server-auth-dir' for details."
(file-name-as-directory dir))
:warning)
(throw :safe t))
(unless (eql uid (user-uid)) ; is the dir ours?
(unless (or (= uid (user-uid)) ; is the dir ours?
(and w32
;; Files created on Windows by
;; Administrator (RID=500) have
;; the Administrators (RID=544)
;; group recorded as the owner.
(= uid 544) (= (user-uid) 500)))
(throw :safe nil))
(when w32 ; on NTFS?
(throw :safe t))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment