[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
vc-mode-line ancient, root-specific code for buffer-read-only
From: |
Glenn Morris |
Subject: |
vc-mode-line ancient, root-specific code for buffer-read-only |
Date: |
Tue, 18 Dec 2018 23:49:39 -0500 |
User-agent: |
Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) |
Hi,
vc-mode-line contains this:
;; If the user is root, and the file is not owner-writable,
;; then pretend that we can't write it
;; even though we can (because root can write anything).
;; This way, even root cannot modify a file that isn't locked.
(and (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)))
Some version of this has been present since at least 1996.
It is buggy in that it has a race condition: (file-modes buffer-file-name)
will return nil if the file has been deleted, and logand will error.
Eg this happens if you run make lisp/vc/vc-bzr-tests as root, which is
presumably what prompted Debian to disable one of the tests
https://sources.debian.org/patches/emacs/1:26.1+1-1/0010-Mark-vc-bzr-test-fauilt-bzr-autoloads-as-unstable-fo.patch/
I would like to suggest just removing that vc-mode-line code.
It's for locking VCS, is buggy, and doesn't even make sense.
root cannot "write anything", unless we are concerned with odd cases
like a file being writable by other but not owner. Ie locked files would
be marked read-only for root anyway.
- vc-mode-line ancient, root-specific code for buffer-read-only,
Glenn Morris <=