2 * Compatibility routines for older rsync protocol versions.
4 * Copyright (C) Andrew Tridgell 1996
5 * Copyright (C) Paul Mackerras 1996
6 * Copyright (C) 2004-2020 Wayne Davison
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, visit the http://fsf.org website.
27 extern int local_server;
31 extern int allow_inc_recurse;
32 extern int preallocate_files;
33 extern int append_mode;
34 extern int fuzzy_basis;
35 extern int read_batch;
36 extern int write_batch;
37 extern int delay_updates;
38 extern int checksum_seed;
39 extern int basis_dir_cnt;
40 extern int prune_empty_dirs;
41 extern int protocol_version;
42 extern int protect_args;
43 extern int preserve_uid;
44 extern int preserve_gid;
45 extern int preserve_atimes;
46 extern int preserve_crtimes;
47 extern int preserve_acls;
48 extern int preserve_xattrs;
49 extern int xfer_flags_as_varint;
50 extern int need_messages_from_generator;
51 extern int delete_mode, delete_before, delete_during, delete_after;
52 extern int do_compression;
53 extern int do_compression_level;
54 extern char *shell_cmd;
55 extern char *partial_dir;
56 extern char *files_from;
57 extern char *filesfrom_host;
58 extern const char *checksum_choice;
59 extern const char *compress_choice;
60 extern filter_rule_list filter_list;
61 extern int need_unsorted_flist;
63 extern iconv_t ic_send, ic_recv;
64 extern char *iconv_opt;
66 extern struct name_num_obj valid_checksums;
68 int remote_protocol = 0;
69 int file_extra_cnt = 0; /* count of file-list extras that everyone gets */
72 int use_safe_inc_flist = 0;
73 int want_xattr_optim = 0;
74 int proper_seed_order = 0;
75 int inplace_partial = 0;
76 int do_negotiated_strings = 0;
77 int xmit_id0_names = 0;
79 /* These index values are for the file-list's extra-attribute array. */
80 int pathname_ndx, depth_ndx, atimes_ndx, crtimes_ndx, uid_ndx, gid_ndx, acls_ndx, xattrs_ndx, unsort_ndx;
82 int receiver_symlink_times = 0; /* receiver can set the time on a symlink */
83 int sender_symlink_iconv = 0; /* sender should convert symlink content */
86 int filesfrom_convert = 0;
89 #define MAX_NSTR_STRLEN 256
91 struct name_num_obj valid_compressions = {
92 "compress", NULL, NULL, 0, 0, {
94 { CPRES_ZSTD, "zstd", NULL },
97 { CPRES_LZ4, "lz4", NULL },
99 { CPRES_ZLIBX, "zlibx", NULL },
100 { CPRES_ZLIB, "zlib", NULL },
101 { CPRES_NONE, "none", NULL },
106 #define CF_INC_RECURSE (1<<0)
107 #define CF_SYMLINK_TIMES (1<<1)
108 #define CF_SYMLINK_ICONV (1<<2)
109 #define CF_SAFE_FLIST (1<<3)
110 #define CF_AVOID_XATTR_OPTIM (1<<4)
111 #define CF_CHKSUM_SEED_FIX (1<<5)
112 #define CF_INPLACE_PARTIAL_DIR (1<<6)
113 #define CF_VARINT_FLIST_FLAGS (1<<7)
114 #define CF_ID0_NAMES (1<<8)
116 static const char *client_info;
118 /* The server makes sure that if either side only supports a pre-release
119 * version of a protocol, that both sides must speak a compatible version
120 * of that protocol for it to be advertised as available. */
121 static void check_sub_protocol(void)
124 int their_protocol, their_sub;
125 #if SUBPROTOCOL_VERSION != 0
126 int our_sub = protocol_version < PROTOCOL_VERSION ? 0 : SUBPROTOCOL_VERSION;
131 /* client_info starts with VER.SUB string if client is a pre-release. */
132 if (!(their_protocol = atoi(client_info))
133 || !(dot = strchr(client_info, '.'))
134 || !(their_sub = atoi(dot+1))) {
135 #if SUBPROTOCOL_VERSION != 0
142 if (their_protocol < protocol_version) {
144 protocol_version = their_protocol - 1;
148 if (their_protocol > protocol_version)
149 their_sub = 0; /* 0 == final version of older protocol */
150 if (their_sub != our_sub)
154 void set_allow_inc_recurse(void)
156 client_info = shell_cmd ? shell_cmd : "";
158 if (!recurse || use_qsort)
159 allow_inc_recurse = 0;
161 && (delete_before || delete_after
162 || delay_updates || prune_empty_dirs))
163 allow_inc_recurse = 0;
164 else if (am_server && !local_server
165 && (strchr(client_info, 'i') == NULL))
166 allow_inc_recurse = 0;
169 void parse_compress_choice(int final_call)
171 if (valid_compressions.negotiated_name)
172 do_compression = valid_compressions.negotiated_num;
173 else if (compress_choice) {
174 struct name_num_item *nni = get_nni_by_name(&valid_compressions, compress_choice, -1);
176 rprintf(FERROR, "unknown compress name: %s\n", compress_choice);
177 exit_cleanup(RERR_UNSUPPORTED);
179 do_compression = nni->num;
181 validate_choice_vs_env(NSTR_COMPRESS, do_compression, -1);
182 } else if (do_compression)
183 do_compression = CPRES_ZLIB;
185 do_compression = CPRES_NONE;
187 if (do_compression != CPRES_NONE && final_call)
188 init_compression_level(); /* There's a chance this might turn compression off! */
190 if (do_compression == CPRES_NONE)
191 compress_choice = NULL;
193 /* Snag the compression name for both write_batch's option output & the following debug output. */
194 if (valid_compressions.negotiated_name)
195 compress_choice = valid_compressions.negotiated_name;
196 else if (compress_choice == NULL) {
197 struct name_num_item *nni = get_nni_by_num(&valid_compressions, do_compression);
198 compress_choice = nni ? nni->name : "UNKNOWN";
201 if (final_call && DEBUG_GTE(NSTR, am_server ? 3 : 1)
202 && (do_compression != CPRES_NONE || do_compression_level != CLVL_NOT_SPECIFIED)) {
203 rprintf(FINFO, "%s%s compress: %s (level %d)\n",
204 am_server ? "Server" : "Client",
205 valid_compressions.negotiated_name ? " negotiated" : "",
206 compress_choice, do_compression_level);
210 struct name_num_item *get_nni_by_name(struct name_num_obj *nno, const char *name, int len)
212 struct name_num_item *nni;
217 for (nni = nno->list; nni->name; nni++) {
218 if (strncasecmp(name, nni->name, len) == 0 && nni->name[len] == '\0')
225 struct name_num_item *get_nni_by_num(struct name_num_obj *nno, int num)
227 struct name_num_item *nni;
229 for (nni = nno->list; nni->name; nni++) {
237 static void init_nno_saw(struct name_num_obj *nno, int val)
239 struct name_num_item *nni;
243 for (nni = nno->list; nni->name; nni++) {
244 if (nni->num >= nno->saw_len)
245 nno->saw_len = nni->num + 1;
250 nno->saw = new_array0(uchar, nno->saw_len);
252 /* We'll take this opportunity to make sure that the main_name values are set right. */
253 for (cnt = 1, nni = nno->list; nni->name; nni++, cnt++) {
254 if (nno->saw[nni->num])
255 nni->main_name = nno->list[nno->saw[nni->num]-1].name;
257 nno->saw[nni->num] = cnt;
261 memset(nno->saw, val, nno->saw_len);
264 /* Simplify the user-provided string so that it contains valid names without any duplicates.
265 * It also sets the "saw" flags to a 1-relative count of which name was seen first. */
266 static int parse_nni_str(struct name_num_obj *nno, const char *from, char *tobuf, int tobuf_len)
268 char *to = tobuf, *tok = NULL;
269 int saw_tok = 0, cnt = 0;
272 int at_space = isSpace(from);
276 if (!ch || at_space) {
278 struct name_num_item *nni = get_nni_by_name(nno, tok, to - tok);
279 if (nni && !nno->saw[nni->num]) {
280 nno->saw[nni->num] = ++cnt;
281 if (nni->main_name) {
282 to = tok + strlcpy(tok, nni->main_name, tobuf_len - (tok - tobuf));
283 if (to - tobuf >= tobuf_len) {
289 to = tok - (tok != tobuf);
302 if (to - tobuf >= tobuf_len - 1) {
303 to = tok - (tok != tobuf);
310 if (saw_tok && to == tobuf)
311 return strlcpy(tobuf, "INVALID", MAX_NSTR_STRLEN);
316 /* This routine is always called with a tmpbuf of MAX_NSTR_STRLEN length, but the
317 * buffer may be pre-populated with a "len" length string to use OR a len of -1
318 * to tell us to read a string from the fd. */
319 static void recv_negotiate_str(int f_in, struct name_num_obj *nno, char *tmpbuf, int len)
321 struct name_num_item *ret = NULL;
324 len = read_vstring(f_in, tmpbuf, MAX_NSTR_STRLEN);
326 if (DEBUG_GTE(NSTR, am_server ? 3 : 2)) {
328 rprintf(FINFO, "Client %s list (on server): %s\n", nno->type, tmpbuf);
330 rprintf(FINFO, "Server %s list (on client): %s\n", nno->type, tmpbuf);
334 struct name_num_item *nni;
335 int best = nno->saw_len; /* We want best == 1 from the client list, so start with a big number. */
336 char *space, *tok = tmpbuf;
338 while (*tok == ' ') tok++; /* Should be unneeded... */
341 if ((space = strchr(tok, ' ')) != NULL)
343 nni = get_nni_by_name(nno, tok, -1);
349 if (!nni || !nno->saw[nni->num] || best <= nno->saw[nni->num])
352 best = nno->saw[nni->num];
353 if (best == 1 || am_server) /* The server side stops at the first acceptable client choice */
359 nno->negotiated_name = ret->main_name ? ret->main_name : ret->name;
360 nno->negotiated_num = ret->num;
365 if (!am_server || !do_negotiated_strings) {
368 rprintf(FERROR, "Failed to negotiate a %s choice.\n", nno->type);
369 rprintf(FERROR, "%s list: %s\n", am_server ? "Client" : "Server", tmpbuf);
370 /* Recreate our original list from the saw values. This can't overflow our huge
371 * buffer because we don't have enough valid entries to get anywhere close. */
372 for (j = 1, *cp = '\0'; j <= nno->saw_len; j++) {
373 struct name_num_item *nni;
374 for (nni = nno->list; nni->name; nni++) {
375 if (nno->saw[nni->num] == j) {
377 cp += strlcpy(cp, nni->name, MAX_NSTR_STRLEN - (cp - tmpbuf));
383 strlcpy(cp, " INVALID", MAX_NSTR_STRLEN);
384 rprintf(FERROR, "%s list:%s\n", am_server ? "Server" : "Client", tmpbuf);
387 exit_cleanup(RERR_UNSUPPORTED);
390 static const char *getenv_nstr(int ntype)
392 const char *env_str = getenv(ntype == NSTR_COMPRESS ? "RSYNC_COMPRESS_LIST" : "RSYNC_CHECKSUM_LIST");
394 /* When writing a batch file, we always negotiate an old-style choice. */
396 env_str = ntype == NSTR_COMPRESS ? "zlib" : protocol_version >= 30 ? "md5" : "md4";
398 if (am_server && env_str) {
399 char *cp = strchr(env_str, '&');
407 void validate_choice_vs_env(int ntype, int num1, int num2)
409 struct name_num_obj *nno = ntype == NSTR_COMPRESS ? &valid_compressions : &valid_checksums;
410 const char *list_str = getenv_nstr(ntype);
411 char tmpbuf[MAX_NSTR_STRLEN];
416 while (isSpace(list_str)) list_str++;
421 init_nno_saw(nno, 0);
422 parse_nni_str(nno, list_str, tmpbuf, MAX_NSTR_STRLEN);
424 if (ntype == NSTR_CHECKSUM) /* If "md4" is in the env list, all the old MD4 choices are OK too. */
425 nno->saw[CSUM_MD4_ARCHAIC] = nno->saw[CSUM_MD4_BUSTED] = nno->saw[CSUM_MD4_OLD] = nno->saw[CSUM_MD4];
427 if (!nno->saw[num1] || (num2 >= 0 && !nno->saw[num2])) {
428 rprintf(FERROR, "Your --%s-choice value (%s) was refused by the server.\n",
429 ntype == NSTR_COMPRESS ? "compress" : "checksum",
430 ntype == NSTR_COMPRESS ? compress_choice : checksum_choice);
431 exit_cleanup(RERR_UNSUPPORTED);
438 /* The saw buffer is initialized and used to store ordinal values from 1 to N
439 * for the order of the args in the array. If dup_markup == '\0', duplicates
440 * are removed otherwise the char is prefixed to the duplicate term and, if it
441 * is an opening paren/bracket/brace, the matching closing char is suffixed.
442 * "none" is removed on the client side unless dup_markup != '\0'. */
443 int get_default_nno_list(struct name_num_obj *nno, char *to_buf, int to_buf_len, char dup_markup)
445 struct name_num_item *nni;
446 int len = 0, cnt = 0;
447 char delim = '\0', post_delim;
449 switch (dup_markup) {
450 case '(': post_delim = ')'; break;
451 case '[': post_delim = ']'; break;
452 case '{': post_delim = '}'; break;
453 default: post_delim = '\0'; break;
456 init_nno_saw(nno, 0);
458 for (nni = nno->list, len = 0; nni->name; nni++) {
459 if (nni->main_name) {
464 if (nni->num == 0 && !am_server && !dup_markup)
469 to_buf[len++]= delim;
472 len += strlcpy(to_buf+len, nni->name, to_buf_len - len);
473 if (len >= to_buf_len - 3)
474 exit_cleanup(RERR_UNSUPPORTED); /* IMPOSSIBLE... */
476 to_buf[len++]= delim;
479 nno->saw[nni->num] = ++cnt;
485 static void send_negotiate_str(int f_out, struct name_num_obj *nno, int ntype)
487 char tmpbuf[MAX_NSTR_STRLEN];
488 const char *list_str = getenv_nstr(ntype);
491 if (list_str && *list_str) {
492 init_nno_saw(nno, 0);
493 len = parse_nni_str(nno, list_str, tmpbuf, MAX_NSTR_STRLEN);
498 if (!list_str || !*list_str)
499 len = get_default_nno_list(nno, tmpbuf, MAX_NSTR_STRLEN, '\0');
501 if (DEBUG_GTE(NSTR, am_server ? 3 : 2)) {
503 rprintf(FINFO, "Server %s list (on server): %s\n", nno->type, tmpbuf);
505 rprintf(FINFO, "Client %s list (on client): %s\n", nno->type, tmpbuf);
508 /* Each side sends their list of valid names to the other side and then both sides
509 * pick the first name in the client's list that is also in the server's list. */
510 if (do_negotiated_strings)
511 write_vstring(f_out, tmpbuf, len);
514 static void negotiate_the_strings(int f_in, int f_out)
516 /* We send all the negotiation strings before we start to read them to help avoid a slow startup. */
518 if (!checksum_choice)
519 send_negotiate_str(f_out, &valid_checksums, NSTR_CHECKSUM);
521 if (do_compression && !compress_choice)
522 send_negotiate_str(f_out, &valid_compressions, NSTR_COMPRESS);
524 if (valid_checksums.saw) {
525 char tmpbuf[MAX_NSTR_STRLEN];
527 if (do_negotiated_strings)
530 len = strlcpy(tmpbuf, protocol_version >= 30 ? "md5" : "md4", MAX_NSTR_STRLEN);
531 recv_negotiate_str(f_in, &valid_checksums, tmpbuf, len);
534 if (valid_compressions.saw) {
535 char tmpbuf[MAX_NSTR_STRLEN];
537 if (do_negotiated_strings)
540 len = strlcpy(tmpbuf, "zlib", MAX_NSTR_STRLEN);
541 recv_negotiate_str(f_in, &valid_compressions, tmpbuf, len);
544 /* If the other side is too old to negotiate, the above steps just made sure that
545 * the env didn't disallow the old algorithm. Mark things as non-negotiated. */
546 if (!do_negotiated_strings)
547 valid_checksums.negotiated_name = valid_compressions.negotiated_name = NULL;
550 void setup_protocol(int f_out,int f_in)
552 assert(file_extra_cnt == 0);
553 assert(EXTRA64_CNT == 2 || EXTRA64_CNT == 1);
555 /* All int64 values must be set first so that they are guaranteed to be
556 * aligned for direct int64-pointer memory access. */
558 atimes_ndx = (file_extra_cnt += EXTRA64_CNT);
559 if (preserve_crtimes)
560 crtimes_ndx = (file_extra_cnt += EXTRA64_CNT);
561 if (am_sender) /* This is most likely in the in64 union as well. */
562 pathname_ndx = (file_extra_cnt += PTR_EXTRA_CNT);
564 depth_ndx = ++file_extra_cnt;
566 uid_ndx = ++file_extra_cnt;
568 gid_ndx = ++file_extra_cnt;
569 if (preserve_acls && !am_sender)
570 acls_ndx = ++file_extra_cnt;
572 xattrs_ndx = ++file_extra_cnt;
575 set_allow_inc_recurse();
577 if (remote_protocol == 0) {
578 if (am_server && !local_server)
579 check_sub_protocol();
581 write_int(f_out, protocol_version);
582 remote_protocol = read_int(f_in);
583 if (protocol_version > remote_protocol)
584 protocol_version = remote_protocol;
586 if (read_batch && remote_protocol > protocol_version) {
587 rprintf(FERROR, "The protocol version in the batch file is too new (%d > %d).\n",
588 remote_protocol, protocol_version);
589 exit_cleanup(RERR_PROTOCOL);
592 if (DEBUG_GTE(PROTO, 1)) {
593 rprintf(FINFO, "(%s) Protocol versions: remote=%d, negotiated=%d\n",
594 am_server? "Server" : "Client", remote_protocol, protocol_version);
596 if (remote_protocol < MIN_PROTOCOL_VERSION
597 || remote_protocol > MAX_PROTOCOL_VERSION) {
598 rprintf(FERROR,"protocol version mismatch -- is your shell clean?\n");
599 rprintf(FERROR,"(see the rsync man page for an explanation)\n");
600 exit_cleanup(RERR_PROTOCOL);
602 if (remote_protocol < OLD_PROTOCOL_VERSION) {
603 rprintf(FINFO,"%s is very old version of rsync, upgrade recommended.\n",
604 am_server? "Client" : "Server");
606 if (protocol_version < MIN_PROTOCOL_VERSION) {
607 rprintf(FERROR, "--protocol must be at least %d on the %s.\n",
608 MIN_PROTOCOL_VERSION, am_server? "Server" : "Client");
609 exit_cleanup(RERR_PROTOCOL);
611 if (protocol_version > PROTOCOL_VERSION) {
612 rprintf(FERROR, "--protocol must be no more than %d on the %s.\n",
613 PROTOCOL_VERSION, am_server? "Server" : "Client");
614 exit_cleanup(RERR_PROTOCOL);
619 #ifndef SUPPORT_PREALLOCATION
620 if (preallocate_files && !am_sender) {
621 rprintf(FERROR, "preallocation is not supported on this %s\n",
622 am_server ? "Server" : "Client");
623 exit_cleanup(RERR_SYNTAX);
627 if (protocol_version < 30) {
628 if (append_mode == 1)
630 if (preserve_acls && !local_server) {
632 "--acls requires protocol 30 or higher"
633 " (negotiated %d).\n",
635 exit_cleanup(RERR_PROTOCOL);
637 if (preserve_xattrs && !local_server) {
639 "--xattrs requires protocol 30 or higher"
640 " (negotiated %d).\n",
642 exit_cleanup(RERR_PROTOCOL);
646 if (delete_mode && !(delete_before+delete_during+delete_after)) {
647 if (protocol_version < 30)
653 if (protocol_version < 29) {
656 "--fuzzy requires protocol 29 or higher"
657 " (negotiated %d).\n",
659 exit_cleanup(RERR_PROTOCOL);
662 if (basis_dir_cnt && inplace) {
664 "%s with --inplace requires protocol 29 or higher"
665 " (negotiated %d).\n",
666 alt_dest_opt(0), protocol_version);
667 exit_cleanup(RERR_PROTOCOL);
670 if (basis_dir_cnt > 1) {
672 "Using more than one %s option requires protocol"
673 " 29 or higher (negotiated %d).\n",
674 alt_dest_opt(0), protocol_version);
675 exit_cleanup(RERR_PROTOCOL);
678 if (prune_empty_dirs) {
680 "--prune-empty-dirs requires protocol 29 or higher"
681 " (negotiated %d).\n",
683 exit_cleanup(RERR_PROTOCOL);
685 } else if (protocol_version >= 30) {
687 compat_flags = allow_inc_recurse ? CF_INC_RECURSE : 0;
688 #ifdef CAN_SET_SYMLINK_TIMES
689 compat_flags |= CF_SYMLINK_TIMES;
692 compat_flags |= CF_SYMLINK_ICONV;
694 if (local_server || strchr(client_info, 'f') != NULL)
695 compat_flags |= CF_SAFE_FLIST;
696 if (local_server || strchr(client_info, 'x') != NULL)
697 compat_flags |= CF_AVOID_XATTR_OPTIM;
698 if (local_server || strchr(client_info, 'C') != NULL)
699 compat_flags |= CF_CHKSUM_SEED_FIX;
700 if (local_server || strchr(client_info, 'I') != NULL)
701 compat_flags |= CF_INPLACE_PARTIAL_DIR;
702 if (local_server || strchr(client_info, 'u') != NULL)
703 compat_flags |= CF_ID0_NAMES;
704 if (local_server || strchr(client_info, 'v') != NULL) {
705 do_negotiated_strings = 1;
706 compat_flags |= CF_VARINT_FLIST_FLAGS;
708 if (strchr(client_info, 'V') != NULL) { /* Support a pre-release 'V' that got superseded */
710 compat_flags |= CF_VARINT_FLIST_FLAGS;
711 write_byte(f_out, compat_flags);
713 write_varint(f_out, compat_flags);
714 } else { /* read_varint() is compatible with the older write_byte() when the 0x80 bit isn't on. */
715 compat_flags = read_varint(f_in);
716 if (compat_flags & CF_VARINT_FLIST_FLAGS)
717 do_negotiated_strings = 1;
719 /* The inc_recurse var MUST be set to 0 or 1. */
720 inc_recurse = compat_flags & CF_INC_RECURSE ? 1 : 0;
721 want_xattr_optim = protocol_version >= 31 && !(compat_flags & CF_AVOID_XATTR_OPTIM);
722 proper_seed_order = compat_flags & CF_CHKSUM_SEED_FIX ? 1 : 0;
723 xfer_flags_as_varint = compat_flags & CF_VARINT_FLIST_FLAGS ? 1 : 0;
724 xmit_id0_names = compat_flags & CF_ID0_NAMES ? 1 : 0;
725 if (!xfer_flags_as_varint && preserve_crtimes) {
726 fprintf(stderr, "Both rsync versions must be at least 3.2.0 for --crtimes.\n");
727 exit_cleanup(RERR_PROTOCOL);
730 receiver_symlink_times = am_server
731 ? strchr(client_info, 'L') != NULL
732 : !!(compat_flags & CF_SYMLINK_TIMES);
734 #ifdef CAN_SET_SYMLINK_TIMES
736 receiver_symlink_times = 1;
739 sender_symlink_iconv = iconv_opt && (am_server
740 ? local_server || strchr(client_info, 's') != NULL
741 : !!(compat_flags & CF_SYMLINK_ICONV));
743 if (inc_recurse && !allow_inc_recurse) {
744 /* This should only be able to happen in a batch. */
746 "Incompatible options specified for inc-recursive %s.\n",
747 read_batch ? "batch file" : "connection");
748 exit_cleanup(RERR_SYNTAX);
750 use_safe_inc_flist = (compat_flags & CF_SAFE_FLIST) || protocol_version >= 31;
751 need_messages_from_generator = 1;
752 if (compat_flags & CF_INPLACE_PARTIAL_DIR)
754 #ifdef CAN_SET_SYMLINK_TIMES
755 } else if (!am_sender) {
756 receiver_symlink_times = 1;
761 do_negotiated_strings = 0;
763 if (need_unsorted_flist && (!am_sender || inc_recurse))
764 unsort_ndx = ++file_extra_cnt;
766 if (partial_dir && *partial_dir != '/' && (!am_server || local_server)) {
767 int rflags = FILTRULE_NO_PREFIXES | FILTRULE_DIRECTORY;
768 if (!am_sender || protocol_version >= 30)
769 rflags |= FILTRULE_PERISHABLE;
770 parse_filter_str(&filter_list, partial_dir, rule_template(rflags), 0);
775 if (protect_args && files_from) {
777 filesfrom_convert = filesfrom_host && ic_send != (iconv_t)-1;
779 filesfrom_convert = !filesfrom_host && ic_recv != (iconv_t)-1;
783 negotiate_the_strings(f_in, f_out);
787 checksum_seed = time(NULL) ^ (getpid() << 6);
788 write_int(f_out, checksum_seed);
790 checksum_seed = read_int(f_in);
793 parse_checksum_choice(1); /* Sets checksum_type & xfersum_type */
794 parse_compress_choice(1); /* Sets do_compression */
796 if (write_batch && !am_server)
797 write_batch_shell_file();