[net.bugs.4bsd] 4.2 bsd bugs in ch/own/grp.

leslie@dice.UUCP (Leslie Freeland) (04/03/84)

.for the monster of the net.

Their is a bug,feature,in the way that chown and chgrp work,interact.
This only happens when you try to change the owner or group of a
symbolic link then it fouls up.
	What actually happens is that both chown and chgrp do a stat
on the symbolic link which returns the status of the   file  at  the
other side of the link.Therefore when we do a :-

	chown root test

where test is owned by bin and has group bin,and is a symbolic link
to say /tmp/test which is owned by bin and has group root.
the file test will then be owned by root and also have root as it's
group since it takes the group for the file from the  other  side of
the link.
	The same happens when you use chgrp,except that the owner
is taken from the other side of the link i.e. if we try to:-

	chgrp bin test

it will end up being owned by bin and being in group bin which is
not what we want.

	We have now entered a catch-22 situation,try it and see.

The fix is obvious just change the call's to stat in both chown.c
and chgrp.c to call's to lstat  and  the buggy , feature ,will go
away.

beam me up Scotty.