Wednesday, May 3, 2017

Re: Strange behavior with x! and permissions

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.

That is the reason /tmp has the sticky bit (t) set, so that you cannot
delete files from other users.

Best,
Christian
--
Lachen: ein Affekt aus der plötzlichen Verwandlung einer gespannten
Erwartung in nichts.
-- Immanuel Kant

--
--
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: