4.3bsd chgrp

Ron Stanonik stanonik at nprdc.arpa
Sat Aug 20 01:09:10 AEST 1988


While trying to chgrp -R a user's files, I got the error
"You are not the owner" and the chgrp -R didn't complete.
True, I was not the owner . . . I was root!

chgrp had balked when it encountered files not owned by
the user (the files belonged to someone the user was working
with and the directory was g+w to facilitate this sharing).

Digging into chgrp, I found that it checked ownership of
the file against the variable uid, which was initially the
user's uid, but in the recursive call to chownr became the
uid of the current directory; ie, chgrp ends up checking
ownership of the file against ownership of the current
directory.  Ironically chgrp also first checks if uid is
zero, seemingly to exempt root from this checking.

Any ideas as to the reason for checking file ownership against
directory ownership?  Any good reasons for not changing the
calls to chownr to pass the user's uid, rather than the uid
of the current directory?

Thanks,

Ron Stanonik
stanonik at nprdc.arpa



More information about the Comp.unix.wizards mailing list