* Christian Brabandt <[email protected]> [171102 16:50]:
> 
> On Do, 02 Nov 2017, [email protected] wrote:
> 
> > 
> > However, there is another problem with the swap file permissions
> > that has not yet been discussed: when Vim creates swap files, the
> > .swp file is created with the owner and group set to the user who is
> > editing the file (hereafter referred to as the "editor") and the
> > editor's primary group respectively. The permission bits on the swap
> > file are the same as the original file.
> > 
> > This is a problem, as the editor's primary group may be different
> > from the group of the file being edited. Take /etc/shadow for
> > example. That file is supposed to have the permissions 640 with
> > owner: root, group: shadow as a quick `ls -l` shows:
> > 
> > -rw-r----- 1 root shadow 1195 Sep 16 20:09 /etc/shadow
> > 
> > However, shadow is not the root user's primary group; on this system
> > it happens to be 'users', which every other user on the system is
> > also a member of. Now if root goes to edit the file, a swap file is
> > created in /etc/.shadow.swp with the following permissions:
> > 
> > -rw-r----- 1 root users 4096 Nov  2 13:52 /etc/.shadow.swp
> > 
> > This swap file is now readable by every user on the system. Keep in
> > mind the /etc/shadow file contains hashes of every user's password,
> > so now the password for every single user on the system may have
> > been compromised.
> 
> That looks like a problem.

I agree.  One solution is if the user doing the editing has permission
to create the swap file with the original file's user:group, then do
that with the original file's perms.  Otherwise use the editing user's
user:group and perm 0600.

Another solution would be to always use the editing user's user:group
and perm 0600.

There might need to be more logic added to recover to check if the
current user has rw permission on the swap file.  However, this might
very well just 'work' (i.e. fail gracefully) with the current code.

Re Bram's question about root's default group being users:  While that
seems like a bad idea in general, the situation could still come up with
very reasonable user/group combinations.  Take a 'normal' user whose
default group is users, but who also happens to be a member of group
staff.  A file with root:staff ownership and 0660 perms would have a
swap file with someone:users and perms 0660, thus giving most users rw
access to the swap file when they had neither r nor w access to the
original.

...Marvin

-- 
-- 
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui