The branch, master has been updated via 962f8b9 Complain if an inc-recursive path is not right for its dir. This ensures that a malicious sender can't use a just-sent symlink as a trasnfer path. via ae189e1 Mention that --append can be dangerous. via 5b34561 Call set_modtime even if only NSEC is different. from 5546dab Use usleep() for msleep() if it is available.
https://git.samba.org/?p=rsync.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 962f8b90045ab331fc04c9e65f80f1a53e68243b Author: Wayne Davison <way...@samba.org> Date: Wed Dec 31 12:41:03 2014 -0800 Complain if an inc-recursive path is not right for its dir. This ensures that a malicious sender can't use a just-sent symlink as a trasnfer path. commit ae189e18ded7a306a2d5516fbd5b7112c784e333 Author: Wayne Davison <way...@samba.org> Date: Wed Dec 31 11:12:55 2014 -0800 Mention that --append can be dangerous. commit 5b34561cf77962fe1286a5cb20f6bc25f7b6e345 Author: Wayne Davison <way...@samba.org> Date: Wed Dec 31 11:02:03 2014 -0800 Call set_modtime even if only NSEC is different. ----------------------------------------------------------------------- Summary of changes: NEWS | 7 ++++++- flist.c | 22 ++++++++++++++++++++-- io.c | 2 +- main.c | 4 ++-- rsync.c | 8 ++++++-- rsync.yo | 5 +++++ 6 files changed, 40 insertions(+), 8 deletions(-) Changeset truncated at 500 lines: diff --git a/NEWS b/NEWS index 84df781..0c02d82 100644 --- a/NEWS +++ b/NEWS @@ -4,7 +4,11 @@ Changes since 3.1.1: BUG FIXES: - - ... + - Make sure that an inc-recursive transfer includes the right directory- + name prefixes for each dir. This makes it impossible for a malicious + sender to use a just-sent symlink as a path in a transfer. + - Only skip set_modtime() on a transferred file if the time is exactly + right. ENHANCEMENTS: @@ -12,6 +16,7 @@ Changes since 3.1.1: - Use usleep() for our msleep() function if it is available. - Added a few extra long-option names to rrsync script, which will make BackupPC happier. + - Misc. manpage tweaks. DEVELOPER RELATED: diff --git a/flist.c b/flist.c index c24672e..92e4b65 100644 --- a/flist.c +++ b/flist.c @@ -2435,8 +2435,9 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) return flist; } -struct file_list *recv_file_list(int f) +struct file_list *recv_file_list(int f, int dir_ndx) { + const char *good_dirname = NULL; struct file_list *flist; int dstart, flags; int64 start_read; @@ -2492,6 +2493,23 @@ struct file_list *recv_file_list(int f) flist_expand(flist, 1); file = recv_file_entry(f, flist, flags); + if (inc_recurse) { + static const char empty_dir[] = "\0"; + const char *cur_dir = file->dirname ? file->dirname : empty_dir; + if (relative_paths && *cur_dir == '/') + cur_dir++; + if (cur_dir != good_dirname) { + const char *d = dir_ndx >= 0 ? f_name(dir_flist->files[dir_ndx], NULL) : empty_dir; + if (strcmp(cur_dir, d) != 0) { + rprintf(FERROR, + "ABORTING due to invalid dir prefix from sender: %s (should be: %s)\n", + cur_dir, d); + exit_cleanup(RERR_PROTOCOL); + } + good_dirname = cur_dir; + } + } + if (S_ISREG(file->mode)) { /* Already counted */ } else if (S_ISDIR(file->mode)) { @@ -2615,7 +2633,7 @@ void recv_additional_file_list(int f) rprintf(FINFO, "[%s] receiving flist for dir %d\n", who_am_i(), ndx); } - flist = recv_file_list(f); + flist = recv_file_list(f, ndx); flist->parent_ndx = ndx; } } diff --git a/io.c b/io.c index b9a9bd0..a868fa9 100644 --- a/io.c +++ b/io.c @@ -1685,7 +1685,7 @@ void wait_for_receiver(void) rprintf(FINFO, "[%s] receiving flist for dir %d\n", who_am_i(), ndx); } - flist = recv_file_list(iobuf.in_fd); + flist = recv_file_list(iobuf.in_fd, ndx); flist->parent_ndx = ndx; #ifdef SUPPORT_HARD_LINKS if (preserve_hard_links) diff --git a/main.c b/main.c index e7a13f7..713b818 100644 --- a/main.c +++ b/main.c @@ -1009,7 +1009,7 @@ static void do_server_recv(int f_in, int f_out, int argc, char *argv[]) filesfrom_fd = -1; } - flist = recv_file_list(f_in); + flist = recv_file_list(f_in, -1); if (!flist) { rprintf(FERROR,"server_recv: recv_file_list error\n"); exit_cleanup(RERR_FILESELECT); @@ -1183,7 +1183,7 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[]) if (write_batch && !am_server) start_write_batch(f_in); - flist = recv_file_list(f_in); + flist = recv_file_list(f_in, -1); if (inc_recurse && file_total == 1) recv_additional_file_list(f_in); diff --git a/rsync.c b/rsync.c index c498c44..c3ecc51 100644 --- a/rsync.c +++ b/rsync.c @@ -364,7 +364,7 @@ int read_ndx_and_attrs(int f_in, int f_out, int *iflag_ptr, uchar *type_ptr, } /* Send all the data we read for this flist to the generator. */ start_flist_forward(ndx); - flist = recv_file_list(f_in); + flist = recv_file_list(f_in, ndx); flist->parent_ndx = ndx; stop_flist_forward(); } @@ -548,7 +548,11 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp, || (!(preserve_times & PRESERVE_LINK_TIMES) && S_ISLNK(sxp->st.st_mode))) flags |= ATTRS_SKIP_MTIME; if (!(flags & ATTRS_SKIP_MTIME) - && cmp_time(sxp->st.st_mtime, file->modtime) != 0) { + && (sxp->st.st_mtime != file->modtime +#ifdef ST_MTIME_NSEC + || (NSEC_BUMP(file) && (uint32)sxp->st.ST_MTIME_NSEC != F_MOD_NSEC(file)) +#endif + )) { int ret = set_modtime(fname, file->modtime, F_MOD_NSEC(file), sxp->st.st_mode); if (ret < 0) { rsyserr(FERROR_XFER, errno, "failed to set times on %s", diff --git a/rsync.yo b/rsync.yo index eef47e9..20300eb 100644 --- a/rsync.yo +++ b/rsync.yo @@ -864,6 +864,11 @@ Implies bf(--inplace), but does not conflict with bf(--sparse) (since it is always extending a file's length). +The use of bf(--append) can be dangerous if you aren't 100% sure that the files +that are longer have only grown by the appending of data onto the end. You +should thus use include/exclude/filter rules to ensure that such a transfer is +only affecting files that you know to be growing via appended data. + dit(bf(--append-verify)) This works just like the bf(--append) option, but the existing data on the receiving side is included in the full-file checksum verification step, which will cause a file to be resent if the -- The rsync repository. _______________________________________________ rsync-cvs mailing list rsync-cvs@lists.samba.org https://lists.samba.org/mailman/listinfo/rsync-cvs