Commit e107b6b1 authored by Wayne Davison's avatar Wayne Davison

Fixed a problem with --fake-super not getting the fully tweaked new_mode

value.  Also fixed the removal of rsync-internal xattr values on the
destination files when we aren't copying rsync-internal xattr values.
parent 5223b786
...@@ -371,6 +371,9 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp, ...@@ -371,6 +371,9 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
new_mode |= S_ISGID; new_mode |= S_ISGID;
} }
if (daemon_chmod_modes && !S_ISLNK(new_mode))
new_mode = tweak_mode(new_mode, daemon_chmod_modes);
#ifdef SUPPORT_ACLS #ifdef SUPPORT_ACLS
if (preserve_acls && !S_ISLNK(file->mode) && !ACL_READY(*sxp)) if (preserve_acls && !S_ISLNK(file->mode) && !ACL_READY(*sxp))
get_acl(fname, sxp); get_acl(fname, sxp);
...@@ -380,7 +383,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp, ...@@ -380,7 +383,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
if (preserve_xattrs && fnamecmp) if (preserve_xattrs && fnamecmp)
set_xattr(fname, file, fnamecmp, sxp); set_xattr(fname, file, fnamecmp, sxp);
if (am_root < 0) if (am_root < 0)
set_stat_xattr(fname, file); set_stat_xattr(fname, file, new_mode);
#endif #endif
if (!preserve_times || (S_ISDIR(sxp->st.st_mode) && preserve_times == 1)) if (!preserve_times || (S_ISDIR(sxp->st.st_mode) && preserve_times == 1))
...@@ -440,9 +443,6 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp, ...@@ -440,9 +443,6 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
updated = 1; updated = 1;
} }
if (daemon_chmod_modes && !S_ISLNK(new_mode))
new_mode = tweak_mode(new_mode, daemon_chmod_modes);
#ifdef SUPPORT_ACLS #ifdef SUPPORT_ACLS
/* It's OK to call set_acl() now, even for a dir, as the generator /* It's OK to call set_acl() now, even for a dir, as the generator
* will enable owner-writability using chmod, if necessary. * will enable owner-writability using chmod, if necessary.
......
...@@ -230,7 +230,7 @@ static int rsync_xal_get(const char *fname, item_list *xalp) ...@@ -230,7 +230,7 @@ static int rsync_xal_get(const char *fname, item_list *xalp)
#endif #endif
/* No rsync.%FOO attributes are copied w/o 2 -X options. */ /* No rsync.%FOO attributes are copied w/o 2 -X options. */
if (preserve_xattrs < 2 && name_len > RPRE_LEN if (am_sender && preserve_xattrs < 2 && name_len > RPRE_LEN
&& name[RPRE_LEN] == '%' && HAS_PREFIX(name, RSYNC_PREFIX)) && name[RPRE_LEN] == '%' && HAS_PREFIX(name, RSYNC_PREFIX))
continue; continue;
...@@ -523,12 +523,12 @@ void xattr_clear_locals(struct file_struct *file) ...@@ -523,12 +523,12 @@ void xattr_clear_locals(struct file_struct *file)
* any needed xattrs with a flag that lets us know they need to be sent to * any needed xattrs with a flag that lets us know they need to be sent to
* the receiver. When called by the receiver, reads the sent data and * the receiver. When called by the receiver, reads the sent data and
* stores it in place of its checksum. */ * stores it in place of its checksum. */
void recv_xattr_request(struct file_struct *file, int f_in) int recv_xattr_request(struct file_struct *file, int f_in)
{ {
item_list *lst = rsync_xal_l.items; item_list *lst = rsync_xal_l.items;
char *old_datum, *name; char *old_datum, *name;
rsync_xa *rxa; rsync_xa *rxa;
int rel_pos, cnt; int rel_pos, cnt, got_xattr_data = 0;
if (F_XATTR(file) < 0) { if (F_XATTR(file) < 0) {
rprintf(FERROR, "recv_xattr_request: internal data error!\n"); rprintf(FERROR, "recv_xattr_request: internal data error!\n");
...@@ -566,7 +566,10 @@ void recv_xattr_request(struct file_struct *file, int f_in) ...@@ -566,7 +566,10 @@ void recv_xattr_request(struct file_struct *file, int f_in)
rxa->name = name; rxa->name = name;
free(old_datum); free(old_datum);
read_buf(f_in, rxa->datum, rxa->datum_len); read_buf(f_in, rxa->datum, rxa->datum_len);
got_xattr_data = 1;
} }
return got_xattr_data;
} }
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
...@@ -765,6 +768,9 @@ static int rsync_xal_set(const char *fname, item_list *xalp, ...@@ -765,6 +768,9 @@ static int rsync_xal_set(const char *fname, item_list *xalp,
: !HAS_PREFIX(name, USER_PREFIX)) : !HAS_PREFIX(name, USER_PREFIX))
continue; continue;
#endif #endif
if (am_root < 0 && name_len > RPRE_LEN
&& name[RPRE_LEN] == '%' && strcmp(name, XSTAT_ATTR) == 0)
continue;
for (i = 0; i < xalp->count; i++) { for (i = 0; i < xalp->count; i++) {
if (strcmp(name, rxas[i].name) == 0) if (strcmp(name, rxas[i].name) == 0)
...@@ -881,7 +887,7 @@ int get_stat_xattr(const char *fname, int fd, STRUCT_STAT *fst, STRUCT_STAT *xst ...@@ -881,7 +887,7 @@ int get_stat_xattr(const char *fname, int fd, STRUCT_STAT *fst, STRUCT_STAT *xst
return 0; return 0;
} }
int set_stat_xattr(const char *fname, struct file_struct *file) int set_stat_xattr(const char *fname, struct file_struct *file, mode_t new_mode)
{ {
STRUCT_STAT fst, xst; STRUCT_STAT fst, xst;
dev_t rdev; dev_t rdev;
...@@ -903,7 +909,7 @@ int set_stat_xattr(const char *fname, struct file_struct *file) ...@@ -903,7 +909,7 @@ int set_stat_xattr(const char *fname, struct file_struct *file)
} }
fst.st_mode &= (_S_IFMT | CHMOD_BITS); fst.st_mode &= (_S_IFMT | CHMOD_BITS);
fmode = file->mode & (_S_IFMT | CHMOD_BITS); fmode = new_mode & (_S_IFMT | CHMOD_BITS);
if (IS_DEVICE(fmode) || IS_SPECIAL(fmode)) { if (IS_DEVICE(fmode) || IS_SPECIAL(fmode)) {
uint32 *devp = F_RDEV_P(file); uint32 *devp = F_RDEV_P(file);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment