Fixed failing hunks.
[rsync/rsync-patches.git] / id-pair.diff
index 32683b9..23922a2 100644 (file)
@@ -10,18 +10,18 @@ gets to be really large.
 
 --- old/flist.c
 +++ new/flist.c
-@@ -60,6 +60,7 @@ extern int protocol_version;
+@@ -54,6 +54,7 @@ extern int copy_unsafe_links;
+ extern int protocol_version;
  extern int sanitize_paths;
- extern const char *io_write_phase;
  extern struct stats stats;
 +extern struct id_pair *id_pairs;
  extern struct file_list *the_file_list;
  
  extern char curr_dir[MAXPATHLEN];
-@@ -363,14 +364,14 @@ static void send_file_entry(struct file_
+@@ -351,14 +352,14 @@ static void send_file_entry(struct file_
                }
        } else if (protocol_version < 28)
-               rdev = makedev(0, 0);
+               rdev = MAKEDEV(0, 0);
 -      if (file->uid == uid)
 +      if (id_pairs[file->id_ndx].uid == uid)
                flags |= XMIT_SAME_UID;
@@ -37,7 +37,7 @@ gets to be really large.
        if (file->modtime == modtime)
                flags |= XMIT_SAME_TIME;
        else
-@@ -623,8 +624,7 @@ static struct file_struct *receive_file_
+@@ -609,8 +610,7 @@ static struct file_struct *receive_file_
        file->modtime = modtime;
        file->length = file_length;
        file->mode = mode;
