Commit 43fac3be authored by Noam Postavsky's avatar Noam Postavsky

Make "unsafe directory" error message more informative (Bug#865)

* lisp/server.el (server-ensure-safe-dir): Produce a description for
each "unsafe" condition.
parent c59ddb21
......@@ -525,8 +525,10 @@ Creates the directory if necessary and makes sure:
;; Check that it's safe for use.
(let* ((uid (nth 2 attrs))
(w32 (eq system-type 'windows-nt))
(safe (cond
((not (eq t (car attrs))) nil) ; is a dir?
(unsafe (cond
((not (eq t (car attrs)))
(format "it is a %s" (if (stringp (car attrs))
"symlink" "file")))
((and w32 (zerop uid)) ; on FAT32?
......@@ -536,19 +538,22 @@ Directories on FAT32 filesystems are NOT secure against tampering.
See variable `server-auth-dir' for details."
(file-name-as-directory dir))
((and (/= uid (user-uid)) ; is the dir ours?
(or (not w32)
;; Files created on Windows by Administrator
;; (RID=500) have the Administrators (RID=544)
;; group recorded as the owner.
(/= uid 544) (/= (user-uid) 500)))
(w32 t) ; on NTFS?
(t ; else, check permissions
(zerop (logand ?\077 (file-modes dir)))))))
(unless safe
(error "The directory `%s' is unsafe" dir)))))
(format "it is not owned by you (owner = %s (%d))"
(user-full-name (user-uid)) (user-uid)))
(w32 nil) ; on NTFS?
((/= 0 (logand ?\077 (file-modes dir)))
(format "it is accessible by others (%03o)"
(file-modes dir)))
(t nil))))
(when unsafe
(error "`%s' is not a safe directory because %s" dir unsafe)))))
(defun server-generate-key ()
"Generate and return a random authentication key.
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