Fix bug in --copy-unsafe that made it totally broken, and re-enable
authorDavid Dykstra <dwd@samba.org>
Wed, 15 Jan 2003 16:14:07 +0000 (16:14 +0000)
committerDavid Dykstra <dwd@samba.org>
Wed, 15 Jan 2003 16:14:07 +0000 (16:14 +0000)
the tests that tested it.  As far as I can tell, it was always broken
since the day I put it in years ago.  In my investigation into this I
was unable to figure out what in the world I was thinking back then,
to introduce a global variable with the wrong information in it rather
than using a parameter that was already available in readlink_stat
function.  That still bothers me a bit but I decided to stop worrying
about it.

flist.c
testsuite/unsafe-byname.test
testsuite/unsafe-links.test

diff --git a/flist.c b/flist.c
index 93148e6..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);
                }
        }
@@ -895,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);
 
@@ -1000,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);
        }
index 47809dc..ef6bfa7 100644 (file)
@@ -44,12 +44,3 @@ test_unsafe ../files/file1          safe     unsafe
 
 test_unsafe ../../unsafe/unsafefile    `pwd`/from/safe safe
 test_unsafe ../files/file1            `pwd`/from/safe  safe
-
-# I think these are correct, but I don't really understand the code.
-# Waiting for an answer from dwd
-test_skipped "correct behaviour is unclear"
-
-# Test suspicious handling of '..' in srcdir
-test_unsafe ../../unsafe/unsafefile    from/safe/../safe       unsafe
-test_unsafe ../files/file1            from/safe/../safe        safe
-
index 7b508bc..a1e197b 100644 (file)
@@ -46,20 +46,13 @@ test_regular to/links/file1
 test_regular to/links/file2
 test_regular to/links/unsafefile
 
-#next rsync copy correctly
 echo "rsync with relative path and --copy-unsafe-links";
 $RSYNC -avv --copy-unsafe-links from/safe/ to
 test_symlink to/links/file1
 test_symlink to/links/file2
 test_regular to/links/unsafefile
 
-# I think these are correct, but I don't really understand the code.
-# Waiting for an answer from dwd
-test_skipped "correct behaviour is unclear"
-
-
 rm -rf to
-#next rsync copy incorrectly - links are copied as files not as links
 echo "rsync with relative2 path";
 (cd from; $RSYNC -avv --copy-unsafe-links safe/ ../to)
 test_symlink to/links/file1
@@ -67,7 +60,6 @@ test_symlink to/links/file2
 test_regular to/links/unsafefile
 
 rm -rf to
-#next rsync copy uncorectly - all links are copied
 echo "rsync with absolute path";
 $RSYNC -avv --copy-unsafe-links `pwd`/from/safe/ to
 test_symlink to/links/file1