суббота, 7 сентября 2013 г., 14:36:34 UTC+3 пользователь James McCoy написал:
> On Sat, Sep 07, 2013 at 03:42:55AM -0700, cac2s wrote:
> 
> > The question is not why vim does not open undo files, but that is why
> 
> > owners of these files are different?
> 
> 
> 
> In the common case (not editing as root), even if you can edit a file
> 
> not owned by you, you can't create files that aren't owned by you.
> 
> 
> 
> > For example, if I edit the file list.txt as root, and it belongs to
> 
> > the www-data:www-data, undo file will be saved in
> 
> > /root/.vim/undofiles/, but use it when I reopen list.txt I can't,
> 
> > because undo file will belong to root:www-data, but not to
> 
> > www-data:www-data
> 
> 
> 
> root-specific code could probably be added, but that doesn't solve the
> 
> problem for a normal user that can edit due to group membership/ACLs.
> 
> The undo file would still have a different user.
> 
> 
> 
> Cheers,

I've tried this experiment:

1. $ sudo vim /var/www/htdocs/robots.txt

robots.txt is owned by www-data:www-data

2. made some changes in the robots.txt and ":wq"

3. $ sudo ls -la /root/.vim/undofiles/%var%www%htdocs%robots.txt
-rw-r----- 1 root www-data 2234 Sep  7 14:43 
/root/.vim/undofiles/%var%www%htdocs%robots.txt

as you can see the undo file of robots.txt owned by root:www-data now

4. sudo chown cac2s.cac2s /root/.vim/undofiles/%var%www%htdocs%robots.txt

"cac2s.cac2s" is chosen only as an example

$ sudo ls -la /root/.vim/undofiles/%var%www%htdocs%robots.txt
-rw-r----- 1 cac2s cac2s 2234 Sep  7 14:43 
/root/.vim/undofiles/%var%www%htdocs%robots.txt

5. made some changes in the robots.txt and ":wq"

6. $ sudo ls -la /root/.vim/undofiles/%var%www%htdocs%robots.txt
-rw-r----- 1 root www-data 2234 Sep  7 14:43 
/root/.vim/undofiles/%var%www%htdocs%robots.txt

the undo file of robots.txt owned by root:www-data again! not by cac2s:cac2s as 
it was set in step 4.


this experiment suggests that vim himself sets the owner of undo file, using 
the fact that it is running as root.

so maybe correctly set the owner of undo file the same as that of the file 
being edited, knowing that vim running as root, which guarantees the continued 
use of the file changes for an undo/redo actions?

-- 
-- 
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/groups/opt_out.

Raspunde prin e-mail lui