race condition bugs

Wayne Davison wayned at samba.org
Mon Aug 9 17:17:23 GMT 2004

On Mon, Aug 09, 2004 at 12:12:16PM +0100, Tony Finch wrote:
> This is because of race conditions in finish_transfer() which mean
> that it does not update files atomically.

There is a diff in the "patches" dir named early-chmod.diff that changes
this behavior.  It sets the permissions prior to the robust_rename()
call, and the copy-when-rename-fails logic is extended to ensure that
these final permissions on the temp file don't interfere with rsync's
reading of the file for the copy.

The only reason this patch hasn't already been applied is that I'm not
100% sure of the reasons that rsync was written to do the chmod() after
the rename().  For instance, do we need to worry about some strange
system that drops the setuid bits on rename()?  Is there a (relevant)
system that prevents the rename() if the file is read-only?  (I seem to
recall that MS DOS has this behavior, but cygwin probably hides it if it

Any comments on how portable it would be to apply the final permissions
before calling rename()?


More information about the rsync mailing list