X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/83235dbc546d74ee325bb09b602bd62313fea793..698bc16e87b0ac6b29668fe0df4f3fd6d41e4b67:/rsync.c diff --git a/rsync.c b/rsync.c index 7505c634..6a5f5df3 100644 --- a/rsync.c +++ b/rsync.c @@ -41,6 +41,7 @@ extern int am_generator; extern int am_starting_up; extern int allow_8bit_chars; extern int protocol_version; +extern int receiver_symlink_times; extern int uid_ndx; extern int gid_ndx; extern int inc_recurse; @@ -399,6 +400,8 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp, } if (ret == 0) /* ret == 1 if symlink could not be set */ updated = 1; + else if (receiver_symlink_times) + file->flags |= FLAG_TIME_FAILED; } change_uid = am_root && uid_ndx && sxp->st.st_uid != (uid_t)F_OWNER(file); @@ -422,24 +425,24 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp, fname, (unsigned)sxp->st.st_gid, F_GROUP(file)); } } - if (am_root < 0) { - ; - } else if (do_lchown(fname, - change_uid ? (uid_t)F_OWNER(file) : sxp->st.st_uid, - change_gid ? (gid_t)F_GROUP(file) : sxp->st.st_gid) != 0) { - /* shouldn't have attempted to change uid or gid - * unless have the privilege */ - rsyserr(FERROR_XFER, errno, "%s %s failed", - 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 */ - if (sxp->st.st_mode & (S_ISUID | S_ISGID)) { - link_stat(fname, &sxp->st, - keep_dirlinks && S_ISDIR(sxp->st.st_mode)); + if (am_root >= 0) { + if (do_lchown(fname, + change_uid ? (uid_t)F_OWNER(file) : sxp->st.st_uid, + change_gid ? (gid_t)F_GROUP(file) : sxp->st.st_gid) != 0) { + /* We shouldn't have attempted to change uid + * or gid unless have the privilege. */ + rsyserr(FERROR_XFER, errno, "%s %s failed", + change_uid ? "chown" : "chgrp", + full_fname(fname)); + goto cleanup; + } + /* A lchown had been done, so we need to re-stat if + * the destination had the setuid or setgid bits set + * (due to the side effect of the chown call). */ + if (sxp->st.st_mode & (S_ISUID | S_ISGID)) { + link_stat(fname, &sxp->st, + keep_dirlinks && S_ISDIR(sxp->st.st_mode)); + } } updated = 1; }