Subject: standards/17504: POSIX.1-2001: chown -RP doesn't affect symlinks
To: None <gnats-bugs@gnats.netbsd.org>
From: Ben Harris <bjh21@netbsd.org>
List: netbsd-bugs
Date: 07/07/2002 13:23:58
>Number:         17504
>Category:       standards
>Synopsis:       POSIX.1-2001: chown -RP doesn't affect symlinks
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    standards-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 07 05:25:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Ben Harris
>Release:        1.6_BETA4
>Organization:
>Environment:
NetBSD 1.6_BETA4 (RPC_WSCONS) #0: Fri Jul  5 10:48:27 UTC 2002
    autobuild@tgm.daemon.org:/autobuild/acorn32/OBJ/autobuild/src/sys/arch/acorn32/compile/RPC_WSCONS

>Description:
POSIX.1-2001 says, of chown -P:

    -P  If the -R option is specified and a symbolic link is specified on the
        command line or encountered during the traversal of a file hierarchy,
        chown shall change the owner ID (and group ID, if specified) of the
        symbolic link if the system supports this operation. The chown utility
        shall not follow the symbolic link to any other part of the file
        hierarchy.

However, under NetBSD, chown -RP leaves the ownership of symlinks alone, and
the -h option is needed to change their ownership.  It's debatable whether
this is a bug in NetBSD or in the standard, especially since symlink(7)
specifies our current behaviour, and I have yet to find an implementation
that follows POSIX.

>How-To-Repeat:

southeast-iceland# mkdir foo
southeast-iceland# touch foo/bar
southeast-iceland# ln -s bar foo/baz
southeast-iceland# ls -la foo
total 2
drwxr-xr-x  2 root  wheel  512 Jul  7 12:08 .
drwxrwxrwt  4 root  wheel  512 Jul  7 12:08 ..
-rw-r--r--  1 root  wheel    0 Jul  7 12:08 bar
lrwxr-xr-x  1 root  wheel    3 Jul  7 12:08 baz -> bar
southeast-iceland# chown -RP bjh21 foo
southeast-iceland# ls -la foo
total 2
drwxr-xr-x  2 bjh21  wheel  512 Jul  7 12:08 .
drwxrwxrwt  4 root   wheel  512 Jul  7 12:08 ..
-rw-r--r--  1 bjh21  wheel    0 Jul  7 12:08 bar
lrwxr-xr-x  1 root   wheel    3 Jul  7 12:08 baz -> bar

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted: