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

Re: chmod/chown -R - maybe an ITP



On Mon, Dec 13, 1999 at 03:37:14PM +0100, Russell Coker wrote:
> On Mon, 13 Dec 1999, Daniel Burrows wrote:
> >On Mon, Dec 13, 1999 at 03:19:36PM +0100, Russell Coker was heard to say:
> >> [...] "recurse through this directory and change the ownership or
> >> permissions of files owned by this user". [...]
> >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.  [...]

I'm not sure you'll get one without race conditions at all (in userspace,
anyway), but:

	find /home/foo -uid 105 -exec chown 4242.4242 {} \;

probably has a fairly minimal window, and shouldn't result in *too*
much overhead.

Hmmm.

One way of doing this correctly (as opposed to efficiently, say), might be
to make a hardlink of each file you see, check the hardlink is owned by the
right user, chown/chmod the hardlink, and remove the hardlink.

(Another possibility, if chown supported giving away your own files (ie,
if you could chown any file you owned to any other user), like at least
some of the books I've read say it should, would be su'ing to each uid
first, and running chown. Of course, chown doesn't support this, so...)

Cheers,
aj

-- 
Anthony Towns <aj@humbug.org.au> <http://azure.humbug.org.au/~aj/>
I don't speak for anyone save myself. GPG encrypted mail preferred.

 ``The thing is: trying to be too generic is EVIL. It's stupid, it 
        results in slower code, and it results in more bugs.''
                                        -- Linus Torvalds

Attachment: pgpg8sYdi70nE.pgp
Description: PGP signature


Reply to: