From: "Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu>
Cc: emacs-devel@gnu.org, Stefan Monnier <monnier+gnu/emacs@rum.cs.yale.edu>
Subject: Re: VC, read-only buffers for writable files
Date: Tue, 22 Oct 2002 10:49:23 -0400 [thread overview]
Message-ID: <200210221449.g9MEnNc22634@rum.cs.yale.edu> (raw)
In-Reply-To: 1035297355.2276.58.camel@eagle
> > Currently VC sometimes makes a file read-only because it thinks it's
> > better that way for the user. More specifically, it makes it read-only
> > if the file seems to be locked by another user.
>
> I have talked this over with Stefan several times, and we have reached
> no agreement.
We did agree to postpone the decision to after 21.1, tho ;-)
> > This special behavior used to apply to SCCS, RCS and CVS under Emacs-20
> > and was silently changed in Emacs-21 to only apply to RCS and SCCS (it was
> > changed as a side effect of another change). Nobody complained about
> > this change and I think we should go further and remove this hack
> > altogether so it doesn't aply to RCS and SCCS either.
>
> The behavior wasn't changed accidentally for CVS. There are no locks
Maybe it wasn't accidentally, but it was changed. In Emacs-20 you
could end up in CVS with a read-only buffer because the owner of the
locally modified file was different from the current user (or
seemed that way to VC). That's because VC considered a locally modified
CVS file as "locked by the owner of the file".
> under CVS, and Emacs-21 handles that correctly by not assuming that a
> file could be "locked" by anybody. RCS and SCCS do have locks, and
> Emacs-21 deliberately chooses to enforce the locking. This is not a
> "hack".
Sorry for using "hack". I tried to be somewhat "neutral" in my post,
but my bias took precedence. The reason why I think it's a hack
is because such things *should* be enforced with file permissions
and are enforced that way on all the systems I've used.
> Here is the relevant portion of code from vc-hooks.el, since the
> comments may make it clearer to everybody.
>
> ;; If the file is locked by some other user, make
> ;; the buffer read-only. Like this, even root
> ;; cannot modify a file that someone else has locked.
> (and (equal file (buffer-file-name))
> (stringp (vc-state file))
> (setq buffer-read-only t))
> ;; 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)))
Note that I'd gladly remove the second half as well, but I'm mostly
interested in the first half (the behavior of Emacs when run as root
is not of much concern to me).
Stefan
next prev parent reply other threads:[~2002-10-22 14:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-22 13:31 VC, read-only buffers for writable files Stefan Monnier
2002-10-22 14:35 ` Andre Spiegel
2002-10-22 14:49 ` Stefan Monnier [this message]
2002-10-23 7:12 ` Richard Stallman
2002-10-23 7:39 ` Stefan Monnier
2002-10-24 16:54 ` Richard Stallman
2002-10-24 17:03 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200210221449.g9MEnNc22634@rum.cs.yale.edu \
--to=monnier+gnu/emacs@rum.cs.yale.edu \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).