Wednesday, May 3, 2017

Re: Strange behavior with x! and permissions

On 2017-05-03, Christian Brabandt wrote:
> Hi Niels!
>
> On Mi, 03 Mai 2017, Niels Kobschätzki wrote:
>
> > I found today the following on a Debian 8.7 (vim 7.4.576) and FreeBSD 11
> > (8.0.579): I am in my home-dir "user" and there I create a file with the
> > following permissions: root:user 640
> >
> > When I open the file as "user", vim tells me that the file is read-only.
> > I edit it, and close it with :x!
> > vim writes the file and sets the permissions to:
> > user:user 640
> >
> > I didn't use sudo or anything. When I tried to do a chown or chmod on
> > this file to set the permissions to user:user from root:user it failed
> > because "user" didn't have the permissions.
> >
> > What is happening here?
>
> The user has write permissions on the directory, therefore he can
> happily delete the file owned by root and create a new file. And that is
> what Vim is doing.

If that was true, I would expect the inode number of the file to be
different after Vim had edited it, but that is not what I observe.
The inode number is unchanged.

I created a file with only read permissions and successfully edited
it with Vim. I repeated the experiment in a directory with only
read and execute permissions and was able to edit that file as well.

Regards,
Gary

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment