summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1996-06-18 16:52:09 +0000
committerRichard M. Stallman <rms@gnu.org>1996-06-18 16:52:09 +0000
commit4b1383c8155833e3cc3357b1bbc0d85a3bb73824 (patch)
treeaf5ad59874266fc0c1f375a043e42530049f79e9
parentdc115a0d66305982deddf9d66e48661b53aab074 (diff)
downloademacs-4b1383c8155833e3cc3357b1bbc0d85a3bb73824.tar.gz
(vc-mode-line): If user is root, verify file really has user-writable bit.
-rw-r--r--lisp/vc-hooks.el15
1 files changed, 12 insertions, 3 deletions
diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el
index 5005c30383a..86e53116583 100644
--- a/lisp/vc-hooks.el
+++ b/lisp/vc-hooks.el
@@ -878,14 +878,23 @@ control system name."
(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))