[BusyBox] Must chmod & chown follow symlinks or not ?

Luc Van Oostenryck lkml at looxix.net
Mon Jun 20 23:00:23 UTC 2005


Hi,

Trying to change the owner of a symlink can also change (increase) the permissions
of the target of the symlink. For example:

# ls -l
total 4
-rw-r--r--    1 luc      users           2 Jun 21 00:50 f
lrwxrwxrwx    1 luc      users           1 Jun 21 00:50 l -> f

# chown root.root *
# ls -l
total 4
-rwxrwxrwx    1 root     root            2 Jun 21 00:50 f
   ^^^^^^^^
lrwxrwxrwx    1 root     root            1 Jun 21 00:50 l -> f


The problem come from the fact that recursive_action() use lstat() but
the chown applet use in its action chown() and not lchown().

I think that either lstat()/lchown() or stat()/chown() must be used but not a mix of the two.

With the following patch chown have the same behaviour as the GNU one and do the same for chmod
that suffer from the same problem.
I have not really checked but from the code it seems that chgrp must not be corrected since it use
already lchown().


Luc Van Oostenryck




More information about the busybox mailing list