[CentOS] strange chgrp behavior

William L. Maltby

CentOS4Bill at triad.rr.com
Sun Sep 2 15:21:12 UTC 2007


On Thu, 2007-08-30 at 19:39 +0200, Tomas Ruprich wrote:
> Thu, Aug 30, 2007 ve 06:05:49PM +0200, Tomas Ruprich napsal:
> > Greetings,
> > i had a following problem, which on one side i have already solved, but
> > on other side i don't thing it should behave this way and wish somebody to 
> > tell if it is feature or bug ;-)
> > 
> > [root at machine home]# chown user user/
> > [root at machine home]# ls -ld /home/user
> > drwxr-xr-x  66 user staff 4096 /home/user
> > [root at machine home]# chgrp -R staff user/
> > [root at machine home]# ls -ld user/
> > drwxr-xr-x  66 root staff 4096 user/
> >               ^^^^^^
> 
> just to be accurate, this doesn't happen when using --no-dereference and it is not 
> changing permissions to root, but to user who is the owner of the link, so:
> 
> [root at machine home]# ls -la user/.openoffice/user/work
> lrwxrwxrwx  1 nobody root 13 Aug 28 14:35 user/.openoffice/user/work -> /home/user
> [root at machine home]# ls -ld /home/user
> drwxr-xr-x  66 user staff 4096 /home/user
> [root at machine home]# chgrp -R staff user/
> [root at machine home]# ls -ld user/
> drwxr-xr-x  66 nobody staff 4096 user/
> <snip sig stuff>

ISTM it's a bug and should be reported on both CentOS and RH tracking
systems. Two errors are apparent. One may be difficult to correct.

As you originally discovered, the user ID is being change during
execution of the command to change a group. And it is using the ID from
the symbolic link owner, as you later noticed.

The 2nd bug is a recursion into the original directory via the symbolic
link when dereference is not suppressed. IMO, recursion should not
occur, but I know from a programming background that it takes a little
foresight, thought and intense effort to avoid this sort of trap.

As an afterthought, how valid is it to have user control files that are
supposed to be contained in an "invisible" directory in the user's
$HOME? This presents a "non-standard" structure that offers increased
opportunities for mishaps of various types.

--
Bill




More information about the CentOS mailing list