Re: sys_chown() hits symlinks

Linus Torvalds (
Sun, 18 Jan 1998 13:52:42 -0800 (PST)

On Sun, 18 Jan 1998 wrote:
> According to Linus Torvalds:
> > Actually, the owner of a symlink _does_ matter for sticky directories
> > [...]
> > Essentially, if you cannot change the owner of a symlink, you cannot
> > reliably do a "chown -R" on a directory tree.
> Agreeable. But what of "chmod -R", then?

That's another issue - symlinks always have mode lrwxrwxrwx, and nobody
can change that, including root. So a "chmod -R" should just ignore
symlinks (you have do do a "stat()" anyway to check whether it is a
directory, so you get the symlink info at the same time - and know to not
do the chmod() because it would try to follow the link which is not what
you want).

Essentially, yes they have different behaviour, and yes you can consider
that to be strange. However, another way of looking at it is that symlinks
have fundamentally different meanings for chown() and chmod() anyway (one
of them doesn't make any sense), so it is ok to have different behaviour.

I'm not saying that it wouldn't make more sense to have "lchown()", but I
also don't think it makes all that much of a difference.