On Wed, 2005-06-08 at 23:02 +0300, shimi wrote: > On Wed, 2005-06-08 at 21:39 +0300, Shachar Shemesh wrote: > > Alon Altman wrote: > > > > > On Wed, 8 Jun 2005, Shachar Shemesh wrote: > > > > > >> Hi all, > > >> > > >> Does anyone know WHY only root can create hard links to directories? > > >> What is the attack/problem this permission restriction is trying to > > >> solve? > > > > > > > > > Because only root can unlink a non-empty directory? > > > > I was hoping to learn something new from the answers, but I have to > > admit that I didn't expect anything like that. > > > > WHY can root unlink a non-empty directory? Why is that useful? What's > > the difference between that and "rm -r", and when would I want to use that? > > > > Congrats, Alon. Not only did you not answer my question, you've added to > > the mystery :-) > > My assumption: if you hard-link to a file not owned by you, inside a > directory you do have write access to (otherwise you can't create the > link), the file will of course be identical to the original file (it > _is_ a hard-link). Meaning it will have the same owner, same > permissions, and same bits in general. > > So... > > 1) I am in /home/shimi/test and my uid is 500 > 2) I do ln -d /sbin/ifconfig > 3) If I do ls -li, I see "ifconfig" with the same inode > of /sbin/ifconfig, owned by uid 0. > 4) I try rm -rf ~/test - and I fail. I cannot erase the file "ifconfig" > because it is not owned by me (even though I created it. bad!). I also > can't erase the directory because it's non-empty (and I'm not root).
Replying to myself ; on second thought, I was answering about files and not directories; That example would actually work. But on a directory it's a bit different, as it may contain files (?). I just tried that (with -d), and got a Operation not permitted (although being root and linking on the same FS). I quit. No replies next time when I'm tired. sorry :) -- shimi <[EMAIL PROTECTED]> ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
