Thursday, August 8, 2013

Re: vim vs nano on editing system files

On Thursday, August 8, 2013 8:22:21 AM UTC-5, Sven Guckes wrote:
> * Dahong Tang <tang.dahong@gmail.com> [2013-08-08 15:14]:
>
> > On Thursday, August 8, 2013 7:43:42 AM UTC-5, Christian Brabandt wrote:
>
> > > On Thu, August 8, 2013 14:18, John Little wrote:
>
> > > > Interestingly, I find sudoedit ignores a lack of write permission.
>
> > > That is because you are editing a temporary file with
>
> > > sane permissions instead of the original file.
>
> > Thanks everyone for point me into the right direction.
>
> > I guess the default behavior of vim is what it is.
>
>
>
> "it is what it is. and that's that." ;-)
>
>
>
> > Curiously, if the file permission is 644 and the
>
> > file belongs to root, then a normal user does not
>
> > even need sudo to override readonly, just use :w!.
>
>
>
> bzzt. a non-root user cannot overwrite a file
>
> owned by root unless he gets write permission.
>
>
>
> > (and in addition, the ownership of the file
>
> > would change from root to the user.)
>
>
>
> bzzt. wrong again.
>
>
>
> > Whereas this is not possible in
>
> > nano, i.e., only root and sudo
>
> > have write permission in 644.
>
> > Does anyone know why is this?
>
>
>
> because he's "root".
>
>
>
> anyway, all of these "probleme"
>
> lack a description of what you do.
>
> unless you can back up what you say
>
> with list of commands showing the
>
> file permissions and the changes
>
> it's simply statements which sound
>
> as if they are simply wrong. sorry.
>
>
>
> so.. either write up something..
>
> or simply wonder forever. :-P
>
>
>
> Sven

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?

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

No comments: