On 22:59 30 Jan 2003, Todd A. Jacobs <[EMAIL PROTECTED]> wrote:
| On Thu, 30 Jan 2003, Rigler, S C (Steve) wrote:
| > I guess I must have an evil vi on all of my machines, because I've been
| > doing this for some time (using ":w!" to override read-only permission
| > when I own the file).
| 
| The problem is that if you have write permissions on the directory, you 
| can add and delete directory entries regardless of the permissions on the 
| file itself.
| 
| Some editors (vi is a good example) don't edit the actual file; they edit
| a temporary copy the way all good multi-user utilities should. If you do a
| ":w!" and you have sufficient privelege for the directory, it can unlink
| the file and move the temporary data to a new file with the old name and
| permissions.

Vim will do this (there's some setting for it). Most vis don't. They
all edit a copy, but generally overwrite the original.

| It only *looks* like it's over-writing the old file. It isn't. But the end 
| result is the same.

No, not quite. Consider:

        echo hi >foo    # make file
        chmod 444 foo   # remove write permission
        ln foo bah      # link to second name
        umask 2         # just to ensure
        vim foo         # and go :w!

If your hypothesis were correct there would be two distinct files now,
the "foo" one with a mode 664. (Which is a core reason I loathe apps
which do the unlink/new-file thing.) A quick experiment reveals that vim
leaves them linked with the perms ok. So it must in fact be tweaking the
permissions to add write, rewriting, and putting the permissions back.
Which is sort of ok in my book.

Still, I use nvi mostly, and expect to have to tweak perms if I lock
myself out - I will have done it for a reason, after all.
-- 
Cameron Simpson, DoD#743        [EMAIL PROTECTED]    http://www.zip.com.au/~cs/

A host is a host from coast to coast
& no one will talk to a host that's close
Unless the host (that isn't close)
is busy, hung or dead
        - David Lesher, [EMAIL PROTECTED]



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to