Fix bug in --copy-unsafe that made it totally broken, and re-enable
[rsync/rsync.git] / flist.c
diff --git a/flist.c b/flist.c
index 1dee24c..169c33f 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -61,8 +61,6 @@ extern int sanitize_paths;
 extern int read_batch;
 extern int write_batch;
 
-static char topsrcname[MAXPATHLEN];
-
 static struct exclude_struct **local_exclude_list;
 
 static struct file_struct null_file;
@@ -221,8 +219,11 @@ int readlink_stat(const char *path, STRUCT_STAT * buffer, char *linkbuf)
                if (l == -1) 
                        return -1;
                linkbuf[l] = 0;
-               if (copy_unsafe_links && (topsrcname[0] != '\0') &&
-                   unsafe_symlink(linkbuf, topsrcname)) {
+               if (copy_unsafe_links && unsafe_symlink(linkbuf, path)) {
+                       if (verbose > 1) {
+                               rprintf(FINFO,"copying unsafe symlink \"%s\" -> \"%s\"\n", 
+                                       path, linkbuf);
+                       }
                        return do_stat(path, buffer);
                }
        }
@@ -660,8 +661,10 @@ struct file_struct *make_file(int f, char *fname, struct string_area **ap,
 
        if (readlink_stat(fname, &st, linkbuf) != 0) {
                int save_errno = errno;
-               if ((errno == ENOENT) && copy_links && !noexcludes) {
-                       /* symlink pointing nowhere, see if excluded */
+               if ((errno == ENOENT) && !noexcludes) {
+                       /* either symlink pointing nowhere or file that 
+                        * was removed during rsync run; see if excluded
+                        * before reporting an error */
                        memset((char *) &st, 0, sizeof(st));
                        if (check_exclude_file(f, fname, &st)) {
                                /* file is excluded anyway, ignore silently */
@@ -893,7 +896,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
        }
 
        for (i = 0; i < argc; i++) {
-               char *fname = topsrcname;
+               char fname2[MAXPATHLEN];
+               char *fname = fname2;
 
                strlcpy(fname, argv[i], MAXPATHLEN);
 
@@ -998,8 +1002,6 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
                }
        }
 
-       topsrcname[0] = '\0';
-
        if (f != -1) {
                send_file_entry(NULL, f, 0);
        }
@@ -1195,7 +1197,7 @@ void free_file(struct file_struct *file)
 /*
  * allocate a new file list
  */
-struct file_list *flist_new()
+struct file_list *flist_new(void)
 {
        struct file_list *flist;