We omit copying any user-space rsync.%FOO attributes unless the
authorWayne Davison <wayned@samba.org>
Mon, 2 Jul 2007 21:35:14 +0000 (21:35 +0000)
committerWayne Davison <wayned@samba.org>
Mon, 2 Jul 2007 21:35:14 +0000 (21:35 +0000)
user specified -X twice.

options.c
xattrs.c

index b49c115..1da74e5 100644 (file)
--- a/options.c
+++ b/options.c
@@ -1186,7 +1186,7 @@ int parse_arguments(int *argc, const char ***argv, int frommain)
 
                case 'X':
 #ifdef SUPPORT_XATTRS
-                       preserve_xattrs = 1;
+                       preserve_xattrs++;
                        preserve_perms = 1;
                        break;
 #else
@@ -1677,8 +1677,11 @@ void server_options(char **args,int *argc)
                argstr[x++] = 'A';
 #endif
 #ifdef SUPPORT_XATTRS
-       if (preserve_xattrs)
+       if (preserve_xattrs) {
                argstr[x++] = 'X';
+               if (preserve_xattrs > 1)
+                       argstr[x++] = 'X';
+       }
 #endif
        if (recurse)
                argstr[x++] = 'r';
index 7591660..48a630f 100644 (file)
--- a/xattrs.c
+++ b/xattrs.c
@@ -30,6 +30,7 @@ extern int am_sender;
 extern int am_generator;
 extern int read_only;
 extern int list_only;
+extern int preserve_xattrs;
 extern int checksum_seed;
 
 #define RSYNC_XAL_INITIAL 5
@@ -62,7 +63,6 @@ extern int checksum_seed;
 #define RPRE_LEN ((int)sizeof RSYNC_PREFIX - 1)
 
 #define XSTAT_ATTR RSYNC_PREFIX "%stat"
-#define XSTAT_LEN ((int)sizeof XSTAT_ATTR - 1)
 
 typedef struct {
        char *datum, *name;
@@ -223,8 +223,9 @@ static int rsync_xal_get(const char *fname, item_list *xalp)
                        continue;
 #endif
 
-               if (am_root < 0 && name_len == XSTAT_LEN + 1
-                && name[RPRE_LEN] == '%' && strcmp(name, XSTAT_ATTR) == 0)
+               /* No rsync.%FOO attributes are copied w/o 2 -X options. */
+               if (preserve_xattrs < 2 && name_len > RPRE_LEN
+                && name[RPRE_LEN] == '%' && HAS_PREFIX(name, RSYNC_PREFIX))
                        continue;
 
                datum_len = name_len; /* Pass extra size to get_xattr_data() */
@@ -636,8 +637,9 @@ void receive_xattr(struct file_struct *file, int f)
                        continue;
                }
 #endif
-               if (am_root < 0 && name_len == XSTAT_LEN + 1
-                && name[RPRE_LEN] == '%' && strcmp(name, XSTAT_ATTR) == 0) {
+               /* No rsync.%FOO attributes are copied w/o 2 -X options. */
+               if (preserve_xattrs < 2 && name_len > RPRE_LEN
+                && name[RPRE_LEN] == '%' && HAS_PREFIX(name, RSYNC_PREFIX)) {
                        free(ptr);
                        continue;
                }