[comp.unix.wizards] 4.3bsd chgrp

stanonik@nprdc.arpa (Ron Stanonik) (08/19/88)

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@nprdc.arpa

smb@ulysses.homer.nj.att.com (Steven Bellovin) (08/20/88)

Sounds to me like the thing to do is to scrap -R and use (and if necessary
implement) xargs.