* access to ensure that there is no race condition. They will be
* correctly updated after the right owner and group info is set.
* (Thanks to snabb@epipe.fi for pointing this out.) */
- fd = do_mkstemp(fnametmp, file->mode & INITACCESSPERMS);
+ fd = do_mkstemp(fnametmp, (file->mode & INITACCESSPERMS) | S_IWUSR);
#if 0
/* In most cases parent directories will already exist because their
/* move tmp file over real file */
if (DEBUG_GTE(RECV, 1))
rprintf(FINFO, "renaming %s to %s\n", fnametmp, fname);
- ret = robust_rename(fnametmp, fname, temp_copy_name,
- file->mode & INITACCESSPERMS);
+ ret = robust_rename(fnametmp, fname, temp_copy_name, file->mode);
if (ret < 0) {
rsyserr(FERROR_XFER, errno, "%s %s -> \"%s\"",
ret == -2 ? "copy" : "rename",
full_fname(fnametmp), fname);
if (!partialptr || (ret == -2 && temp_copy_name)
- || robust_rename(fnametmp, partialptr, NULL,
- file->mode & INITACCESSPERMS) < 0)
+ || robust_rename(fnametmp, partialptr, NULL, file->mode) < 0)
do_unlink(fnametmp);
return 0;
}
return -1;
}
+#ifdef SUPPORT_XATTRS
+ if (preserve_xattrs)
+ mode |= S_IWUSR;
+#endif
+ mode &= INITACCESSPERMS;
if ((ofd = do_open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, mode)) < 0) {
int save_errno = errno;
rsyserr(FERROR_XFER, save_errno, "open %s", full_fname(dest));