[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: recursive commands
From: |
Oystein Viggen |
Subject: |
Re: recursive commands |
Date: |
Tue, 02 Apr 2002 14:55:13 +0200 |
User-agent: |
Gnus/5.090005 (Oort Gnus v0.05) XEmacs/21.1 (Capitol Reef, i386-debian-linux) |
* [Craig Allan Jeffree]
>> old = open(".");
>> chdir("foo);
>> delete stuff
>> fchdir(old);
>> delete more stuff
>>
> Isn't this potentially racey as well? I can see that fchdir(old); will
> definately take you back to the parent of "foo" but how can you be sure
> that the directories aren't moved around between step 1 and 2? You
> could end up in a different "foo" to what you intended, I guess this is
> a different issue - but it is still an issue isn't it?
I think the way rm already does that part is:
d=open("foo", 'r', O_DIRECTORY|O_NOFOLLOW);
fchdir(d);
If you don't do that, even in regular unix, a user can rename the dir
and exchange it with a symlink to / or whatever beneath your feet
between steps 1 and 2.
I've had other things to do in the easter, but I'll see if I can come up
with some translator stuff on top of this soon :)
Oystein
--
When in doubt: Recompile.