fchmod in do_mkstemp? (patch included)

Wayne Davison wayned at samba.org
Wed Apr 21 22:07:33 GMT 2004

On Sat, Apr 10, 2004 at 08:04:00PM -0400, Assar wrote:
> Why is do_mkstemp fchmod-ing the temporary file?

Seeing as the writer of that code isn't here, it's hard to know for
sure.  One thing that occurs to me is that it sets the execute bit for
the owner if the file is executable.  Since rsync currently moves the
temporary file into place before setting the final permissions, this
can make updating program files slightly less problematical in certain
rare cases (but only for the owner).  Other than that, I don't think
it really matters much.  Maybe it's a left-over from back when
mkstemp() wasn't so good about creating files with a safe mode?

In the future I'd like to see the code changed to chmod the file to
its final value before it is moved into place (like the code in the
early-chmod.diff patch does), but I deemed this change too risky for
the end of the current release cycle (mainly because I wanted more
time to think about any hidden "gotchas" lurking in this alternate


More information about the rsync mailing list