Why change the owner of a symbolic link in linux?
Apache can be configured to follow symlinks only if the owner of the link matches the owner of the destination. This can help prevent users from creating links for web access to files they don't own (e.g. /etc/passwd).
... so let's say you, as root, wanted apache to follow a link to display a certain logfile, which was owned by xymon or something, but you didn't want to relax apache's security by allowing it to follow symlinks regardless of owner. Then you might want to make xymon the owner of the symlink.
Suppose root is working in a directory that Eve can write to. There's a file foo
in this directory that needs to be changed to belong to Eve. So root types chown eve foo
. But just before root hits Enter, Eve runs ln -sf /etc/passwd foo
. Now /etc/passwd
belongs to Eve! If root can run chown -h eve foo
to make sure not to follow symlinks, then the most harm that can be done is that some other file in the same directory has been changed to belong to Eve.
lchown
is also convenient when you're changing the owner of a directory tree. You don't need to worry about accidentally affecting a file outside the tree because you called chown
on a symbolic link.
The first answer doesn't seem to adress the question, and the second one only applies to Apache.
One thing I can think of for linux in general is that it's only possible for an ordinary user to make a hard link to a symbolic link if the user is the owner of the symbolic link. Why one would want to make such a link, I don't know.
Another thing is that an ordinary user can only change the group ownership of a file if the user owns the file (and is also a member of the group the file is being added to.) That brings up the question of what the group ownership of a symbolic link does. In an organization, it might be useful as a tag to indicate which team would have need of the link.
Also, on Ubuntu at least, anyone can update the timestamp of a symbolic link. However, there may be some systems that only allow the owner to. What good the timestamp does for a symbolic link, I'm not sure, but it may give some useful information on how much it's used.
Edit: I just realized another reason why ownership would be important. The link could be inside of a sticky directory, where only the owner of a file can delete or rename it.