diff options
| author | Richard M. Stallman | 1996-06-18 16:52:09 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-06-18 16:52:09 +0000 |
| commit | 9becbeca26e360f9e9b5020a8e32748c11917883 (patch) | |
| tree | 7f0e64ca36f5d717ea6cabbd864ca7123127b9d5 /lisp | |
| parent | a0341d132be82cf82c74258655c0d81c86a88b4c (diff) | |
| download | emacs-9becbeca26e360f9e9b5020a8e32748c11917883.tar.gz emacs-9becbeca26e360f9e9b5020a8e32748c11917883.zip | |
(vc-mode-line): If user is root, verify file really has user-writable bit.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/vc-hooks.el | 15 |
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." | |||
| 878 | (and vc-type | 878 | (and vc-type |
| 879 | (concat " " (or label (symbol-name vc-type)) | 879 | (concat " " (or label (symbol-name vc-type)) |
| 880 | (and vc-display-status (vc-status file))))) | 880 | (and vc-display-status (vc-status file))))) |
| 881 | ;; If the file is locked by some other user, make | ||
| 882 | ;; the buffer read-only. Like this, even root | ||
| 883 | ;; cannot modify a file without locking it first. | ||
| 881 | (and vc-type | 884 | (and vc-type |
| 882 | (equal file (buffer-file-name)) | 885 | (equal file (buffer-file-name)) |
| 883 | (vc-locking-user file) | 886 | (vc-locking-user file) |
| 884 | ;; If the file is locked by some other user, make | ||
| 885 | ;; the buffer read-only. Like this, even root | ||
| 886 | ;; cannot modify a file without locking it first. | ||
| 887 | (not (string= (user-login-name) (vc-locking-user file))) | 887 | (not (string= (user-login-name) (vc-locking-user file))) |
| 888 | (setq buffer-read-only t)) | 888 | (setq buffer-read-only t)) |
| 889 | ;; If the user is root, and the file is not owner-readable, | ||
| 890 | ;; then pretend that we can't read it | ||
| 891 | ;; even though we can (because root can read anything). | ||
| 892 | (and vc-type | ||
| 893 | (equal file (buffer-file-name)) | ||
| 894 | (not buffer-read-only) | ||
| 895 | (zerop (user-real-uid)) | ||
| 896 | (zerop (logand (file-modes (buffer-file-name)) 128)) | ||
| 897 | (setq buffer-read-only t)) | ||
| 889 | (force-mode-line-update) | 898 | (force-mode-line-update) |
| 890 | ;;(set-buffer-modified-p (buffer-modified-p)) ;;use this if Emacs 18 | 899 | ;;(set-buffer-modified-p (buffer-modified-p)) ;;use this if Emacs 18 |
| 891 | vc-type)) | 900 | vc-type)) |