Re: Gain owner of a file using vim :w!
I'm not sure how this works. What were the permissions on the file before you edited it? Yeah, you sure your not accessing an sftp with suid dir permissions. I get permission denied. Also setting chattr +ias on a file as root prevents the folder shenanigans On OpenBSD setting chflags schg means you would need to reboot or defeat the very secure kernel. I understand how the folder thing could trick you and I would guess whether it is a bug has been debated many times coming down to inodes vs logic but as for read-only and IPR how could you expect any different, you can prevent others except root reading with standard chmod? -- ___ 'Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface' (Doug McIlroy) ___ -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/305833.61127...@smtp101.mail.ir2.yahoo.com
Re: Gain owner of a file using vim :w!
[sent privately by mistake] On Mi, 22 mai 13, 19:48:37, Beco wrote: Dear users, I'm astonished by this (maybe I'm naive and I'm missing something). Yesterday as root I saved a file skel.bashrc in my /home/beco user, owned by root, group root. Today I edited it, logged as beco, and vi told me warning, read only!. I edited anyway, just to test, and saved with :w! After that I checked the file and it has changed to owner beco, group beco. How is that possible? Check this out: amp@sid:~$ sudo touch tmp/testfile amp@sid:~$ ls -l tmp/testfile -rw-r--r-- 1 root root 0 May 23 01:58 tmp/testfile amp@sid:~$ rm tmp/testfile rm: remove write-protected regular empty file `tmp/testfile'? y amp@sid:~$ ls -l tmp/testfile ls: cannot access tmp/testfile: No such file or directory amp@sid:~$ AFAIR it has to do with the fact that you own the directory and rm just deletes the directory entry for that file. With vi(m) (and I assume most other editors) this works because when you edit a file you don't work on the actual file, but on a copy of it. When you save it vi(m) replaces the original file with the changed copy (effectively rm/rename), because in case of a crash/power failure/etc. you still have the original and hopefully even most of the changed file (depending on autosave settings). Hope this explains, Andrei -- If you can't explain it simply, you don't understand it well enough. (Albert Einstein) signature.asc Description: Digital signature
Re: Gain owner of a file using vim :w!
On Thu, 23 May 2013 00:50:01 +0200, Beco wrote: Dear users, I'm astonished by this (maybe I'm naive and I'm missing something). Yesterday as root I saved a file skel.bashrc in my /home/beco user, owned by root, group root. Today I edited it, logged as beco, and vi told me warning, read only!. I edited anyway, just to test, and saved with :w! After that I checked the file and it has changed to owner beco, group beco. How is that possible? Thanks, Beco Did you want the modified file to remain owned by root? That would, of course, be _more_ dangerous! -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/knlgup$sno$1...@dont-email.me
Gain owner of a file using vim :w!
Dear users, I'm astonished by this (maybe I'm naive and I'm missing something). Yesterday as root I saved a file skel.bashrc in my /home/beco user, owned by root, group root. Today I edited it, logged as beco, and vi told me warning, read only!. I edited anyway, just to test, and saved with :w! After that I checked the file and it has changed to owner beco, group beco. How is that possible? Thanks, Beco -- Dr Beco A.I. researcher Sometimes the heart sees what is invisible to the eye. (H. Jackson Brown Jr.)
Re: Gain owner of a file using vim :w!
On Wed, May 22, 2013 at 07:48:37PM -0300, Beco wrote: Dear users, I'm astonished by this (maybe I'm naive and I'm missing something). Yesterday as root I saved a file skel.bashrc in my /home/beco user, owned by root, group root. Today I edited it, logged as beco, and vi told me warning, read only!. I edited anyway, just to test, and saved with :w! After that I checked the file and it has changed to owner beco, group beco. How is that possible? Thanks, Beco -- Dr Beco A.I. researcher Sometimes the heart sees what is invisible to the eye. (H. Jackson Brown Jr.) According to the vim docs [0]: :w[rite]! [++opt] Like :write, but forcefully write when 'readonly' is set or there is another reason why writing was refused. Note: This may change the permission and ownership of the file and break (symbolic) links. Add the 'W' flag to 'cpoptions' to avoid this. I'm not sure how this works. What were the permissions on the file before you edited it? [0] - http://vimdoc.sourceforge.net/htmldoc/editing.html#writing -- staticsafe O ascii ribbon campaign - stop html mail - www.asciiribbon.org Please don't top post - http://goo.gl/YrmAb Don't CC me! I'm subscribed to whatever list I just posted on. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20130523002605.ga4...@uriel.asininetech.com
Re: Gain owner of a file using vim :w!
On 05/22/2013 04:48 PM, Beco wrote: Dear users, I'm astonished by this (maybe I'm naive and I'm missing something). Yesterday as root I saved a file skel.bashrc in my /home/beco user, owned by root, group root. Today I edited it, logged as beco, and vi told me warning, read only!. I edited anyway, just to test, and saved with :w! After that I checked the file and it has changed to owner beco, group beco. How is that possible? Thanks, Beco -- Dr Beco A.I. researcher Sometimes the heart sees what is invisible to the eye. (H. Jackson Brown Jr.) I did not know about this, and it is suprising, but ... I have frequently used another flaw in the read-only security to get a copy with write permission. I open a new document in a new window, and then use my mouse to select the whole text in the window holding the read-only original. Then I paste that text into the new, empty document. The read-only feature of the UNIX paradigm is not a way of enforcing intellectual property rights. It is just a way of reminding oneself to be careful and not clobber something that one really needs to keep. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/519d6545.3070...@gmail.com
Re: Gain owner of a file using vim :w!
Beco r...@beco.cc writes: Dear users, I'm astonished by this (maybe I'm naive and I'm missing something). Yesterday as root I saved a file skel.bashrc in my /home/beco user, owned by root, group root. Today I edited it, logged as beco, and vi told me warning, read only!. I edited anyway, just to test, and saved with :w! After that I checked the file and it has changed to owner beco, group beco. How is that possible? You have write permission to the directory, so you can delete the file and create a new one, with yourself as the owner. That is, essentially, what vi is doing. -- Joe Riel -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/87bo82czos@san.rr.com
Re: Gain owner of a file using vim :w!
Joe Riel writes: You have write permission to the directory, so you can delete the file and create a new one, with yourself as the owner. That is, essentially, what vi is doing. Note that if the file had had a hardlink in another directory, say one owned by root, that link (and therefor the actual file) would not have been deleted. The effect would have been to replace the link in his directory with a copy owned by him, leaving the original file and the other link unchanged. -- John Hasler -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/87ppwi9ytx@thumper.dhh.gt.org