[This is a correction of my last e-mail that incorrectly referred to "chmod" instead of "chown" in a couple of places. This report is about chown. Sorry about that.]

I hope I'm not making a fool of myself, but here we go:

version: coreutils-5.2.1-3.rpm (from SuSE 9.2). Linux kernel 2.6.11.1.
reiserfs.

Quoting from the chown man page:
The following options modify how a hierarchy is traversed when the  -R  option  
is
       also specified.  If more than one is specified, only the final one takes 
effect.

       -H     if a command line argument is a symbolic link to a directory, 
traverse it

       -L     traverse every symbolic link to a directory encountered

-P do not traverse any symbolic links (default)

The info page for chown agrees:
`-R'
`--recursive'
     Recursively change ownership of directories and their contents.

`-H'
     If `--recursive' (`-R') is specified and a command line argument
     is a symbolic link to a directory, traverse it.  *Note Traversing
     symlinks::.

`-L'
     In a recursive traversal, traverse every symbolic link to a
     directory that is encountered.  *Note Traversing symlinks::.

`-P'
     Do not traverse any symbolic links.  This is the default if none
     of `-H', `-L', or `-P' is specified.  *Note Traversing symlinks::.


The actual default behavior of chown appears to be to recursively follow
symbolic links. To wit:

haydn:~ # mkdir sandbox
haydn:~ # cd sandbox/
haydn:~/sandbox # mkdir -p a/aa/aaa
haydn:~/sandbox # touch foo
haydn:~/sandbox # mkdir b
haydn:~/sandbox # cd a/aa/aaa/
haydn:~/sandbox/a/aa/aaa # ln -s ../../../foo foo
haydn:~/sandbox/a/aa/aaa # ln -s ../../../b b
haydn:~/sandbox/a/aa/aaa # cd ../../..
haydn:~/sandbox # ls -l
total 2
drwxr-xr-x   4 root root  120 Mar  9 10:03 .
drwx------  37 root root 2304 Mar  9 10:02 ..
drwxr-xr-x   3 root root   72 Mar  9 10:03 a
drwxr-xr-x   2 root root   48 Mar  9 10:03 b
-rw-r--r--   1 root root    0 Mar  9 10:03 foo
haydn:~/sandbox # chown -R nobody:users a
haydn:~/sandbox # ls -l
total 2
drwxr-xr-x   4 root   root   120 Mar  9 10:03 .
drwx------  37 root   root  2304 Mar  9 10:02 ..
drwxr-xr-x   3 nobody users   72 Mar  9 10:03 a
drwxr-xr-x   2 nobody users   48 Mar  9 10:03 b
-rw-r--r--   1 nobody users    0 Mar  9 10:03 foo

Moreover, there doesn't seem to be any way of invoking chown so that it
operates recursively on a directory tree but ignores (doesn't follow)
symbolic links.





_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to