@@ -47,7 +47,7 @@ gets to be really large.
  
        if (dirname_len) {
                file->dirname = lastdir = bp;
-@@ -875,8 +875,7 @@ struct file_struct *make_file(char *fnam
+@@ -862,8 +862,7 @@ struct file_struct *make_file(char *fnam
        file->modtime = st.st_mtime;
        file->length = st.st_size;
        file->mode = st.st_mode;
@@ -57,7 +57,7 @@ gets to be really large.
  
  #ifdef SUPPORT_HARD_LINKS
        if (flist && flist->hlink_pool) {
-@@ -944,8 +943,7 @@ struct file_struct *make_file(char *fnam
+@@ -931,8 +930,7 @@ struct file_struct *make_file(char *fnam
                        file->modtime = st2.st_mtime;
                        file->length = st2.st_size;
                        file->mode = st2.st_mode;
@@ -67,7 +67,7 @@ gets to be really large.
                        file->u.link = NULL;
                } else
                        file->mode = save_mode;
-@@ -1389,7 +1387,7 @@ struct file_list *recv_file_list(int f)
+@@ -1383,7 +1381,7 @@ struct file_list *recv_file_list(int f)
        clean_flist(flist, relative_paths, 1);
  
        if (f >= 0) {
@@ -76,31 +76,31 @@ gets to be really large.
  
                /* Recv the io_error flag */
                if (lp_ignore_errors(module_id) || ignore_errors)
-@@ -1705,13 +1703,15 @@ static void output_flist(struct file_lis
+@@ -1699,13 +1697,15 @@ static void output_flist(struct file_lis
  
        for (i = 0; i < flist->count; i++) {
                file = flist->files[i];
 -              if ((am_root || am_sender) && preserve_uid)
--                      sprintf(uidbuf, " uid=%ld", (long)file->uid);
+-                      snprintf(uidbuf, sizeof uidbuf, " uid=%ld", (long)file->uid);
 -              else
 +              if ((am_root || am_sender) && preserve_uid) {
-+                      sprintf(uidbuf, " uid=%ld",
++                      snprintf(uidbuf, sizeof uidbuf, " uid=%ld",
 +                              (long)id_pairs[file->id_ndx].uid);
 +              } else
                        *uidbuf = '\0';
 -              if (preserve_gid && file->gid != GID_NONE)
--                      sprintf(gidbuf, " gid=%ld", (long)file->gid);
+-                      snprintf(gidbuf, sizeof gidbuf, " gid=%ld", (long)file->gid);
 -              else
 +              if (preserve_gid && id_pairs[file->id_ndx].gid != GID_NONE) {
-+                      sprintf(gidbuf, " gid=%ld",
++                      snprintf(gidbuf, sizeof gidbuf, " gid=%ld",
 +                              (long)id_pairs[file->id_ndx].gid);
 +              } else
                        *gidbuf = '\0';
                if (!am_sender)
-                       sprintf(depthbuf, "%d", file->dir.depth);
+                       snprintf(depthbuf, sizeof depthbuf, "%d", file->dir.depth);
 --- old/generator.c
 +++ new/generator.c
-@@ -91,6 +91,7 @@ extern dev_t filesystem_dev;
+@@ -90,6 +90,7 @@ extern dev_t filesystem_dev;
  extern char *backup_dir;
  extern char *backup_suffix;
  extern int backup_suffix_len;
@@ -108,7 +108,7 @@ gets to be really large.
  extern struct file_list *the_file_list;
  extern struct filter_list_struct server_filter_list;
  
-@@ -326,10 +327,12 @@ int unchanged_attrs(struct file_struct *
+@@ -323,10 +324,12 @@ int unchanged_attrs(struct file_struct *
         && (st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS))
                return 0;
  
@@ -123,7 +123,7 @@ gets to be really large.
                return 0;
  
        return 1;
-@@ -342,6 +345,8 @@ void itemize(struct file_struct *file, i
+@@ -339,6 +342,8 @@ void itemize(struct file_struct *file, i
                int keep_time = !preserve_times ? 0
                    : S_ISDIR(file->mode) ? !omit_dir_times
                    : !S_ISLNK(file->mode);
@@ -132,7 +132,7 @@ gets to be really large.
  
                if (S_ISREG(file->mode) && file->length != st->st_size)
                        iflags |= ITEM_REPORT_SIZE;
-@@ -351,10 +356,10 @@ void itemize(struct file_struct *file, i
+@@ -348,10 +353,10 @@ void itemize(struct file_struct *file, i
                        iflags |= ITEM_REPORT_TIME;
                if ((file->mode & CHMOD_BITS) != (st->st_mode & CHMOD_BITS))
                        iflags |= ITEM_REPORT_PERMS;
@@ -146,26 +146,56 @@ gets to be really large.
                        iflags |= ITEM_REPORT_GROUP;
        } else
                iflags |= ITEM_IS_NEW;
+--- old/log.c
++++ new/log.c
+@@ -47,6 +47,7 @@ extern char *auth_user;
+ extern char *stdout_format;
+ extern char *logfile_format;
+ extern char *logfile_name;
++extern struct id_pair *id_pairs;
+ #if defined HAVE_ICONV_OPEN && defined HAVE_ICONV_H
+ extern iconv_t ic_chck;
+ #endif
+@@ -479,16 +480,16 @@ static void log_formatted(enum logcode c
+               case 'U':
+                       strlcat(fmt, "ld", sizeof fmt);
+                       snprintf(buf2, sizeof buf2, fmt,
+-                               (long)file->uid);
++                               (long)id_pairs[file->id_ndx].uid);
+                       n = buf2;
+                       break;
+               case 'G':
+-                      if (file->gid == GID_NONE)
++                      if (id_pairs[file->id_ndx].gid == GID_NONE)
+                               n = "DEFAULT";
+                       else {
+                               strlcat(fmt, "ld", sizeof fmt);
+                               snprintf(buf2, sizeof buf2, fmt,
+-                                       (long)file->gid);
++                                       (long)id_pairs[file->id_ndx].gid);
+                               n = buf2;
+                       }
+                       break;
 --- old/rsync.c
 +++ new/rsync.c
-@@ -50,6 +50,7 @@ extern int inplace;
- extern int keep_dirlinks;
+@@ -49,6 +49,7 @@ extern int keep_dirlinks;
  extern int make_backups;
+ extern mode_t orig_umask;
  extern struct stats stats;
 +extern struct id_pair *id_pairs;
+ extern struct chmod_mode_struct *daemon_chmod_modes;
  
  #if defined HAVE_ICONV_OPEN && defined HAVE_ICONV_H
- iconv_t ic_chck = (iconv_t)-1;
-@@ -125,6 +126,8 @@ int set_file_attrs(char *fname, struct f
-       int updated = 0;
+@@ -130,6 +131,8 @@ int set_file_attrs(char *fname, struct f
        STRUCT_STAT st2;
        int change_uid, change_gid;
+       mode_t new_mode = file->mode;
 +      uid_t uid;
 +      gid_t gid;
  
        if (!st) {
                if (dry_run)
-@@ -157,9 +160,11 @@ int set_file_attrs(char *fname, struct f
+@@ -162,9 +165,11 @@ int set_file_attrs(char *fname, struct f
                        updated = 1;
        }
  
@@ -180,7 +210,7 @@ gets to be really large.
  #if !defined HAVE_LCHOWN && !defined CHOWN_MODIFIES_SYMLINK
        if (S_ISLNK(st->st_mode))
                ;
-@@ -171,18 +176,18 @@ int set_file_attrs(char *fname, struct f
+@@ -176,18 +181,18 @@ int set_file_attrs(char *fname, struct f
                                rprintf(FINFO,
                                        "set uid of %s from %ld to %ld\n",
                                        fname,
@@ -205,8 +235,8 @@ gets to be really large.
                        rsyserr(FERROR, errno, "%s %s failed",
 --- old/rsync.h
 +++ new/rsync.h
-@@ -493,6 +493,11 @@ struct hlink {
-       int hlindex;
+@@ -503,6 +503,11 @@ struct hlink {
+       unsigned short link_dest_used;
  };
  
 +struct id_pair {
@@ -217,7 +247,7 @@ gets to be really large.
  #define F_DEV link_u.idev->dev
  #define F_INODE       link_u.idev->inode
  
-@@ -517,8 +522,7 @@ struct file_struct {
+@@ -527,8 +532,7 @@ struct file_struct {
                struct hlink *links;
        } link_u;
        time_t modtime;
@@ -229,7 +259,7 @@ gets to be really large.
  };
 --- old/uidlist.c
 +++ new/uidlist.c
-@@ -37,6 +37,8 @@ extern int preserve_gid;
+@@ -38,6 +38,8 @@ extern int preserve_gid;
  extern int numeric_ids;
  extern int am_root;
  
@@ -238,7 +268,7 @@ gets to be really large.
  struct idlist {
        struct idlist *next;
        int id, id2;
-@@ -46,6 +48,8 @@ struct idlist {
+@@ -47,6 +49,8 @@ struct idlist {
  static struct idlist *uidlist;
  static struct idlist *gidlist;
  
@@ -247,7 +277,7 @@ gets to be really large.
  static struct idlist *add_to_list(struct idlist **root, int id, char *name,
                                  int id2)
  {
-@@ -307,7 +311,7 @@ void send_uid_list(int f)
+@@ -306,7 +310,7 @@ void send_uid_list(int f)
  
  /* recv a complete uid/gid mapping from the peer and map the uid/gid
   * in the file list to local names */
@@ -256,7 +286,7 @@ gets to be really large.
  {
        int id, i;
        char *name;
-@@ -338,11 +342,40 @@ void recv_uid_list(int f, struct file_li
+@@ -337,11 +341,40 @@ void recv_uid_list(int f, struct file_li
  
        /* Now convert all the uids/gids from sender values to our values. */
        if (am_root && preserve_uid && !numeric_ids) {