I just noticed that copying ".." with rsync copies the directory by
name, resulting in the destination files being written out one directory
higher than expected.  For instance,

    rsync -av .. /var/tmp/save-dir/

That would copy everything from the parent dir into /var/tmp, not
/var/tmp/save-dir.  Ouch.

I don't think that anyone depends on this anti-intuitive behavior,
right?  Attached is a patch that makes the above command behave as
if "../" had been specified for the source.

..wayne..
--- flist.c     13 May 2005 22:02:24 -0000      1.293
+++ flist.c     13 May 2005 22:17:04 -0000
@@ -1127,6 +1127,14 @@ struct file_list *send_file_list(int f, 
                                fname[l] = '\0';
                        }
                        is_dot_dir = 1;
+               } else if (l > 1 && fname[l-1] == '.' && fname[l-2] == '.'
+                   && (l == 2 || fname[l-3] == '/')) {
+                       if (l + 2 >= MAXPATHLEN)
+                               overflow("send_file_list");
+                       fname[l++] = '/';
+                       fname[l++] = '.';
+                       fname[l] = '\0';
+                       is_dot_dir = 1;
                } else {
                        is_dot_dir = fname[l-1] == '.'
                                   && (l == 1 || fname[l-2] == '/');
-- 
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html

Reply via email to