Attempt to avoid a problem with --copy-unsafe-links where a symlink was
[rsync/rsync.git] / generator.c
index 11a7cb9..48ef16c 100644 (file)
@@ -417,7 +417,7 @@ int unchanged_attrs(const char *fname, struct file_struct *file, stat_x *sxp)
        if (preserve_acls && !S_ISLNK(file->mode)) {
                if (!ACL_READY(*sxp))
                        get_acl(fname, sxp);
-               if (set_acl(NULL, file, sxp) == 0)
+               if (set_acl(NULL, file, sxp, file->mode))
                        return 0;
        }
 #endif
@@ -476,7 +476,7 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
                if (preserve_acls && !S_ISLNK(file->mode)) {
                        if (!ACL_READY(*sxp))
                                get_acl(fnamecmp, sxp);
-                       if (set_acl(NULL, file, sxp) == 0)
+                       if (set_acl(NULL, file, sxp, file->mode))
                                iflags |= ITEM_REPORT_ACL;
                }
 #endif
@@ -1354,7 +1354,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
        if (preserve_links && S_ISLNK(file->mode)) {
 #ifdef SUPPORT_LINKS
                const char *sl = F_SYMLINK(file);
-               if (safe_symlinks && unsafe_symlink(sl, fname)) {
+               if (safe_symlinks && unsafe_symlink(sl, path_depth(fname))) {
                        if (INFO_GTE(NAME, 1)) {
                                if (solo_file)
                                        fname = f_name(file, NULL);
@@ -1644,7 +1644,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                if (inplace && make_backups > 0 && fnamecmp_type == FNAMECMP_FNAME) {
                        if (!(backupptr = get_backup_name(fname)))
                                goto cleanup;
-                       if (!(back_file = make_file(fname, NULL, NULL, 0, NO_FILTERS)))
+                       if (!(back_file = make_file(fname, NULL, NULL, 0, NO_FILTERS, PHYS_DEPTH_N_A)))
                                goto pretend_missing;
                        if (copy_file(fname, backupptr, -1, back_file->mode) < 0) {
                                unmake_file(back_file);
@@ -1682,7 +1682,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                        close(fd);
                        goto cleanup;
                }
-               if (!(back_file = make_file(fname, NULL, NULL, 0, NO_FILTERS))) {
+               if (!(back_file = make_file(fname, NULL, NULL, 0, NO_FILTERS, PHYS_DEPTH_N_A))) {
                        close(fd);
                        goto pretend_missing;
                }
@@ -1923,7 +1923,7 @@ static void touch_up_dirs(struct file_list *flist, int ndx)
                        STRUCT_STAT st;
                        if (link_stat(fname, &st, 0) == 0
                         && cmp_time(st.st_mtime, file->modtime) != 0)
-                               set_modtime(fname, file->modtime, file->mode);
+                               set_modtime(fname, file->modtime, F_MOD_NSEC(file), file->mode);
                }
                if (counter >= loopchk_limit) {
                        if (allowed_lull)