Created
December 9, 2013 00:54
-
-
Save hfm/7865859 to your computer and use it in GitHub Desktop.
$ diff -u rsync-3.0.7/flist.c rsync-3.0.8/flist.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- rsync-3.0.7/flist.c 2009-12-22 07:40:41.000000000 +0900 | |
| +++ rsync-3.0.8/flist.c 2011-02-22 03:20:58.000000000 +0900 | |
| @@ -52,12 +52,9 @@ | |
| extern int preserve_devices; | |
| extern int preserve_specials; | |
| extern int delete_during; | |
| -extern int uid_ndx; | |
| -extern int gid_ndx; | |
| extern int eol_nulls; | |
| extern int relative_paths; | |
| extern int implied_dirs; | |
| -extern int file_extra_cnt; | |
| extern int ignore_perishable; | |
| extern int non_perishable_cnt; | |
| extern int prune_empty_dirs; | |
| @@ -70,6 +67,7 @@ | |
| extern int need_unsorted_flist; | |
| extern int sender_symlink_iconv; | |
| extern int unsort_ndx; | |
| +extern uid_t our_uid; | |
| extern struct stats stats; | |
| extern char *filesfrom_host; | |
| @@ -118,7 +116,7 @@ | |
| * will survive just long enough to be used by send_file_entry(). */ | |
| static dev_t tmp_rdev; | |
| #ifdef SUPPORT_HARD_LINKS | |
| -static int64 tmp_dev, tmp_ino; | |
| +static int64 tmp_dev = -1, tmp_ino; | |
| #endif | |
| static char tmp_sum[MAX_DIGEST_LEN]; | |
| @@ -480,7 +478,7 @@ | |
| modtime = file->modtime; | |
| #ifdef SUPPORT_HARD_LINKS | |
| - if (tmp_dev != 0) { | |
| + if (tmp_dev != -1) { | |
| if (protocol_version >= 30) { | |
| struct ht_int64_node *np = idev_find(tmp_dev, tmp_ino); | |
| first_hlink_ndx = (int32)(long)np->data - 1; | |
| @@ -598,15 +596,17 @@ | |
| #endif | |
| #ifdef SUPPORT_HARD_LINKS | |
| - if (tmp_dev != 0 && protocol_version < 30) { | |
| + if (tmp_dev != -1 && protocol_version < 30) { | |
| + /* Older protocols expect the dev number to be transmitted | |
| + * 1-incremented so that it is never zero. */ | |
| if (protocol_version < 26) { | |
| /* 32-bit dev_t and ino_t */ | |
| - write_int(f, (int32)dev); | |
| + write_int(f, (int32)(dev+1)); | |
| write_int(f, (int32)tmp_ino); | |
| } else { | |
| /* 64-bit dev_t and ino_t */ | |
| if (!(xflags & XMIT_SAME_DEV_pre30)) | |
| - write_longint(f, dev); | |
| + write_longint(f, dev+1); | |
| write_longint(f, tmp_ino); | |
| } | |
| } | |
| @@ -630,8 +630,7 @@ | |
| stats.total_size += F_LENGTH(file); | |
| } | |
| -static struct file_struct *recv_file_entry(struct file_list *flist, | |
| - int xflags, int f) | |
| +static struct file_struct *recv_file_entry(int f, struct file_list *flist, int xflags) | |
| { | |
| static int64 modtime; | |
| static mode_t mode; | |
| @@ -1051,11 +1050,11 @@ | |
| #ifdef SUPPORT_ACLS | |
| if (preserve_acls && !S_ISLNK(mode)) | |
| - receive_acl(file, f); | |
| + receive_acl(f, file); | |
| #endif | |
| #ifdef SUPPORT_XATTRS | |
| if (preserve_xattrs) | |
| - receive_xattr(file, f ); | |
| + receive_xattr(f, file); | |
| #endif | |
| if (S_ISREG(mode) || S_ISLNK(mode)) | |
| @@ -1259,10 +1258,10 @@ | |
| if (protocol_version >= 28 | |
| ? (!S_ISDIR(st.st_mode) && st.st_nlink > 1) | |
| : S_ISREG(st.st_mode)) { | |
| - tmp_dev = (int64)st.st_dev + 1; | |
| + tmp_dev = (int64)st.st_dev; | |
| tmp_ino = (int64)st.st_ino; | |
| } else | |
| - tmp_dev = 0; | |
| + tmp_dev = -1; | |
| } | |
| #endif | |
| @@ -1284,10 +1283,12 @@ | |
| } | |
| #endif | |
| file->mode = st.st_mode; | |
| - if (uid_ndx) /* Check uid_ndx instead of preserve_uid for del support */ | |
| + if (preserve_uid) | |
| F_OWNER(file) = st.st_uid; | |
| - if (gid_ndx) /* Check gid_ndx instead of preserve_gid for del support */ | |
| + if (preserve_gid) | |
| F_GROUP(file) = st.st_gid; | |
| + if (am_generator && st.st_uid == our_uid) | |
| + file->flags |= FLAG_OWNED_BY_US; | |
| if (basename != thisname) | |
| file->dirname = lastdir; | |
| @@ -1427,6 +1428,7 @@ | |
| #endif | |
| #ifdef SUPPORT_XATTRS | |
| if (preserve_xattrs) { | |
| + sx.st.st_mode = file->mode; | |
| sx.xattr = NULL; | |
| if (get_xattr(fname, &sx) < 0) { | |
| io_error |= IOERR_GENERAL; | |
| @@ -1443,13 +1445,13 @@ | |
| #ifdef SUPPORT_ACLS | |
| if (preserve_acls && !S_ISLNK(file->mode)) { | |
| - send_acl(&sx, f); | |
| + send_acl(f, &sx); | |
| free_acl(&sx); | |
| } | |
| #endif | |
| #ifdef SUPPORT_XATTRS | |
| if (preserve_xattrs) { | |
| - F_XATTR(file) = send_xattr(&sx, f); | |
| + F_XATTR(file) = send_xattr(f, &sx); | |
| free_xattr(&sx); | |
| } | |
| #endif | |
| @@ -1476,12 +1478,6 @@ | |
| unsigned int len = strlen(fbuf); | |
| if (len > 1 && fbuf[len-1] == '/') | |
| fbuf[--len] = '\0'; | |
| - if (len >= MAXPATHLEN - 1) { | |
| - io_error |= IOERR_GENERAL; | |
| - rprintf(FERROR_XFER, "skipping long-named directory: %s\n", | |
| - full_fname(fbuf)); | |
| - return; | |
| - } | |
| save_filters = push_local_filters(fbuf, len); | |
| send_directory(f, flist, fbuf, len, flags); | |
| pop_local_filters(save_filters); | |
| @@ -1640,21 +1636,29 @@ | |
| } | |
| p = fbuf + len; | |
| - if (len != 1 || *fbuf != '/') | |
| + if (len == 1 && *fbuf == '/') | |
| + remainder = MAXPATHLEN - 1; | |
| + else if (len < MAXPATHLEN-1) { | |
| *p++ = '/'; | |
| - *p = '\0'; | |
| - remainder = MAXPATHLEN - (p - fbuf); | |
| + *p = '\0'; | |
| + remainder = MAXPATHLEN - (len + 1); | |
| + } else | |
| + remainder = 0; | |
| for (errno = 0, di = readdir(d); di; errno = 0, di = readdir(d)) { | |
| char *dname = d_name(di); | |
| if (dname[0] == '.' && (dname[1] == '\0' | |
| || (dname[1] == '.' && dname[2] == '\0'))) | |
| continue; | |
| - if (strlcpy(p, dname, remainder) >= remainder) { | |
| + unsigned name_len = strlcpy(p, dname, remainder); | |
| + if (name_len >= remainder) { | |
| + char save = fbuf[len]; | |
| + fbuf[len] = '\0'; | |
| io_error |= IOERR_GENERAL; | |
| rprintf(FERROR_XFER, | |
| - "cannot send long-named file %s\n", | |
| - full_fname(fbuf)); | |
| + "filename overflows max-path len by %u: %s/%s\n", | |
| + name_len - remainder + 1, fbuf, dname); | |
| + fbuf[len] = save; | |
| continue; | |
| } | |
| if (dname[0] == '\0') { | |
| @@ -2355,7 +2359,7 @@ | |
| } | |
| flist_expand(flist, 1); | |
| - file = recv_file_entry(flist, flags, f); | |
| + file = recv_file_entry(f, flist, flags); | |
| if (inc_recurse && S_ISDIR(file->mode)) { | |
| flist_expand(dir_flist, 1); | |
| @@ -3039,13 +3043,14 @@ | |
| * of the dirname string, and also indicates that "dirname" is a MAXPATHLEN | |
| * buffer (the functions we call will append names onto the end, but the old | |
| * dir value will be restored on exit). */ | |
| -struct file_list *get_dirlist(char *dirname, int dlen, int ignore_filter_rules) | |
| +struct file_list *get_dirlist(char *dirname, int dlen, int flags) | |
| { | |
| struct file_list *dirlist; | |
| char dirbuf[MAXPATHLEN]; | |
| int save_recurse = recurse; | |
| int save_xfer_dirs = xfer_dirs; | |
| int save_prune_empty_dirs = prune_empty_dirs; | |
| + int senddir_fd = flags & GDL_IGNORE_FILTER_RULES ? -2 : -1; | |
| if (dlen < 0) { | |
| dlen = strlcpy(dirbuf, dirname, MAXPATHLEN); | |
| @@ -3058,7 +3063,7 @@ | |
| recurse = 0; | |
| xfer_dirs = 1; | |
| - send_directory(ignore_filter_rules ? -2 : -1, dirlist, dirname, dlen, FLAG_CONTENT_DIR); | |
| + send_directory(senddir_fd, dirlist, dirname, dlen, FLAG_CONTENT_DIR); | |
| xfer_dirs = save_xfer_dirs; | |
| recurse = save_recurse; | |
| if (do_progress) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment