[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: chmod/chown -R - maybe an ITP



On Mon, 13 Dec 1999, Daniel Burrows wrote:
>On Mon, Dec 13, 1999 at 03:19:36PM +0100, Russell Coker was heard to say:
>> Do we have a set of chmod/chown programs that will solve these problems?
>> I would like to have versions of them which take a source UID or GID.  So we
>> can say "recurse through this directory and change the ownership or
>> permissions of files owned by this user".
>> This will make it really easy to renumber UIDs, "nuchown oldUID newUID -R /" !
>
>  Can't you do this with find and xargs?  Or are you looking for something more
>sophisticated?..

find and xargs is better but has race conditions.  For example when I was at
university the systems I was using had some scripts run regularly to chmod
certain files to permissions that the sys-admin liked (.rhosts was changed to
mode 0).
Working out what time these scripts run is not difficult from the mtime. 
Then you could write a program which stat's the home directory as rapidly as
possible, when it sees the atime change it knows that find has run, then it
does:

unlink("/home/user/.rhosts");
link("/etc/passwd", "/home/user/.rhosts");
sleep(60);
unlink("/home/user/.rhosts");
exit(0);

Then the sys-admin comes in to find his voice mail full of messages about not
being able to login, when he gets control of the server again he finds
/etc/passwd with mode 0 and no evidence of what happened.
Of course for any serious system /etc won't be on the same file system as
/home, but there's always the quota files and similar scripts.

On the same university network there was a script which would gzip all files
in a user's home directory that were more than 1 week old and delete files
that were more than a year old.  If I made a directory named /home/user/foo
containing a 2 week old file named vmunix I could then delete the directory
foo and make it a sym-link to the root directory.  Then /vmunix gets
compressed and the machine won't boot.

I'm sure that there are people who can thing of better ways of exploiting
this than I can.  ;)

-- 
The ultimate result is that some innovations that would truly benefit
consumers never occur for the sole reason that they do not coincide with
Microsoft's self-interest.
-- Judge Thomas Penfield Jackson, U.S. District Judge


Reply to: