bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

chmod fails to ignore symbolic links during recursive directory transver


From: Mark Brand
Subject: chmod fails to ignore symbolic links during recursive directory transversals
Date: Wed, 09 Mar 2005 10:16:45 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041220

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 last paragraph of the DESCRIPTION chmod man page:
However, for each symbolic link listed on the command line, chmod changes the permissions of the pointed-to file. In contrast, chmod ignores symbolic links encountered during recursive directory traversals.
The 2nd sentence states that chmod ignores symbolc links during recursive directory traversals. The info page for chmod agrees:
`-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 behavior of chmod 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 chmod so that it operates recursively on a directory tree but ignores (doesn't follow) symbolic links.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]