X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/16edf86595a5a990a942fa045dfb523dae1fe6cb..9439c0cb5a4b020b9bfcfe0351e33c17b9c53b54:/rsync.c diff --git a/rsync.c b/rsync.c index 7e97a930..1eda740a 100644 --- a/rsync.c +++ b/rsync.c @@ -98,7 +98,7 @@ int read_ndx_and_attrs(int f_in, int *iflag_ptr, uchar *type_ptr, int len, iflags = 0; struct file_list *flist; uchar fnamecmp_type = FNAMECMP_FNAME; - int verbose_save, ndx; + int ndx; read_loop: while (1) { @@ -124,8 +124,6 @@ int read_ndx_and_attrs(int f_in, int *iflag_ptr, uchar *type_ptr, NDX_FLIST_OFFSET - dir_flist->count); exit_cleanup(RERR_PROTOCOL); } - verbose_save = verbose; - verbose = 0; /* TODO allow verbose messages? */ /* Send everything read from f_in to msg_fd_out. */ send_msg_int(MSG_FLIST, ndx); @@ -133,8 +131,6 @@ int read_ndx_and_attrs(int f_in, int *iflag_ptr, uchar *type_ptr, flist = recv_file_list(f_in); flist->parent_ndx = ndx; stop_flist_forward(); - - verbose = verbose_save; } iflags = protocol_version >= 29 ? read_shortint(f_in) @@ -261,6 +257,8 @@ int set_file_attrs(const char *fname, struct file_struct *file, statx *sxp, #ifdef SUPPORT_XATTRS if (preserve_xattrs && fnamecmp) set_xattr(fname, file, fnamecmp, sxp); + if (am_root < 0) + set_stat_xattr(fname, file); #endif if (!preserve_times || (S_ISDIR(sxp->st.st_mode) && omit_dir_times)) @@ -300,7 +298,9 @@ int set_file_attrs(const char *fname, struct file_struct *file, statx *sxp, (long)sxp->st.st_gid, (long)F_GID(file)); } } - if (do_lchown(fname, + if (am_root < 0) { + ; + } else if (do_lchown(fname, change_uid ? F_UID(file) : sxp->st.st_uid, change_gid ? F_GID(file) : sxp->st.st_gid) != 0) { /* shouldn't have attempted to change uid or gid @@ -309,7 +309,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, statx *sxp, change_uid ? "chown" : "chgrp", full_fname(fname)); goto cleanup; - } + } else /* a lchown had been done - we have to re-stat if the * destination had the setuid or setgid bits set due * to the side effect of the chown call */ @@ -336,7 +336,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, statx *sxp, #ifdef HAVE_CHMOD if (!BITS_EQUAL(sxp->st.st_mode, new_mode, CHMOD_BITS)) { - int ret = do_chmod(fname, new_mode); + int ret = am_root < 0 ? 0 : do_chmod(fname, new_mode); if (ret < 0) { rsyserr(FERROR, errno, "failed to set permissions on %s",