From fc63847406c5e99669ce11047d6cc01b837b57ae Mon Sep 17 00:00:00 2001 From: David Dykstra Date: Wed, 15 Jan 2003 16:14:07 +0000 Subject: [PATCH] Fix bug in --copy-unsafe that made it totally broken, and re-enable 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 | 14 +++++++------- testsuite/unsafe-byname.test | 9 --------- testsuite/unsafe-links.test | 8 -------- 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/flist.c b/flist.c index 93148e6e..169c33fe 100644 --- 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); } diff --git a/testsuite/unsafe-byname.test b/testsuite/unsafe-byname.test index 47809dcb..ef6bfa7f 100644 --- a/testsuite/unsafe-byname.test +++ b/testsuite/unsafe-byname.test @@ -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 - diff --git a/testsuite/unsafe-links.test b/testsuite/unsafe-links.test index 7b508bcb..a1e197bf 100644 --- a/testsuite/unsafe-links.test +++ b/testsuite/unsafe-links.test @@ -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 -- 2.34.1