extern struct file_list *the_file_list;
extern char curr_dir[MAXPATHLEN];
-@@ -355,14 +356,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;
if (file->modtime == modtime)
flags |= XMIT_SAME_TIME;
else
-@@ -613,8 +614,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;
if (dirname_len) {
file->dirname = lastdir = bp;
-@@ -865,8 +865,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;
#ifdef SUPPORT_HARD_LINKS
if (flist && flist->hlink_pool) {
-@@ -934,8 +933,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;
file->u.link = NULL;
} else
file->mode = save_mode;
-@@ -1379,7 +1377,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) {
/* Recv the io_error flag */
if (lp_ignore_errors(module_id) || ignore_errors)
-@@ -1695,13 +1693,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
@@ -90,6 +90,7 @@ extern dev_t filesystem_dev;
iflags |= ITEM_IS_NEW;
--- old/log.c
+++ new/log.c
-@@ -43,6 +43,7 @@ extern int daemon_log_format_has_o_or_i;
- extern mode_t orig_umask;
- extern char *auth_user;
- extern char *log_format;
+@@ -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
-@@ -475,16 +476,16 @@ static void log_formatted(enum logcode c
+@@ -479,16 +480,16 @@ static void log_formatted(enum logcode c
case 'U':
strlcat(fmt, "ld", sizeof fmt);
snprintf(buf2, sizeof buf2, fmt,
break;
--- old/rsync.c
+++ new/rsync.c
-@@ -50,6 +50,7 @@ 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 chmod_mode_struct *daemon_chmod_modes;
#if defined HAVE_ICONV_OPEN && defined HAVE_ICONV_H
-@@ -128,6 +129,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)
-@@ -160,9 +163,11 @@ int set_file_attrs(char *fname, struct f
+@@ -162,9 +165,11 @@ int set_file_attrs(char *fname, struct f
updated = 1;
}
#if !defined HAVE_LCHOWN && !defined CHOWN_MODIFIES_SYMLINK
if (S_ISLNK(st->st_mode))
;
-@@ -174,18 +179,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,
rsyserr(FERROR, errno, "%s %s failed",
--- old/rsync.h
+++ new/rsync.h
-@@ -495,6 +495,11 @@ struct hlink {
- int hlindex;
+@@ -503,6 +503,11 @@ struct hlink {
+ unsigned short link_dest_used;
};
+struct id_pair {
#define F_DEV link_u.idev->dev
#define F_INODE link_u.idev->inode
-@@ -519,8 +524,7 @@ struct file_struct {
+@@ -527,8 +532,7 @@ struct file_struct {
struct hlink *links;
} link_u;
time_t modtime;
static struct idlist *add_to_list(struct idlist **root, int id, char *name,
int id2)
{
-@@ -308,7 +312,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 */
{
int id, i;
char *name;
-@@ -339,11 +343,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) {