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

Re: Help! File permissions keep changing...



On Thu, 19 Feb 2004 00:23, Javier Fernández-Sanguino Peña <jfs@computer.org> 
wrote:
> On Wed, Feb 18, 2004 at 11:50:27PM +1100, Russell Coker wrote:
> > If you are going to change such things then you need to use the -uid or
> > -gid options to find (depending on whether you are changing the UID or
> > GID), and you need to do it when the machine is in single-user mode (IE
> > no-one can login and cron jobs can't run).
>
> Hmmm.. I did say there was plenty of room for improvement, after all,
> obviously shell scripting is more prone to failure than a proper program
> in C but let's give it a shot:

Your script still had a race condition.  If you use file input redirection and 
have the ls/chown/chmod commands operate on /proc/self/fd/something then you 
might be able to do it.

> > It would be nice if someone was to patch the -R option of
> > chown/chgrp/chmod in coreutils to do this sort of thing.
>
> As an enhancement over the -h option? (to exclude hard links as
> well as symlinks)

With hard links in many cases it's impossible to tell which was the original, 
so "excluding" hard links is not possible.  We just need options to only 
chown/chmod/chgrp files if the original uid/gid/mode matches certain 
criteria.

Also the chown/chmod/chgrp command needs to be performed on the file handle 
(which those commands don't currently do).

-- 
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page



Reply to: