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.
28 extern int local_server;
32 extern int allow_inc_recurse;
33 extern int preallocate_files;
34 extern int append_mode;
35 extern int fuzzy_basis;
36 extern int read_batch;
37 extern int write_batch;
38 extern int delay_updates;
39 extern int checksum_seed;
40 extern int basis_dir_cnt;
41 extern int prune_empty_dirs;
42 extern int protocol_version;
43 extern int protect_args;
44 extern int preserve_uid;
45 extern int preserve_gid;
46 extern int preserve_atimes;
47 extern int preserve_crtimes;
48 extern int preserve_acls;
49 extern int preserve_xattrs;
50 extern int xfer_flags_as_varint;
51 extern int need_messages_from_generator;
52 extern int delete_mode, delete_before, delete_during, delete_after;
53 extern int do_compression;
54 extern int do_compression_level;
55 extern char *shell_cmd;
56 extern char *partial_dir;
57 extern char *files_from;
58 extern char *filesfrom_host;
59 extern const char *checksum_choice;
60 extern const char *compress_choice;
61 extern filter_rule_list filter_list;
62 extern int need_unsorted_flist;
64 extern iconv_t ic_send, ic_recv;
65 extern char *iconv_opt;
67 extern struct name_num_obj valid_checksums;
69 int remote_protocol = 0;
70 int file_extra_cnt = 0; /* count of file-list extras that everyone gets */
73 int use_safe_inc_flist = 0;
74 int want_xattr_optim = 0;
75 int proper_seed_order = 0;
76 int inplace_partial = 0;
77 int do_negotiated_strings = 0;
78 int xmit_id0_names = 0;
80 /* These index values are for the file-list's extra-attribute array. */
81 int pathname_ndx, depth_ndx, atimes_ndx, crtimes_ndx, uid_ndx, gid_ndx, acls_ndx, xattrs_ndx, unsort_ndx;
83 int receiver_symlink_times = 0; /* receiver can set the time on a symlink */
84 int sender_symlink_iconv = 0; /* sender should convert symlink content */
87 int filesfrom_convert = 0;
90 #define MAX_NSTR_STRLEN 256
92 struct name_num_obj valid_compressions = {
93 "compress", NULL, NULL, 0, 0, {
95 { CPRES_ZSTD, "zstd", NULL },
98 { CPRES_LZ4, "lz4", NULL },
100 { CPRES_ZLIBX, "zlibx", NULL },
101 { CPRES_ZLIB, "zlib", NULL },
102 { CPRES_NONE, "none", NULL },
107 #define CF_INC_RECURSE (1<<0)
108 #define CF_SYMLINK_TIMES (1<<1)
109 #define CF_SYMLINK_ICONV (1<<2)
110 #define CF_SAFE_FLIST (1<<3)
111 #define CF_AVOID_XATTR_OPTIM (1<<4)
112 #define CF_CHKSUM_SEED_FIX (1<<5)
113 #define CF_INPLACE_PARTIAL_DIR (1<<6)
114 #define CF_VARINT_FLIST_FLAGS (1<<7)
115 #define CF_ID0_NAMES (1<<8)
117 static const char *client_info;
119 /* The server makes sure that if either side only supports a pre-release
120 * version of a protocol, that both sides must speak a compatible version
121 * of that protocol for it to be advertised as available. */
122 static void check_sub_protocol(void)
125 int their_protocol, their_sub;
126 #if SUBPROTOCOL_VERSION != 0
127 int our_sub = protocol_version < PROTOCOL_VERSION ? 0 : SUBPROTOCOL_VERSION;
132 /* client_info starts with VER.SUB string if client is a pre-release. */
133 if (!(their_protocol = atoi(client_info))
134 || !(dot = strchr(client_info, '.'))
135 || !(their_sub = atoi(dot+1))) {
136 #if SUBPROTOCOL_VERSION != 0
143 if (their_protocol < protocol_version) {
145 protocol_version = their_protocol - 1;
149 if (their_protocol > protocol_version)
150 their_sub = 0; /* 0 == final version of older protocol */
151 if (their_sub != our_sub)
155 void set_allow_inc_recurse(void)
158 client_info = shell_cmd ? shell_cmd : "";
159 else if (am_server) {
161 maybe_add_e_option(buf, sizeof buf);
162 client_info = *buf ? strdup(buf+1) : ""; /* The +1 skips the leading "e". */
165 if (!recurse || use_qsort)
166 allow_inc_recurse = 0;
168 && (delete_before || delete_after
169 || delay_updates || prune_empty_dirs))
170 allow_inc_recurse = 0;
171 else if (am_server && strchr(client_info, 'i') == NULL)
172 allow_inc_recurse = 0;
175 void parse_compress_choice(int final_call)
177 if (valid_compressions.negotiated_name)
178 do_compression = valid_compressions.negotiated_num;
179 else if (compress_choice) {
180 struct name_num_item *nni = get_nni_by_name(&valid_compressions, compress_choice, -1);
182 rprintf(FERROR, "unknown compress name: %s\n", compress_choice);
183 exit_cleanup(RERR_UNSUPPORTED);
185 do_compression = nni->num;
187 validate_choice_vs_env(NSTR_COMPRESS, do_compression, -1);
188 } else if (do_compression)
189 do_compression = CPRES_ZLIB;
191 do_compression = CPRES_NONE;
193 if (do_compression != CPRES_NONE && final_call)
194 init_compression_level(); /* There's a chance this might turn compression off! */
196 if (do_compression == CPRES_NONE)
197 compress_choice = NULL;
199 /* Snag the compression name for both write_batch's option output & the following debug output. */
200 if (valid_compressions.negotiated_name)
201 compress_choice = valid_compressions.negotiated_name;
202 else if (compress_choice == NULL) {
203 struct name_num_item *nni = get_nni_by_num(&valid_compressions, do_compression);
204 compress_choice = nni ? nni->name : "UNKNOWN";
207 if (final_call && DEBUG_GTE(NSTR, am_server ? 3 : 1)
208 && (do_compression != CPRES_NONE || do_compression_level != CLVL_NOT_SPECIFIED)) {
209 rprintf(FINFO, "%s%s compress: %s (level %d)\n",
210 am_server ? "Server" : "Client",
211 valid_compressions.negotiated_name ? " negotiated" : "",
212 compress_choice, do_compression_level);
216 struct name_num_item *get_nni_by_name(struct name_num_obj *nno, const char *name, int len)
218 struct name_num_item *nni;
223 for (nni = nno->list; nni->name; nni++) {
224 if (strncasecmp(name, nni->name, len) == 0 && nni->name[len] == '\0')
231 struct name_num_item *get_nni_by_num(struct name_num_obj *nno, int num)
233 struct name_num_item *nni;
235 for (nni = nno->list; nni->name; nni++) {
243 static void init_nno_saw(struct name_num_obj *nno, int val)
245 struct name_num_item *nni;
249 for (nni = nno->list; nni->name; nni++) {
250 if (nni->num >= nno->saw_len)
251 nno->saw_len = nni->num + 1;
256 nno->saw = new_array0(uchar, nno->saw_len);
258 /* We'll take this opportunity to make sure that the main_name values are set right. */
259 for (cnt = 1, nni = nno->list; nni->name; nni++, cnt++) {
260 if (nno->saw[nni->num])
261 nni->main_name = nno->list[nno->saw[nni->num]-1].name;
263 nno->saw[nni->num] = cnt;
267 memset(nno->saw, val, nno->saw_len);
270 /* Simplify the user-provided string so that it contains valid names without any duplicates.
271 * It also sets the "saw" flags to a 1-relative count of which name was seen first. */
272 static int parse_nni_str(struct name_num_obj *nno, const char *from, char *tobuf, int tobuf_len)
274 char *to = tobuf, *tok = NULL;
275 int saw_tok = 0, cnt = 0;
278 int at_space = isSpace(from);
282 if (!ch || at_space) {
284 struct name_num_item *nni = get_nni_by_name(nno, tok, to - tok);
285 if (nni && !nno->saw[nni->num]) {
286 nno->saw[nni->num] = ++cnt;
287 if (nni->main_name) {
288 to = tok + strlcpy(tok, nni->main_name, tobuf_len - (tok - tobuf));
289 if (to - tobuf >= tobuf_len) {
295 to = tok - (tok != tobuf);
308 if (to - tobuf >= tobuf_len - 1) {
309 to = tok - (tok != tobuf);
316 if (saw_tok && to == tobuf)
317 return strlcpy(tobuf, "INVALID", MAX_NSTR_STRLEN);
322 /* This routine is always called with a tmpbuf of MAX_NSTR_STRLEN length, but the
323 * buffer may be pre-populated with a "len" length string to use OR a len of -1
324 * to tell us to read a string from the fd. */
325 static void recv_negotiate_str(int f_in, struct name_num_obj *nno, char *tmpbuf, int len)
327 struct name_num_item *ret = NULL;
330 len = read_vstring(f_in, tmpbuf, MAX_NSTR_STRLEN);
332 if (DEBUG_GTE(NSTR, am_server ? 3 : 2)) {
334 rprintf(FINFO, "Client %s list (on server): %s\n", nno->type, tmpbuf);
336 rprintf(FINFO, "Server %s list (on client): %s\n", nno->type, tmpbuf);
340 struct name_num_item *nni;
341 int best = nno->saw_len; /* We want best == 1 from the client list, so start with a big number. */
342 char *space, *tok = tmpbuf;
344 while (*tok == ' ') tok++; /* Should be unneeded... */
347 if ((space = strchr(tok, ' ')) != NULL)
349 nni = get_nni_by_name(nno, tok, -1);
355 if (!nni || !nno->saw[nni->num] || best <= nno->saw[nni->num])
358 best = nno->saw[nni->num];
359 if (best == 1 || am_server) /* The server side stops at the first acceptable client choice */
365 nno->negotiated_name = ret->main_name ? ret->main_name : ret->name;
366 nno->negotiated_num = ret->num;
371 if (!am_server || !do_negotiated_strings) {
374 rprintf(FERROR, "Failed to negotiate a %s choice.\n", nno->type);
375 rprintf(FERROR, "%s list: %s\n", am_server ? "Client" : "Server", tmpbuf);
376 /* Recreate our original list from the saw values. This can't overflow our huge
377 * buffer because we don't have enough valid entries to get anywhere close. */
378 for (j = 1, *cp = '\0'; j <= nno->saw_len; j++) {
379 struct name_num_item *nni;
380 for (nni = nno->list; nni->name; nni++) {
381 if (nno->saw[nni->num] == j) {
383 cp += strlcpy(cp, nni->name, MAX_NSTR_STRLEN - (cp - tmpbuf));
389 strlcpy(cp, " INVALID", MAX_NSTR_STRLEN);
390 rprintf(FERROR, "%s list:%s\n", am_server ? "Server" : "Client", tmpbuf);
393 exit_cleanup(RERR_UNSUPPORTED);
396 static const char *getenv_nstr(int ntype)
398 const char *env_str = getenv(ntype == NSTR_COMPRESS ? "RSYNC_COMPRESS_LIST" : "RSYNC_CHECKSUM_LIST");
400 /* When writing a batch file, we always negotiate an old-style choice. */
402 env_str = ntype == NSTR_COMPRESS ? "zlib" : protocol_version >= 30 ? "md5" : "md4";
404 if (am_server && env_str) {
405 char *cp = strchr(env_str, '&');
413 void validate_choice_vs_env(int ntype, int num1, int num2)
415 struct name_num_obj *nno = ntype == NSTR_COMPRESS ? &valid_compressions : &valid_checksums;
416 const char *list_str = getenv_nstr(ntype);
417 char tmpbuf[MAX_NSTR_STRLEN];
422 while (isSpace(list_str)) list_str++;
427 init_nno_saw(nno, 0);
428 parse_nni_str(nno, list_str, tmpbuf, MAX_NSTR_STRLEN);
430 if (ntype == NSTR_CHECKSUM) /* If "md4" is in the env list, all the old MD4 choices are OK too. */
431 nno->saw[CSUM_MD4_ARCHAIC] = nno->saw[CSUM_MD4_BUSTED] = nno->saw[CSUM_MD4_OLD] = nno->saw[CSUM_MD4];
433 if (!nno->saw[num1] || (num2 >= 0 && !nno->saw[num2])) {
434 rprintf(FERROR, "Your --%s-choice value (%s) was refused by the server.\n",
435 ntype == NSTR_COMPRESS ? "compress" : "checksum",
436 ntype == NSTR_COMPRESS ? compress_choice : checksum_choice);
437 exit_cleanup(RERR_UNSUPPORTED);
444 /* The saw buffer is initialized and used to store ordinal values from 1 to N
445 * for the order of the args in the array. If dup_markup == '\0', duplicates
446 * are removed otherwise the char is prefixed to the duplicate term and, if it
447 * is an opening paren/bracket/brace, the matching closing char is suffixed.
448 * "none" is removed on the client side unless dup_markup != '\0'. */
449 int get_default_nno_list(struct name_num_obj *nno, char *to_buf, int to_buf_len, char dup_markup)
451 struct name_num_item *nni;
452 int len = 0, cnt = 0;
453 char delim = '\0', post_delim;
455 switch (dup_markup) {
456 case '(': post_delim = ')'; break;
457 case '[': post_delim = ']'; break;
458 case '{': post_delim = '}'; break;
459 default: post_delim = '\0'; break;
462 init_nno_saw(nno, 0);
464 for (nni = nno->list, len = 0; nni->name; nni++) {
465 if (nni->main_name) {
470 if (nni->num == 0 && !am_server && !dup_markup)
475 to_buf[len++]= delim;
478 len += strlcpy(to_buf+len, nni->name, to_buf_len - len);
479 if (len >= to_buf_len - 3)
480 exit_cleanup(RERR_UNSUPPORTED); /* IMPOSSIBLE... */
482 to_buf[len++]= delim;
485 nno->saw[nni->num] = ++cnt;
491 static void send_negotiate_str(int f_out, struct name_num_obj *nno, int ntype)
493 char tmpbuf[MAX_NSTR_STRLEN];
494 const char *list_str = getenv_nstr(ntype);
497 if (list_str && *list_str) {
498 init_nno_saw(nno, 0);
499 len = parse_nni_str(nno, list_str, tmpbuf, MAX_NSTR_STRLEN);
504 if (!list_str || !*list_str)
505 len = get_default_nno_list(nno, tmpbuf, MAX_NSTR_STRLEN, '\0');
507 if (DEBUG_GTE(NSTR, am_server ? 3 : 2)) {
509 rprintf(FINFO, "Server %s list (on server): %s\n", nno->type, tmpbuf);
511 rprintf(FINFO, "Client %s list (on client): %s\n", nno->type, tmpbuf);
514 /* Each side sends their list of valid names to the other side and then both sides
515 * pick the first name in the client's list that is also in the server's list. */
516 if (do_negotiated_strings)
517 write_vstring(f_out, tmpbuf, len);
520 static void negotiate_the_strings(int f_in, int f_out)
522 /* We send all the negotiation strings before we start to read them to help avoid a slow startup. */
524 if (!checksum_choice)
525 send_negotiate_str(f_out, &valid_checksums, NSTR_CHECKSUM);
527 if (do_compression && !compress_choice)
528 send_negotiate_str(f_out, &valid_compressions, NSTR_COMPRESS);
530 if (valid_checksums.saw) {
531 char tmpbuf[MAX_NSTR_STRLEN];
533 if (do_negotiated_strings)
536 len = strlcpy(tmpbuf, protocol_version >= 30 ? "md5" : "md4", MAX_NSTR_STRLEN);
537 recv_negotiate_str(f_in, &valid_checksums, tmpbuf, len);
540 if (valid_compressions.saw) {
541 char tmpbuf[MAX_NSTR_STRLEN];
543 if (do_negotiated_strings)
546 len = strlcpy(tmpbuf, "zlib", MAX_NSTR_STRLEN);
547 recv_negotiate_str(f_in, &valid_compressions, tmpbuf, len);
550 /* If the other side is too old to negotiate, the above steps just made sure that
551 * the env didn't disallow the old algorithm. Mark things as non-negotiated. */
552 if (!do_negotiated_strings)
553 valid_checksums.negotiated_name = valid_compressions.negotiated_name = NULL;
556 void setup_protocol(int f_out,int f_in)
558 assert(file_extra_cnt == 0);
559 assert(EXTRA64_CNT == 2 || EXTRA64_CNT == 1);
561 /* All int64 values must be set first so that they are guaranteed to be
562 * aligned for direct int64-pointer memory access. */
564 atimes_ndx = (file_extra_cnt += EXTRA64_CNT);
565 if (preserve_crtimes)
566 crtimes_ndx = (file_extra_cnt += EXTRA64_CNT);
567 if (am_sender) /* This is most likely in the file_extras64 union as well. */
568 pathname_ndx = (file_extra_cnt += PTR_EXTRA_CNT);
570 depth_ndx = ++file_extra_cnt;
572 uid_ndx = ++file_extra_cnt;
574 gid_ndx = ++file_extra_cnt;
575 if (preserve_acls && !am_sender)
576 acls_ndx = ++file_extra_cnt;
578 xattrs_ndx = ++file_extra_cnt;
581 set_allow_inc_recurse();
583 if (remote_protocol == 0) {
584 if (am_server && !local_server)
585 check_sub_protocol();
587 write_int(f_out, protocol_version);
588 remote_protocol = read_int(f_in);
589 if (protocol_version > remote_protocol)
590 protocol_version = remote_protocol;
592 if (read_batch && remote_protocol > protocol_version) {
593 rprintf(FERROR, "The protocol version in the batch file is too new (%d > %d).\n",
594 remote_protocol, protocol_version);
595 exit_cleanup(RERR_PROTOCOL);
598 if (DEBUG_GTE(PROTO, 1)) {
599 rprintf(FINFO, "(%s) Protocol versions: remote=%d, negotiated=%d\n",
600 am_server? "Server" : "Client", remote_protocol, protocol_version);
602 if (remote_protocol < MIN_PROTOCOL_VERSION
603 || remote_protocol > MAX_PROTOCOL_VERSION) {
604 rprintf(FERROR,"protocol version mismatch -- is your shell clean?\n");
605 rprintf(FERROR,"(see the rsync man page for an explanation)\n");
606 exit_cleanup(RERR_PROTOCOL);
608 if (remote_protocol < OLD_PROTOCOL_VERSION) {
609 rprintf(FINFO,"%s is very old version of rsync, upgrade recommended.\n",
610 am_server? "Client" : "Server");
612 if (protocol_version < MIN_PROTOCOL_VERSION) {
613 rprintf(FERROR, "--protocol must be at least %d on the %s.\n",
614 MIN_PROTOCOL_VERSION, am_server? "Server" : "Client");
615 exit_cleanup(RERR_PROTOCOL);
617 if (protocol_version > PROTOCOL_VERSION) {
618 rprintf(FERROR, "--protocol must be no more than %d on the %s.\n",
619 PROTOCOL_VERSION, am_server? "Server" : "Client");
620 exit_cleanup(RERR_PROTOCOL);
625 #ifndef SUPPORT_PREALLOCATION
626 if (preallocate_files && !am_sender) {
627 rprintf(FERROR, "preallocation is not supported on this %s\n",
628 am_server ? "Server" : "Client");
629 exit_cleanup(RERR_SYNTAX);
633 if (protocol_version < 30) {
634 if (append_mode == 1)
636 if (preserve_acls && !local_server) {
638 "--acls requires protocol 30 or higher"
639 " (negotiated %d).\n",
641 exit_cleanup(RERR_PROTOCOL);
643 if (preserve_xattrs && !local_server) {
645 "--xattrs requires protocol 30 or higher"
646 " (negotiated %d).\n",
648 exit_cleanup(RERR_PROTOCOL);
652 if (delete_mode && !(delete_before+delete_during+delete_after)) {
653 if (protocol_version < 30)
659 if (protocol_version < 29) {
662 "--fuzzy requires protocol 29 or higher"
663 " (negotiated %d).\n",
665 exit_cleanup(RERR_PROTOCOL);
668 if (basis_dir_cnt && inplace) {
670 "%s with --inplace requires protocol 29 or higher"
671 " (negotiated %d).\n",
672 alt_dest_opt(0), protocol_version);
673 exit_cleanup(RERR_PROTOCOL);
676 if (basis_dir_cnt > 1) {
678 "Using more than one %s option requires protocol"
679 " 29 or higher (negotiated %d).\n",
680 alt_dest_opt(0), protocol_version);
681 exit_cleanup(RERR_PROTOCOL);
684 if (prune_empty_dirs) {
686 "--prune-empty-dirs requires protocol 29 or higher"
687 " (negotiated %d).\n",
689 exit_cleanup(RERR_PROTOCOL);
691 } else if (protocol_version >= 30) {
693 compat_flags = allow_inc_recurse ? CF_INC_RECURSE : 0;
694 #ifdef CAN_SET_SYMLINK_TIMES
695 compat_flags |= CF_SYMLINK_TIMES;
698 compat_flags |= CF_SYMLINK_ICONV;
700 if (strchr(client_info, 'f') != NULL)
701 compat_flags |= CF_SAFE_FLIST;
702 if (strchr(client_info, 'x') != NULL)
703 compat_flags |= CF_AVOID_XATTR_OPTIM;
704 if (strchr(client_info, 'C') != NULL)
705 compat_flags |= CF_CHKSUM_SEED_FIX;
706 if (strchr(client_info, 'I') != NULL)
707 compat_flags |= CF_INPLACE_PARTIAL_DIR;
708 if (strchr(client_info, 'u') != NULL)
709 compat_flags |= CF_ID0_NAMES;
710 if (strchr(client_info, 'v') != NULL) {
711 do_negotiated_strings = 1;
712 compat_flags |= CF_VARINT_FLIST_FLAGS;
714 if (strchr(client_info, 'V') != NULL) { /* Support a pre-release 'V' that got superseded */
716 compat_flags |= CF_VARINT_FLIST_FLAGS;
717 write_byte(f_out, compat_flags);
719 write_varint(f_out, compat_flags);
720 } else { /* read_varint() is compatible with the older write_byte() when the 0x80 bit isn't on. */
721 compat_flags = read_varint(f_in);
722 if (compat_flags & CF_VARINT_FLIST_FLAGS)
723 do_negotiated_strings = 1;
725 /* The inc_recurse var MUST be set to 0 or 1. */
726 inc_recurse = compat_flags & CF_INC_RECURSE ? 1 : 0;
727 want_xattr_optim = protocol_version >= 31 && !(compat_flags & CF_AVOID_XATTR_OPTIM);
728 proper_seed_order = compat_flags & CF_CHKSUM_SEED_FIX ? 1 : 0;
729 xfer_flags_as_varint = compat_flags & CF_VARINT_FLIST_FLAGS ? 1 : 0;
730 xmit_id0_names = compat_flags & CF_ID0_NAMES ? 1 : 0;
731 if (!xfer_flags_as_varint && preserve_crtimes) {
732 fprintf(stderr, "Both rsync versions must be at least 3.2.0 for --crtimes.\n");
733 exit_cleanup(RERR_PROTOCOL);
736 receiver_symlink_times = am_server
737 ? strchr(client_info, 'L') != NULL
738 : !!(compat_flags & CF_SYMLINK_TIMES);
740 #ifdef CAN_SET_SYMLINK_TIMES
742 receiver_symlink_times = 1;
745 sender_symlink_iconv = iconv_opt && (am_server
746 ? strchr(client_info, 's') != NULL
747 : !!(compat_flags & CF_SYMLINK_ICONV));
749 if (inc_recurse && !allow_inc_recurse) {
750 /* This should only be able to happen in a batch. */
752 "Incompatible options specified for inc-recursive %s.\n",
753 read_batch ? "batch file" : "connection");
754 exit_cleanup(RERR_SYNTAX);
756 use_safe_inc_flist = (compat_flags & CF_SAFE_FLIST) || protocol_version >= 31;
757 need_messages_from_generator = 1;
758 if (compat_flags & CF_INPLACE_PARTIAL_DIR)
760 #ifdef CAN_SET_SYMLINK_TIMES
761 } else if (!am_sender) {
762 receiver_symlink_times = 1;
767 do_negotiated_strings = 0;
769 if (need_unsorted_flist && (!am_sender || inc_recurse))
770 unsort_ndx = ++file_extra_cnt;
772 if (partial_dir && *partial_dir != '/' && (!am_server || local_server)) {
773 int rflags = FILTRULE_NO_PREFIXES | FILTRULE_DIRECTORY;
774 if (!am_sender || protocol_version >= 30)
775 rflags |= FILTRULE_PERISHABLE;
776 parse_filter_str(&filter_list, partial_dir, rule_template(rflags), 0);
781 if (protect_args && files_from) {
783 filesfrom_convert = filesfrom_host && ic_send != (iconv_t)-1;
785 filesfrom_convert = !filesfrom_host && ic_recv != (iconv_t)-1;
789 negotiate_the_strings(f_in, f_out);
793 checksum_seed = time(NULL) ^ (getpid() << 6);
794 write_int(f_out, checksum_seed);
796 checksum_seed = read_int(f_in);
799 parse_checksum_choice(1); /* Sets checksum_type & xfersum_type */
800 parse_compress_choice(1); /* Sets do_compression */
802 if (write_batch && !am_server)
803 write_batch_shell_file();