Oystein Viggen wrote:

>* [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
>
This would just keep going back a step.  "foo" could be changed at any 
point between its discovery and the open syscall.  Obviously the user 
could look at the directory listing then run "rm -r foo", but in the 
time it takes for them to type the command someone else could change the 
directory tree - that is always going to be racey.  But internally to rm 
how can the discovery of a directory (from the directory recurse not the 
command line) be kept atomic with the entering of that directory?

Regards,
Craig.



_______________________________________________
Help-hurd mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/help-hurd

Reply via email to