Repost: chown: no recursive dereferencing through symlinks?

Christopher Wood <[email protected]>
Newsgroups gmane.comp.gnu.fileutils.bugs
Message-ID <[email protected]>
[Reposting this because I originally posted it during the fileutils --> coreutils transition.]

I've looked through the list archives, and I apologize if I missed a post discussing this. I'm not sure whether this behaviour is a feature or a bug. I'm not a programmer, so unfortunately can't check the source in a meaningful way. Would anyone here know if this behaviour is normal/intended?

Here's what happens on two systems, with slightly different fileutils versions. Note how -R behaves differently depending on if I apply the chown to a directory or to a symlink to a directory.


cwood@titanium:/tmp$ uname -a
Linux titanium 2.2.14-5.0smp #1 SMP Tue Mar 7 21:01:40 EST 2000 i686 unknown
cwood@titanium:/tmp$ chown --version
chown (GNU fileutils) 4.0p
Written by David MacKenzie.z

Copyright (C) 1999 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
cwood@titanium:/tmp$ mkdir zdir
cwood@titanium:/tmp$ touch zdir/file
cwood@titanium:/tmp$ ln -s zdir zln
cwood@titanium:/tmp$ ls -l
total 2
drwxrwxr-x    2 cwood    develop      4096 Aug  9 15:17 zdir/
lrwxrwxrwx    1 cwood    develop         4 Aug  9 15:18 zln -> zdir/
cwood@titanium:/tmp$ su
Password: 
[root@titanium /tmp]# chown -R -v root zdir
owner of zdir changed to root
owner of zdir/file changed to root
[root@titanium /tmp]# chown -R -v cwood zdir
owner of zdir changed to cwood
owner of zdir/file changed to cwood
[root@titanium /tmp]# chown -R -v root zln 
owner of zln changed to root
[root@titanium /tmp]# chown -R -v cwood zln
owner of zln changed to cwood
[root@titanium /tmp]# chown -R -v --dereference root zln
owner of zln changed to root
[root@titanium /tmp]# ls -l
total 2
drwxrwxr-x    2 root     develop      4096 Aug  9 15:17 zdir
lrwxrwxrwx    1 cwood    develop         4 Aug  9 15:18 zln -> zdir
[root@titanium /tmp]# ls -l zdir
total 0
-rw-rw-r--    1 cwood    develop         0 Aug  9 15:17 file
[root@titanium /tmp]# 


cwood@playdium:/tmp$ uname -a
Linux playdium 2.4.18 #4 SMP Wed Apr 24 18:38:23 EDT 2002 i686 unknown unknown GNU/Linux
cwood@playdium:/tmp$ chown --version
chown (fileutils) 4.1.10
Written by David MacKenzie.

Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
cwood@playdium:/tmp$ mkdir zdir
cwood@playdium:/tmp$ touch zdir/file
cwood@playdium:/tmp$ ln -s zdir zln
cwood@playdium:/tmp$ ls -l
total 2
drwxrwxr-x    2 cwood    develop      4096 Aug  9 15:24 zdir/
lrwxrwxrwx    1 cwood    develop         4 Aug  9 15:24 zln -> zdir/
cwood@playdium:/tmp$ su
Password: 
playdium:/tmp# chown -R -v root zdir
changed ownership of `zdir' to root
changed ownership of `zdir/file' to root
playdium:/tmp# chown -R -v cwood zdir
changed ownership of `zdir' to cwood
changed ownership of `zdir/file' to cwood
playdium:/tmp# chown -R -v root zln
changed ownership of `zln' to root
playdium:/tmp# ls -l
total 2
drwxrwxr-x    2 cwood    develop      4096 Aug  9 15:24 zdir
lrwxrwxrwx    1 root     develop         4 Aug  9 15:24 zln -> zdir
playdium:/tmp# chown -R -v cwood zln
changed ownership of `zln' to cwood
playdium:/tmp# chown -R -v --dereference root zln
changed ownership of `zln' to root
playdium:/tmp# ls -l
total 2
drwxrwxr-x    2 root     develop      4096 Aug  9 15:24 zdir
lrwxrwxrwx    1 cwood    develop         4 Aug  9 15:24 zln -> zdir
playdium:/tmp# ls -l zdir
total 0
-rw-rw-r--    1 cwood    develop         0 Aug  9 15:24 file
playdium:/tmp#
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.