From: Wayne Davison Date: Tue, 16 Oct 2007 15:10:09 +0000 (+0000) Subject: - Moved the arg-checking relating into set_allow_inc_recurse() and X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/9970bed4d99f70dab4676ae92dab104a70aae56c - Moved the arg-checking relating into set_allow_inc_recurse() and call it when the server is in setup_protocol(). The function sets allow_inc_recurse to 0 if some options won't allow us to support an incremental-recursive transfer. - The server now checks for an 'i' in the -e option from the client and zeros out allow_inc_recurse if not found. - The server reports its inc_recurse determination back to the client. - The client sets inc_recurse based on the value it gets from the server. --- diff --git a/compat.c b/compat.c index a1a0f247..b0574242 100644 --- a/compat.c +++ b/compat.c @@ -102,6 +102,16 @@ static void check_sub_protocol(void) protocol_version--; } +void set_allow_inc_recurse(void) +{ + if (!recurse || delete_before || delete_after || use_qsort + || (!am_sender && (delay_updates || prune_empty_dirs))) + allow_inc_recurse = 0; + else if (am_server && !local_server + && (!shell_cmd || strchr(shell_cmd, 'i') == NULL)) + allow_inc_recurse = 0; +} + void setup_protocol(int f_out,int f_in) { if (am_sender) @@ -117,6 +127,9 @@ void setup_protocol(int f_out,int f_in) if (preserve_xattrs) xattrs_ndx = ++file_extra_cnt; + if (am_server) + set_allow_inc_recurse(); + if (remote_protocol == 0) { if (am_server && !local_server) check_sub_protocol(); @@ -216,21 +229,18 @@ void setup_protocol(int f_out,int f_in) exit_cleanup(RERR_PROTOCOL); } } else if (protocol_version >= 30) { - if (recurse && allow_inc_recurse - && !delete_before && !delete_after && !delay_updates - && !use_qsort && !prune_empty_dirs) - inc_recurse = 1; - if (am_server || read_batch) { - int i_r = read_byte(f_in); - if (i_r && !inc_recurse) { - fprintf(stderr, - "Incompatible options specified for inc-recursive %s.\n", - read_batch ? "batch file" : "connection"); - exit_cleanup(RERR_SYNTAX); - } - inc_recurse = i_r; - } else + if (am_server) { + inc_recurse = allow_inc_recurse; write_byte(f_out, inc_recurse); + } else + inc_recurse = read_byte(f_in); + if (inc_recurse && !allow_inc_recurse) { + /* This should only be able to happen in a batch. */ + fprintf(stderr, + "Incompatible options specified for inc-recursive %s.\n", + read_batch ? "batch file" : "protocol"); + exit_cleanup(RERR_SYNTAX); + } need_messages_from_generator = 1; }