if (uid_ndx) /* Check uid_ndx instead of preserve_uid for del support */
F_OWNER(file) = st.st_uid;
if (gid_ndx) /* Check gid_ndx instead of preserve_gid for del support */
+@@ -1342,6 +1373,7 @@ static struct file_struct *send_file_name(int f, struct file_list *flist,
+ #endif
+ #ifdef SUPPORT_XATTRS
+ if (preserve_xattrs) {
++ sx.st.st_mode = file->mode;
+ sx.xattr = NULL;
+ if (get_xattr(fname, &sx) < 0)
+ return NULL;
diff --git a/generator.c b/generator.c
--- a/generator.c
+++ b/generator.c
#ifdef SUPPORT_ACLS
if (preserve_acls && !S_ISLNK(file->mode)) {
if (!ACL_READY(*sxp))
-@@ -1426,6 +1449,10 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1429,6 +1452,10 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
file->mode = dest_mode(file->mode, sx.st.st_mode,
dflt_perms, statret == 0);
}
if (statret != 0 && basis_dir[0] != NULL) {
int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &sx,
itemizing, code);
-@@ -1461,10 +1488,15 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1464,10 +1491,15 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
/* We need to ensure that the dirs in the transfer have writable
* permissions during the time we are putting files within them.
* This is then fixed after the transfer is done. */
rsyserr(FERROR_XFER, errno,
"failed to modify permissions on %s",
full_fname(fname));
-@@ -1499,6 +1531,10 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1502,6 +1534,10 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
file->mode = dest_mode(file->mode, sx.st.st_mode, dflt_perms,
exists);
}
#ifdef SUPPORT_HARD_LINKS
if (preserve_hard_links && F_HLINK_NOT_FIRST(file)
-@@ -2024,13 +2060,17 @@ static void touch_up_dirs(struct file_list *flist, int ndx)
+@@ -2028,13 +2064,17 @@ static void touch_up_dirs(struct file_list *flist, int ndx)
continue;
fname = f_name(file, NULL);
if (!(file->mode & S_IWUSR))
if (verbose > 1 && flags & ATTRS_REPORT) {
if (updated)
rprintf(FCLIENT, "%s\n", fname);
-@@ -569,7 +617,8 @@ int finish_transfer(const char *fname, const char *fnametmp,
+@@ -570,7 +618,8 @@ int finish_transfer(const char *fname, const char *fnametmp,
/* Change permissions before putting the file into place. */
set_file_attrs(fnametmp, file, NULL, fnamecmp,
/* move tmp file over real file */
if (verbose > 2)
-@@ -588,6 +637,10 @@ int finish_transfer(const char *fname, const char *fnametmp,
+@@ -589,6 +638,10 @@ int finish_transfer(const char *fname, const char *fnametmp,
}
if (ret == 0) {
/* The file was moved into place (not copied), so it's done. */