Allow the file-list sending code to set XMIT_SAME_UID/XMIT_SAME_GID
authorWayne Davison <wayned@samba.org>
Fri, 28 Mar 2008 17:30:19 +0000 (10:30 -0700)
committerWayne Davison <wayned@samba.org>
Fri, 28 Mar 2008 17:40:10 +0000 (10:40 -0700)
when owner/group info isn't being preserved.  This helps to ensure
that the lower 8 bits of the xflags aren't 0, and is what older
rsync versions did.

flist.c

diff --git a/flist.c b/flist.c
index 673148e..eca0dc7 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -429,28 +429,24 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
                }
        } else if (protocol_version < 28)
                rdev = MAKEDEV(0, 0);
                }
        } else if (protocol_version < 28)
                rdev = MAKEDEV(0, 0);
-       if (preserve_uid) {
-               if ((uid_t)F_OWNER(file) == uid && *lastname)
-                       xflags |= XMIT_SAME_UID;
-               else {
-                       uid = F_OWNER(file);
-                       if (!numeric_ids) {
-                               user_name = add_uid(uid);
-                               if (inc_recurse && user_name)
-                                       xflags |= XMIT_USER_NAME_FOLLOWS;
-                       }
+       if (!preserve_uid || ((uid_t)F_OWNER(file) == uid && *lastname))
+               xflags |= XMIT_SAME_UID;
+       else {
+               uid = F_OWNER(file);
+               if (!numeric_ids) {
+                       user_name = add_uid(uid);
+                       if (inc_recurse && user_name)
+                               xflags |= XMIT_USER_NAME_FOLLOWS;
                }
        }
                }
        }
-       if (preserve_gid) {
-               if ((gid_t)F_GROUP(file) == gid && *lastname)
-                       xflags |= XMIT_SAME_GID;
-               else {
-                       gid = F_GROUP(file);
-                       if (!numeric_ids) {
-                               group_name = add_gid(gid);
-                               if (inc_recurse && group_name)
-                                       xflags |= XMIT_GROUP_NAME_FOLLOWS;
-                       }
+       if (!preserve_gid || ((gid_t)F_GROUP(file) == gid && *lastname))
+               xflags |= XMIT_SAME_GID;
+       else {
+               gid = F_GROUP(file);
+               if (!numeric_ids) {
+                       group_name = add_gid(gid);
+                       if (inc_recurse && group_name)
+                               xflags |= XMIT_GROUP_NAME_FOLLOWS;
                }
        }
        if (file->modtime == modtime)
                }
        }
        if (file->modtime == modtime)
@@ -467,15 +463,14 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
                                np->data = (void*)(long)(first_ndx + ndx + 1);
                                xflags |= XMIT_HLINK_FIRST;
                        }
                                np->data = (void*)(long)(first_ndx + ndx + 1);
                                xflags |= XMIT_HLINK_FIRST;
                        }
-                       xflags |= XMIT_HLINKED;
                } else {
                        if (tmp_dev == dev) {
                                if (protocol_version >= 28)
                                        xflags |= XMIT_SAME_DEV_pre30;
                        } else
                                dev = tmp_dev;
                } else {
                        if (tmp_dev == dev) {
                                if (protocol_version >= 28)
                                        xflags |= XMIT_SAME_DEV_pre30;
                        } else
                                dev = tmp_dev;
-                       xflags |= XMIT_HLINKED;
                }
                }
+               xflags |= XMIT_HLINKED;
        }
 #endif
 
        }
 #endif