changeset 15448:593dadb4f287

(vc-mode-line): If user is root, verify file really has user-writable bit.
author Richard M. Stallman <rms@gnu.org>
date Tue, 18 Jun 1996 16:52:09 +0000
parents 41bce2c4b1b8
children 8e6b770317a5
files lisp/vc-hooks.el
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/vc-hooks.el	Tue Jun 18 16:28:22 1996 +0000
+++ b/lisp/vc-hooks.el	Tue Jun 18 16:52:09 1996 +0000
@@ -878,14 +878,23 @@
 	  (and vc-type
 	       (concat " " (or label (symbol-name vc-type)) 
 		       (and vc-display-status (vc-status file)))))
+    ;; If the file is locked by some other user, make
+    ;; the buffer read-only.  Like this, even root
+    ;; cannot modify a file without locking it first.
     (and vc-type 
 	 (equal file (buffer-file-name))
 	 (vc-locking-user file)
-	 ;; If the file is locked by some other user, make
-	 ;; the buffer read-only.  Like this, even root
-	 ;; cannot modify a file without locking it first.
 	 (not (string= (user-login-name) (vc-locking-user file)))
 	 (setq buffer-read-only t))
+    ;; If the user is root, and the file is not owner-readable,
+    ;; then pretend that we can't read it
+    ;; even though we can (because root can read anything).
+    (and vc-type
+	 (equal file (buffer-file-name))
+	 (not buffer-read-only)
+	 (zerop (user-real-uid))
+	 (zerop (logand (file-modes (buffer-file-name)) 128))
+	 (setq buffer-read-only t))
     (force-mode-line-update)
     ;;(set-buffer-modified-p (buffer-modified-p)) ;;use this if Emacs 18
     vc-type))