From 4a7e63b938500c1d43e85848f5d5be10ec3bee8c Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Fri, 24 Dec 1993 03:12:14 +0000 Subject: [PATCH] (vc-mode-line): Make buffer read-only for root if file is locked. --- lisp/vc-hooks.el | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el index 283d2bf56eb..8f407d5b9d8 100644 --- a/lisp/vc-hooks.el +++ b/lisp/vc-hooks.el @@ -147,6 +147,13 @@ visiting FILE." (concat " " (or label (symbol-name vc-type)) (if (and vc-rcs-status (eq vc-type 'RCS)) (vc-rcs-status file))))) + ;; Even root shouldn't modify a registered file without locking it first. + (and vc-type + (not buffer-read-only) + (zerop (user-uid)) + (require 'vc) + (not (string-equal (user-login-name) (vc-locking-user file))) + (setq buffer-read-only t)) ;; force update of mode line (set-buffer-modified-p (buffer-modified-p)) vc-type)) -- 2.39.5