Re: sys_chown() hits symlinks

Richard Gooch (rgooch@atnf.CSIRO.AU)
Fri, 23 Jan 1998 17:00:32 +1100


Linus Torvalds writes:
> In article <69sqr7$f3$1@palladium.transmeta.com>,
> H. Peter Anvin <hpa@transmeta.com> wrote:
> >
> >Incorrect. Neither the owner nor the mode of a symlink have any
> >effects, whatsoever.
>
> Actually, the owner of a symlink _does_ matter for sticky directories,
> which is why you really want to be able to change the owner.
>
> Essentially, if you cannot change the owner of a symlink, you cannot
> reliably do a "chown -R" on a directory tree. Imagine being a sysadmin
> and moving a person from one uid or group to another..
>
> In short: either you have to have "lchown()" or your "chown()" has to
> act on the symlink rather than on the target. Linux takes the second
> approach, which is the traditional one.

Solaris: chown() traverses the link
SunOS: chown() hits the link
IRIX 6: chown() traverses the link
DEC Unix V3.2: chown() traverses the link

Linus, I really think that chown() should traverse the symlink. If you
think that we need a way to change the uid/gid of a symlink, I'll
write a lchown() syscall and give you the patch. Please let me know if
you're happy to go with that, and I'll start coding.

The reason chown() not following a symlink is a problem is that if
your /dev/tty* device is a symlink to elsewhere, then the various
system utilities don't properly change the ownership of the tty
device.

Regards,

Richard....