On Sat, Sep 07, 2013 at 05:23:13AM -0700, cac2s wrote:
> 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.

None of the above disagrees with what I said.  You also don't show
whether the undo files after steps 4 and 5 are the same inode.  It may
not be a matter of vim changing the ownership of the existing undo file,
but creating a new file.

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

Which only works for root, as I stated before.  Non-root users can't set
arbitrary users as the owner for their files, so you still have a
situation where it's not possible to make the owner of the undo file
match that of the file being edited.

Cheers,
-- 
James
GPG Key: 4096R/331BA3DB 2011-12-05 James McCoy <[email protected]>

Attachment: signature.asc
Description: Digital signature

Raspunde prin e-mail lui