shimi wrote:
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...
Your example is bad, because /sbin/ifconfig is a file, not a directory.
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).
Why can root erase a non-empty directory? If you want to dereference the
directory but not the files. Why would you want to do that? I guess it
could be related to hard-linked directories... ;)
Ok, I think you more or less got it, though.
A link to a file is a standalone thing. If I could create it, I can
erase it. A link to a directory is something that carries an entire
hierarchy with it. It is possible that once I create it, I won't be able
to erase it. Bad.
This may also explain what does "unlinking a non-empty directory" mean.
If the directory was hard linked from another place before, I would be
unlinking it from the directory entry, but not from the other directory
entry. As such, it makes sense to not empty it prior to performing the
unlink.
In other words, if that wasn't possible, the operation "cd /root ; ln -d
/usr" would have been practically irreversible without effectively
reinstalling the machine.
I tried to test it, but it seems that my linux does not allow hard links
to directories, even for root. We will have to make do with our educated
guesses, then. unlinking directories equally fails.
Shachar
--
Shachar Shemesh
Lingnu Open Source Consulting ltd.
Have you backed up today's work? http://www.lingnu.com/backup.html
=================================================================
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]