Hi Rob!
On Do, 08 Aug 2013, Rob Owens wrote:
> ----- Original Message -----
> > From: "Rob Owens" <rowens@ptd.net>
> >
> > ----- Original Message -----
> > > From: "Dahong Tang" <tang.dahong@gmail.com>
> >
> > > Here are the commands that I tested:
> > >
> > > $ sudo touch testvim
> > > $ ls -al
> > > -rw-r--r-- 1 root root 0 Aug 8 08:25 testvim
> > > $ vi testvim
> > > :w!
> > > :q
> > > $ ls -al
> > > -rw-r--r-- 1 user user 0 Aug 8 08:26 testvim
> > >
> > > I don't understand why vim would override both file permission and
> > > ownership. Any ideas?
> > >
> >
> > I can't reproduce this. When I enter :w! I get the following
> > message:
> >
> > "testvim" E212: Can't open file for writing
> > Press ENTER or type command to continue
> >
> > This is on a Debian Wheezy system with the packaged version of vim.
> >
> I tried the above in the /tmp directory. When I try it in my own home directory, it indeed works like Dahong says.
What you are seeing, is the effect of the sticky bit and Vim trying to
delete the file. This doesn't work in the /tmp directory, since you
neither own the directory nor do you own the file, so you don't get the
permission to drop the file. In the other directory, you probably had
write permissions so you could successfully delete the file. I think
this comment in fileio.c says it all:
,----
| /*
| * Open the file "wfname" for writing.
| * We may try to open the file twice: If we can't write to the
| * file and forceit is TRUE we delete the existing file and try to create
| * a new one. If this still fails we may have lost the original file!
| * (this may happen when the user reached his quotum for number of files).
| * Appending will fail if the file does not exist and forceit is FALSE.
| */
| while ((fd = mch_open((char *)wfname, O_WRONLY | O_EXTRA | (append
| ? (forceit ? (O_APPEND | O_CREAT) : O_APPEND)
| : (O_CREAT | O_TRUNC))
| , perm < 0 ? 0666 : (perm & 0777))) < 0)
`----
Mit freundlichen Grüßen
Christian
--
Nichts hindert so sehr daran, natürlich zu sein, wie der Wunsch, es zu
scheinen.
-- François de La Rochefoucault
--
--
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/groups/opt_out.
Thursday, August 8, 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment