link(2) to rename files in sftp

Carson Gaspar carson at taltos.org
Wed Apr 7 10:30:20 EST 2004



--On Tuesday, April 06, 2004 08:34:40 -0500 Ben Lindstrom 
<mouring at etoh.eviladmin.org> wrote:

>
> In a single word.. "yes".  Your code is no better than stat()+rename().
> Someone can STILL replace the file from under you.  Which is what the race
> condition we are trying to avoid.

It is _marginally_ better, especially if the file is created mode 000. It 
is still possible to lose the race, but it's far less likely than just 
doing a stat().

But I agree that requiring the rename to not clobber is probably impossible 
to do with no race, so the spec should be changed if that's a requirement.

-- 
Carson




More information about the openssh-unix-dev mailing list