+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.
(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\".
(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))