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

Re: chmod/chown -R - maybe an ITP



On Tue, 14 Dec 1999, Craig Sanders wrote:
>On Mon, Dec 13, 1999 at 11:37:09PM +0000, Jules Bean wrote:
>> On Tue, 14 Dec 1999, Craig Sanders wrote:
>> > you could write a safe-chown program, but even that would be vulnerable
>> > to races, since there is no atomic test-and-chown operation...it would
>> > just reduce the window of opportunity.
>> 
>> You're wrong, of course, as was pointed out earlier in the thread.
>
>yeah, i noticed that...read the rest of the thread after sending my
>messages.  should have read first, written later.
>
>> Once you open a file, you can check it's the right one with fstat(), and
>> chown it with fchown(), and it can't be replaced in between (since you
>> have an fd open to it, and it will stay open to the original file).
>
>yep.  so a safe-chown program is possible.  
>
>probably the best way to implement would be to add an '-a' or '--atomic'
>(alternatively, '-s' or '--safe') option to the chown in GNU fileutils,
>and contribute it back upstream.

I've already downloaded the source to fileutils for that purpose.

-- 
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: