The patches for 3.0.1pre1.
[rsync/rsync-patches.git] / usermap.diff
index 439a6e1..f5d2b1c 100644 (file)
@@ -10,7 +10,7 @@ To use this patch, run these commands for a successful build:
 diff --git a/flist.c b/flist.c
 --- a/flist.c
 +++ b/flist.c
-@@ -68,6 +68,7 @@ extern int need_unsorted_flist;
+@@ -70,6 +70,7 @@ extern int need_unsorted_flist;
  extern int unsort_ndx;
  extern struct stats stats;
  extern char *filesfrom_host;
@@ -18,7 +18,7 @@ diff --git a/flist.c b/flist.c
  
  extern char curr_dir[MAXPATHLEN];
  
-@@ -752,7 +753,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+@@ -789,7 +790,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
                        uid = (uid_t)read_varint(f);
                        if (xflags & XMIT_USER_NAME_FOLLOWS)
                                uid = recv_user_name(f, uid);
@@ -27,7 +27,7 @@ diff --git a/flist.c b/flist.c
                                uid = match_uid(uid);
                }
        }
-@@ -764,7 +765,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+@@ -801,7 +802,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
                        gid_flags = 0;
                        if (xflags & XMIT_GROUP_NAME_FOLLOWS)
                                gid = recv_group_name(f, gid, &gid_flags);
@@ -36,7 +36,7 @@ diff --git a/flist.c b/flist.c
                                gid = match_gid(gid, &gid_flags);
                }
        }
-@@ -2074,8 +2075,13 @@ struct file_list *recv_file_list(int f)
+@@ -2142,8 +2143,13 @@ struct file_list *recv_file_list(int f)
        int dstart, flags;
        int64 start_read;
  
@@ -54,7 +54,7 @@ diff --git a/flist.c b/flist.c
 diff --git a/options.c b/options.c
 --- a/options.c
 +++ b/options.c
-@@ -166,6 +166,8 @@ char *rsync_path = RSYNC_PATH;
+@@ -167,6 +167,8 @@ char *rsync_path = RSYNC_PATH;
  char *backup_dir = NULL;
  char backup_dir_buf[MAXPATHLEN];
  char *sockopts = NULL;
@@ -63,7 +63,7 @@ diff --git a/options.c b/options.c
  int rsync_port = 0;
  int compare_dest = 0;
  int copy_dest = 0;
-@@ -379,6 +381,8 @@ void usage(enum logcode F)
+@@ -384,6 +386,8 @@ void usage(enum logcode F)
    rprintf(F,"     --delay-updates         put all updated files into place at transfer's end\n");
    rprintf(F," -m, --prune-empty-dirs      prune empty directory chains from the file-list\n");
    rprintf(F,"     --numeric-ids           don't map uid/gid values by user/group name\n");
@@ -72,7 +72,7 @@ diff --git a/options.c b/options.c
    rprintf(F,"     --timeout=SECONDS       set I/O timeout in seconds\n");
    rprintf(F,"     --contimeout=SECONDS    set daemon connection timeout in seconds\n");
    rprintf(F," -I, --ignore-times          don't skip files that match in size and mod-time\n");
-@@ -604,6 +608,8 @@ static struct poptOption long_options[] = {
+@@ -622,6 +626,8 @@ static struct poptOption long_options[] = {
    {"no-s",             0,  POPT_ARG_VAL,    &protect_args, 0, 0, 0},
    {"numeric-ids",      0,  POPT_ARG_VAL,    &numeric_ids, 1, 0, 0 },
    {"no-numeric-ids",   0,  POPT_ARG_VAL,    &numeric_ids, 0, 0, 0 },
@@ -81,7 +81,7 @@ diff --git a/options.c b/options.c
    {"timeout",          0,  POPT_ARG_INT,    &io_timeout, 0, 0, 0 },
    {"no-timeout",       0,  POPT_ARG_VAL,    &io_timeout, 0, 0, 0 },
    {"contimeout",       0,  POPT_ARG_INT,    &connect_timeout, 0, 0, 0 },
-@@ -1942,6 +1948,18 @@ void server_options(char **args, int *argc_p)
+@@ -1991,6 +1997,18 @@ void server_options(char **args, int *argc_p)
                args[ac++] = "--use-qsort";
  
        if (am_sender) {
@@ -112,7 +112,7 @@ diff --git a/rsync.yo b/rsync.yo
       --timeout=SECONDS       set I/O timeout in seconds
       --contimeout=SECONDS    set daemon connection timeout in seconds
   -I, --ignore-times          don't skip files that match size and time
-@@ -1579,6 +1581,46 @@ from the source system is used instead.  See also the comments on the
+@@ -1602,6 +1604,46 @@ from the source system is used instead.  See also the comments on the
  the chroot setting affects rsync's ability to look up the names of the
  users and groups and what you can do about it.
  
@@ -188,7 +188,7 @@ diff --git a/uidlist.c b/uidlist.c
 +
  struct idlist {
        struct idlist *next;
-       char *name;
+       const char *name;
 @@ -48,8 +54,8 @@ struct idlist {
        uint16 flags;
  };
@@ -198,13 +198,13 @@ diff --git a/uidlist.c b/uidlist.c
 +static struct idlist *uidlist, *uidmap;
 +static struct idlist *gidlist, *gidmap;
  
- static struct idlist *add_to_list(struct idlist **root, id_t id, char *name,
+ static struct idlist *add_to_list(struct idlist **root, id_t id, const char *name,
                                  id_t id2, uint16 flags)
-@@ -84,22 +90,6 @@ static char *gid_to_name(gid_t gid)
+@@ -84,22 +90,6 @@ static const char *gid_to_name(gid_t gid)
        return NULL;
  }
  
--static uid_t map_uid(uid_t id, char *name)
+-static uid_t map_uid(uid_t id, const char *name)
 -{
 -      uid_t uid;
 -      if (id != 0 && name_to_uid(name, &uid))
@@ -212,7 +212,7 @@ diff --git a/uidlist.c b/uidlist.c
 -      return id;
 -}
 -
--static gid_t map_gid(gid_t id, char *name)
+-static gid_t map_gid(gid_t id, const char *name)
 -{
 -      gid_t gid;
 -      if (id != 0 && name_to_gid(name, &gid))
@@ -228,9 +228,9 @@ diff --git a/uidlist.c b/uidlist.c
  }
  
 -/* Add a uid to the list of uids.  Only called on receiving side. */
--static struct idlist *recv_add_uid(uid_t id, char *name)
+-static struct idlist *recv_add_uid(uid_t id, const char *name)
 +/* Add a uid/gid to its list of ids.  Only called on receiving side. */
-+static struct idlist *recv_add_id(struct idlist **idmap_ptr, id_t id, char *name)
++static struct idlist *recv_add_id(struct idlist **idmap_ptr, id_t id, const char *name)
  {
 -      uid_t id2 = name ? map_uid(id, name) : id;
        struct idlist *node;
@@ -273,7 +273,7 @@ diff --git a/uidlist.c b/uidlist.c
 -}
 -
 -/* Add a gid to the list of gids.  Only called on receiving side. */
--static struct idlist *recv_add_gid(gid_t id, char *name)
+-static struct idlist *recv_add_gid(gid_t id, const char *name)
 -{
 -      gid_t id2 = name ? map_gid(id, name) : id;
 -      struct idlist *node;
@@ -293,7 +293,7 @@ diff --git a/uidlist.c b/uidlist.c
        }
  
        return node;
-@@ -195,12 +200,9 @@ static struct idlist *recv_add_gid(gid_t id, char *name)
+@@ -195,12 +200,9 @@ static struct idlist *recv_add_gid(gid_t id, const char *name)
  /* this function is a definate candidate for a faster algorithm */
  uid_t match_uid(uid_t uid)
  {
@@ -332,25 +332,25 @@ diff --git a/uidlist.c b/uidlist.c
                last = list;
        }
  
-@@ -316,7 +321,7 @@ uid_t recv_user_name(int f, uid_t uid)
-       if (!name)
-               out_of_memory("recv_user_name");
-       read_sbuf(f, name, len);
+@@ -320,7 +325,7 @@ uid_t recv_user_name(int f, uid_t uid)
+               free(name);
+               name = NULL;
+       }
 -      node = recv_add_uid(uid, name); /* node keeps name's memory */
 +      node = recv_add_id(&uidmap, uid, name); /* node keeps name's memory */
        return node->id2;
  }
  
-@@ -328,7 +333,7 @@ gid_t recv_group_name(int f, gid_t gid, uint16 *flags_ptr)
-       if (!name)
-               out_of_memory("recv_group_name");
-       read_sbuf(f, name, len);
+@@ -336,7 +341,7 @@ gid_t recv_group_name(int f, gid_t gid, uint16 *flags_ptr)
+               free(name);
+               name = NULL;
+       }
 -      node = recv_add_gid(gid, name); /* node keeps name's memory */
 +      node = recv_add_id(&gidmap, gid, name); /* node keeps name's memory */
        if (flags_ptr && node->flags & FLAG_SKIP_GROUP)
                *flags_ptr |= FLAG_SKIP_GROUP;
        return node->id2;
-@@ -355,17 +360,96 @@ void recv_id_list(int f, struct file_list *flist)
+@@ -363,17 +368,93 @@ void recv_id_list(int f, struct file_list *flist)
  
        /* Now convert all the uids/gids from sender values to our values. */
  #ifdef SUPPORT_ACLS
@@ -443,10 +443,7 @@ diff --git a/uidlist.c b/uidlist.c
 +              *--cp = '\0'; /* replace comma */
 +      }
 +
-+      /* The 0 user/group doesn't get its name sent, or add it explicitly. */
-+      if (numeric_ids)
-+              cp = NULL;
-+      else
-+              cp = usernames ? uid_to_name(0) : gid_to_name(0);
-+      recv_add_id(idmap_ptr, 0, cp);
++      /* The 0 user/group doesn't get its name sent, so add it explicitly. */
++      recv_add_id(idmap_ptr, 0,
++                  numeric_ids ? NULL : usernames ? uid_to_name(0) : gid_to_name(0));
 +}