Re: sys_chown() hits symlinks

Sudish Joseph (sj@eng.mindspring.net)
23 Jan 1998 14:56:49 -0500


Richard Gooch writes:
> 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.

This seems best. From the Single UNIX Spec., v2:

--------------------------------------------------
NAME

lchown - change the owner and group of a symbolic link

SYNOPSIS

#include <unistd.h>

int lchown(const char *path, uid_t owner, gid_t group);

DESCRIPTION

The lchown() function has the same effect as chown() except in the
case where the named file is a symbolic link. In this case
lchown() changes the ownership of the symbolic link file itself,
while chown() changes the ownership of the file or directory to
which the symbolic link refers.

[...]
--------------------------------------------------

-Sudish