2 * Compatibility routines for older rsync protocol versions.
4 * Copyright (C) Andrew Tridgell 1996
5 * Copyright (C) Paul Mackerras 1996
6 * Copyright (C) 2004-2022 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 int saw_stderr_opt;
56 extern int msgs2stderr;
57 extern char *shell_cmd;
58 extern char *partial_dir;
59 extern char *files_from;
60 extern char *filesfrom_host;
61 extern const char *checksum_choice;
62 extern const char *compress_choice;
63 extern filter_rule_list filter_list;
64 extern int need_unsorted_flist;
66 extern iconv_t ic_send, ic_recv;
67 extern char *iconv_opt;
69 extern struct name_num_obj valid_checksums;
71 int remote_protocol = 0;
72 int file_extra_cnt = 0; /* count of file-list extras that everyone gets */
75 int use_safe_inc_flist = 0;
76 int want_xattr_optim = 0;
77 int proper_seed_order = 0;
78 int inplace_partial = 0;
79 int do_negotiated_strings = 0;
80 int xmit_id0_names = 0;
82 /* These index values are for the file-list's extra-attribute array. */
83 int pathname_ndx, depth_ndx, atimes_ndx, crtimes_ndx, uid_ndx, gid_ndx, acls_ndx, xattrs_ndx, unsort_ndx;
85 int receiver_symlink_times = 0; /* receiver can set the time on a symlink */
86 int sender_symlink_iconv = 0; /* sender should convert symlink content */
89 int filesfrom_convert = 0;
92 #define MAX_NSTR_STRLEN 256
94 struct name_num_item valid_compressions_items[] = {
96 { CPRES_ZSTD, "zstd", NULL },
99 { CPRES_LZ4, "lz4", NULL },
101 { CPRES_ZLIBX, "zlibx", NULL },
102 { CPRES_ZLIB, "zlib", NULL },
103 { CPRES_NONE, "none", NULL },
107 struct name_num_obj valid_compressions = {
108 "compress", NULL, NULL, 0, 0, valid_compressions_items
111 #define CF_INC_RECURSE (1<<0)
112 #define CF_SYMLINK_TIMES (1<<1)
113 #define CF_SYMLINK_ICONV (1<<2)
114 #define CF_SAFE_FLIST (1<<3)
115 #define CF_AVOID_XATTR_OPTIM (1<<4)
116 #define CF_CHKSUM_SEED_FIX (1<<5)
117 #define CF_INPLACE_PARTIAL_DIR (1<<6)
118 #define CF_VARINT_FLIST_FLAGS (1<<7)
119 #define CF_ID0_NAMES (1<<8)
121 static const char *client_info;
123 /* The server makes sure that if either side only supports a pre-release
124 * version of a protocol, that both sides must speak a compatible version
125 * of that protocol for it to be advertised as available. */
126 static void check_sub_protocol(void)
129 int their_protocol, their_sub;
130 #if SUBPROTOCOL_VERSION != 0
131 int our_sub = protocol_version < PROTOCOL_VERSION ? 0 : SUBPROTOCOL_VERSION;
136 /* client_info starts with VER.SUB string if client is a pre-release. */
137 if (!(their_protocol = atoi(client_info))
138 || !(dot = strchr(client_info, '.'))
139 || !(their_sub = atoi(dot+1))) {
140 #if SUBPROTOCOL_VERSION != 0
147 if (their_protocol < protocol_version) {
149 protocol_version = their_protocol - 1;
153 if (their_protocol > protocol_version)
154 their_sub = 0; /* 0 == final version of older protocol */
155 if (their_sub != our_sub)
159 void set_allow_inc_recurse(void)
162 client_info = shell_cmd ? shell_cmd : "";
163 else if (am_server) {
165 maybe_add_e_option(buf, sizeof buf);
166 client_info = *buf ? strdup(buf+1) : ""; /* The +1 skips the leading "e". */
169 if (!recurse || use_qsort)
170 allow_inc_recurse = 0;
172 && (delete_before || delete_after
173 || delay_updates || prune_empty_dirs))
174 allow_inc_recurse = 0;
175 else if (am_server && strchr(client_info, 'i') == NULL)
176 allow_inc_recurse = 0;
179 void parse_compress_choice(int final_call)
181 if (valid_compressions.negotiated_name)
182 do_compression = valid_compressions.negotiated_num;
183 else if (compress_choice) {
184 struct name_num_item *nni = get_nni_by_name(&valid_compressions, compress_choice, -1);
186 rprintf(FERROR, "unknown compress name: %s\n", compress_choice);
187 exit_cleanup(RERR_UNSUPPORTED);
189 do_compression = nni->num;
191 validate_choice_vs_env(NSTR_COMPRESS, do_compression, -1);
192 } else if (do_compression)
193 do_compression = CPRES_ZLIB;
195 do_compression = CPRES_NONE;
197 if (do_compression != CPRES_NONE && final_call)
198 init_compression_level(); /* There's a chance this might turn compression off! */
200 if (do_compression == CPRES_NONE)
201 compress_choice = NULL;
203 /* Snag the compression name for both write_batch's option output & the following debug output. */
204 if (valid_compressions.negotiated_name)
205 compress_choice = valid_compressions.negotiated_name;
206 else if (compress_choice == NULL) {
207 struct name_num_item *nni = get_nni_by_num(&valid_compressions, do_compression);
208 compress_choice = nni ? nni->name : "UNKNOWN";
211 if (final_call && DEBUG_GTE(NSTR, am_server ? 3 : 1)
212 && (do_compression != CPRES_NONE || do_compression_level != CLVL_NOT_SPECIFIED)) {
213 rprintf(FINFO, "%s%s compress: %s (level %d)\n",
214 am_server ? "Server" : "Client",
215 valid_compressions.negotiated_name ? " negotiated" : "",
216 compress_choice, do_compression_level);
220 struct name_num_item *get_nni_by_name(struct name_num_obj *nno, const char *name, int len)
222 struct name_num_item *nni;
227 for (nni = nno->list; nni->name; nni++) {
228 if (strncasecmp(name, nni->name, len) == 0 && nni->name[len] == '\0')
235 struct name_num_item *get_nni_by_num(struct name_num_obj *nno, int num)
237 struct name_num_item *nni;
239 for (nni = nno->list; nni->name; nni++) {
247 static void init_nno_saw(struct name_num_obj *nno, int val)
249 struct name_num_item *nni;
253 for (nni = nno->list; nni->name; nni++) {
254 if (nni->num >= nno->saw_len)
255 nno->saw_len = nni->num + 1;
260 nno->saw = new_array0(uchar, nno->saw_len);
262 /* We'll take this opportunity to make sure that the main_name values are set right. */
263 for (cnt = 1, nni = nno->list; nni->name; nni++, cnt++) {
264 if (nno->saw[nni->num])
265 nni->main_name = nno->list[nno->saw[nni->num]-1].name;
267 nno->saw[nni->num] = cnt;
271 memset(nno->saw, val, nno->saw_len);
274 /* Simplify the user-provided string so that it contains valid names without any duplicates.
275 * It also sets the "saw" flags to a 1-relative count of which name was seen first. */
276 static int parse_nni_str(struct name_num_obj *nno, const char *from, char *tobuf, int tobuf_len)
278 char *to = tobuf, *tok = NULL;
279 int saw_tok = 0, cnt = 0;
282 int at_space = isSpace(from);
286 if (!ch || at_space) {
288 struct name_num_item *nni = get_nni_by_name(nno, tok, to - tok);
289 if (nni && !nno->saw[nni->num]) {
290 nno->saw[nni->num] = ++cnt;
291 if (nni->main_name) {
292 to = tok + strlcpy(tok, nni->main_name, tobuf_len - (tok - tobuf));
293 if (to - tobuf >= tobuf_len) {
299 to = tok - (tok != tobuf);
312 if (to - tobuf >= tobuf_len - 1) {
313 to = tok - (tok != tobuf);
320 if (saw_tok && to == tobuf)
321 return strlcpy(tobuf, "INVALID", MAX_NSTR_STRLEN);
326 /* This routine is always called with a tmpbuf of MAX_NSTR_STRLEN length, but the
327 * buffer may be pre-populated with a "len" length string to use OR a len of -1
328 * to tell us to read a string from the fd. */
329 static void recv_negotiate_str(int f_in, struct name_num_obj *nno, char *tmpbuf, int len)
331 struct name_num_item *ret = NULL;
334 len = read_vstring(f_in, tmpbuf, MAX_NSTR_STRLEN);
336 if (DEBUG_GTE(NSTR, am_server ? 3 : 2)) {
338 rprintf(FINFO, "Client %s list (on server): %s\n", nno->type, tmpbuf);
340 rprintf(FINFO, "Server %s list (on client): %s\n", nno->type, tmpbuf);
344 struct name_num_item *nni;
345 int best = nno->saw_len; /* We want best == 1 from the client list, so start with a big number. */
346 char *space, *tok = tmpbuf;
348 while (*tok == ' ') tok++; /* Should be unneeded... */
351 if ((space = strchr(tok, ' ')) != NULL)
353 nni = get_nni_by_name(nno, tok, -1);
359 if (!nni || !nno->saw[nni->num] || best <= nno->saw[nni->num])
362 best = nno->saw[nni->num];
363 if (best == 1 || am_server) /* The server side stops at the first acceptable client choice */
369 nno->negotiated_name = ret->main_name ? ret->main_name : ret->name;
370 nno->negotiated_num = ret->num;
375 if (!am_server || !do_negotiated_strings) {
378 rprintf(FERROR, "Failed to negotiate a %s choice.\n", nno->type);
379 rprintf(FERROR, "%s list: %s\n", am_server ? "Client" : "Server", tmpbuf);
380 /* Recreate our original list from the saw values. This can't overflow our huge
381 * buffer because we don't have enough valid entries to get anywhere close. */
382 for (j = 1, *cp = '\0'; j <= nno->saw_len; j++) {
383 struct name_num_item *nni;
384 for (nni = nno->list; nni->name; nni++) {
385 if (nno->saw[nni->num] == j) {
387 cp += strlcpy(cp, nni->name, MAX_NSTR_STRLEN - (cp - tmpbuf));
393 strlcpy(cp, " INVALID", MAX_NSTR_STRLEN);
394 rprintf(FERROR, "%s list:%s\n", am_server ? "Server" : "Client", tmpbuf);
397 exit_cleanup(RERR_UNSUPPORTED);
400 static const char *getenv_nstr(int ntype)
402 const char *env_str = getenv(ntype == NSTR_COMPRESS ? "RSYNC_COMPRESS_LIST" : "RSYNC_CHECKSUM_LIST");
404 /* When writing a batch file, we always negotiate an old-style choice. */
406 env_str = ntype == NSTR_COMPRESS ? "zlib" : protocol_version >= 30 ? "md5" : "md4";
408 if (am_server && env_str) {
409 char *cp = strchr(env_str, '&');
417 void validate_choice_vs_env(int ntype, int num1, int num2)
419 struct name_num_obj *nno = ntype == NSTR_COMPRESS ? &valid_compressions : &valid_checksums;
420 const char *list_str = getenv_nstr(ntype);
421 char tmpbuf[MAX_NSTR_STRLEN];
426 while (isSpace(list_str)) list_str++;
431 init_nno_saw(nno, 0);
432 parse_nni_str(nno, list_str, tmpbuf, MAX_NSTR_STRLEN);
434 if (ntype == NSTR_CHECKSUM) /* If "md4" is in the env list, all the old MD4 choices are OK too. */
435 nno->saw[CSUM_MD4_ARCHAIC] = nno->saw[CSUM_MD4_BUSTED] = nno->saw[CSUM_MD4_OLD] = nno->saw[CSUM_MD4];
437 if (!nno->saw[num1] || (num2 >= 0 && !nno->saw[num2])) {
438 rprintf(FERROR, "Your --%s-choice value (%s) was refused by the server.\n",
439 ntype == NSTR_COMPRESS ? "compress" : "checksum",
440 ntype == NSTR_COMPRESS ? compress_choice : checksum_choice);
441 exit_cleanup(RERR_UNSUPPORTED);
448 /* The saw buffer is initialized and used to store ordinal values from 1 to N
449 * for the order of the args in the array. If dup_markup == '\0', duplicates
450 * are removed otherwise the char is prefixed to the duplicate term and, if it
451 * is an opening paren/bracket/brace, the matching closing char is suffixed.
452 * "none" is removed on the client side unless dup_markup != '\0'. */
453 int get_default_nno_list(struct name_num_obj *nno, char *to_buf, int to_buf_len, char dup_markup)
455 struct name_num_item *nni;
456 int len = 0, cnt = 0;
457 char delim = '\0', post_delim;
459 switch (dup_markup) {
460 case '(': post_delim = ')'; break;
461 case '[': post_delim = ']'; break;
462 case '{': post_delim = '}'; break;
463 default: post_delim = '\0'; break;
466 init_nno_saw(nno, 0);
468 for (nni = nno->list, len = 0; nni->name; nni++) {
469 if (nni->main_name) {
474 if (nni->num == 0 && !am_server && !dup_markup)
479 to_buf[len++]= delim;
482 len += strlcpy(to_buf+len, nni->name, to_buf_len - len);
483 if (len >= to_buf_len - 3)
484 exit_cleanup(RERR_UNSUPPORTED); /* IMPOSSIBLE... */
486 to_buf[len++]= delim;
489 nno->saw[nni->num] = ++cnt;
495 static void send_negotiate_str(int f_out, struct name_num_obj *nno, int ntype)
497 char tmpbuf[MAX_NSTR_STRLEN];
498 const char *list_str = getenv_nstr(ntype);
501 if (list_str && *list_str) {
502 init_nno_saw(nno, 0);
503 len = parse_nni_str(nno, list_str, tmpbuf, MAX_NSTR_STRLEN);
508 if (!list_str || !*list_str)
509 len = get_default_nno_list(nno, tmpbuf, MAX_NSTR_STRLEN, '\0');
511 if (DEBUG_GTE(NSTR, am_server ? 3 : 2)) {
513 rprintf(FINFO, "Server %s list (on server): %s\n", nno->type, tmpbuf);
515 rprintf(FINFO, "Client %s list (on client): %s\n", nno->type, tmpbuf);
518 /* Each side sends their list of valid names to the other side and then both sides
519 * pick the first name in the client's list that is also in the server's list. */
520 if (do_negotiated_strings)
521 write_vstring(f_out, tmpbuf, len);
524 static void negotiate_the_strings(int f_in, int f_out)
526 /* We send all the negotiation strings before we start to read them to help avoid a slow startup. */
528 init_checksum_choices();
530 if (!checksum_choice)
531 send_negotiate_str(f_out, &valid_checksums, NSTR_CHECKSUM);
533 if (do_compression && !compress_choice)
534 send_negotiate_str(f_out, &valid_compressions, NSTR_COMPRESS);
536 if (valid_checksums.saw) {
537 char tmpbuf[MAX_NSTR_STRLEN];
539 if (do_negotiated_strings)
542 len = strlcpy(tmpbuf, protocol_version >= 30 ? "md5" : "md4", MAX_NSTR_STRLEN);
543 recv_negotiate_str(f_in, &valid_checksums, tmpbuf, len);
546 if (valid_compressions.saw) {
547 char tmpbuf[MAX_NSTR_STRLEN];
549 if (do_negotiated_strings)
552 len = strlcpy(tmpbuf, "zlib", MAX_NSTR_STRLEN);
553 recv_negotiate_str(f_in, &valid_compressions, tmpbuf, len);
556 /* If the other side is too old to negotiate, the above steps just made sure that
557 * the env didn't disallow the old algorithm. Mark things as non-negotiated. */
558 if (!do_negotiated_strings)
559 valid_checksums.negotiated_name = valid_compressions.negotiated_name = NULL;
562 void setup_protocol(int f_out,int f_in)
564 assert(file_extra_cnt == 0);
565 assert(EXTRA64_CNT == 2 || EXTRA64_CNT == 1);
567 /* All int64 values must be set first so that they are guaranteed to be
568 * aligned for direct int64-pointer memory access. */
570 atimes_ndx = (file_extra_cnt += EXTRA64_CNT);
571 if (preserve_crtimes)
572 crtimes_ndx = (file_extra_cnt += EXTRA64_CNT);
573 if (am_sender) /* This is most likely in the file_extras64 union as well. */
574 pathname_ndx = (file_extra_cnt += PTR_EXTRA_CNT);
576 depth_ndx = ++file_extra_cnt;
578 uid_ndx = ++file_extra_cnt;
580 gid_ndx = ++file_extra_cnt;
581 if (preserve_acls && !am_sender)
582 acls_ndx = ++file_extra_cnt;
584 xattrs_ndx = ++file_extra_cnt;
587 set_allow_inc_recurse();
589 if (remote_protocol == 0) {
590 if (am_server && !local_server)
591 check_sub_protocol();
593 write_int(f_out, protocol_version);
594 remote_protocol = read_int(f_in);
595 if (protocol_version > remote_protocol)
596 protocol_version = remote_protocol;
598 if (read_batch && remote_protocol > protocol_version) {
599 rprintf(FERROR, "The protocol version in the batch file is too new (%d > %d).\n",
600 remote_protocol, protocol_version);
601 exit_cleanup(RERR_PROTOCOL);
604 if (DEBUG_GTE(PROTO, 1)) {
605 rprintf(FINFO, "(%s) Protocol versions: remote=%d, negotiated=%d\n",
606 am_server? "Server" : "Client", remote_protocol, protocol_version);
608 if (remote_protocol < MIN_PROTOCOL_VERSION
609 || remote_protocol > MAX_PROTOCOL_VERSION) {
610 rprintf(FERROR,"protocol version mismatch -- is your shell clean?\n");
611 rprintf(FERROR,"(see the rsync manpage for an explanation)\n");
612 exit_cleanup(RERR_PROTOCOL);
614 if (remote_protocol < OLD_PROTOCOL_VERSION) {
615 rprintf(FINFO,"%s is very old version of rsync, upgrade recommended.\n",
616 am_server? "Client" : "Server");
618 if (protocol_version < MIN_PROTOCOL_VERSION) {
619 rprintf(FERROR, "--protocol must be at least %d on the %s.\n",
620 MIN_PROTOCOL_VERSION, am_server? "Server" : "Client");
621 exit_cleanup(RERR_PROTOCOL);
623 if (protocol_version > PROTOCOL_VERSION) {
624 rprintf(FERROR, "--protocol must be no more than %d on the %s.\n",
625 PROTOCOL_VERSION, am_server? "Server" : "Client");
626 exit_cleanup(RERR_PROTOCOL);
631 if (!saw_stderr_opt && protocol_version <= 28 && am_server)
632 msgs2stderr = 0; /* The client side may not have stderr setup for us. */
634 #ifndef SUPPORT_PREALLOCATION
635 if (preallocate_files && !am_sender) {
636 rprintf(FERROR, "preallocation is not supported on this %s\n",
637 am_server ? "Server" : "Client");
638 exit_cleanup(RERR_SYNTAX);
642 if (protocol_version < 30) {
643 if (append_mode == 1)
645 if (preserve_acls && !local_server) {
647 "--acls requires protocol 30 or higher"
648 " (negotiated %d).\n",
650 exit_cleanup(RERR_PROTOCOL);
652 if (preserve_xattrs && !local_server) {
654 "--xattrs requires protocol 30 or higher"
655 " (negotiated %d).\n",
657 exit_cleanup(RERR_PROTOCOL);
661 if (delete_mode && !(delete_before+delete_during+delete_after)) {
662 if (protocol_version < 30)
668 if (protocol_version < 29) {
671 "--fuzzy requires protocol 29 or higher"
672 " (negotiated %d).\n",
674 exit_cleanup(RERR_PROTOCOL);
677 if (basis_dir_cnt && inplace) {
679 "%s with --inplace requires protocol 29 or higher"
680 " (negotiated %d).\n",
681 alt_dest_opt(0), protocol_version);
682 exit_cleanup(RERR_PROTOCOL);
685 if (basis_dir_cnt > 1) {
687 "Using more than one %s option requires protocol"
688 " 29 or higher (negotiated %d).\n",
689 alt_dest_opt(0), protocol_version);
690 exit_cleanup(RERR_PROTOCOL);
693 if (prune_empty_dirs) {
695 "--prune-empty-dirs requires protocol 29 or higher"
696 " (negotiated %d).\n",
698 exit_cleanup(RERR_PROTOCOL);
700 } else if (protocol_version >= 30) {
702 compat_flags = allow_inc_recurse ? CF_INC_RECURSE : 0;
703 #ifdef CAN_SET_SYMLINK_TIMES
704 compat_flags |= CF_SYMLINK_TIMES;
707 compat_flags |= CF_SYMLINK_ICONV;
709 if (strchr(client_info, 'f') != NULL)
710 compat_flags |= CF_SAFE_FLIST;
711 if (strchr(client_info, 'x') != NULL)
712 compat_flags |= CF_AVOID_XATTR_OPTIM;
713 if (strchr(client_info, 'C') != NULL)
714 compat_flags |= CF_CHKSUM_SEED_FIX;
715 if (strchr(client_info, 'I') != NULL)
716 compat_flags |= CF_INPLACE_PARTIAL_DIR;
717 if (strchr(client_info, 'u') != NULL)
718 compat_flags |= CF_ID0_NAMES;
719 if (strchr(client_info, 'v') != NULL) {
720 do_negotiated_strings = 1;
721 compat_flags |= CF_VARINT_FLIST_FLAGS;
723 if (strchr(client_info, 'V') != NULL) { /* Support a pre-release 'V' that got superseded */
725 compat_flags |= CF_VARINT_FLIST_FLAGS;
726 write_byte(f_out, compat_flags);
728 write_varint(f_out, compat_flags);
729 } else { /* read_varint() is compatible with the older write_byte() when the 0x80 bit isn't on. */
730 compat_flags = read_varint(f_in);
731 if (compat_flags & CF_VARINT_FLIST_FLAGS)
732 do_negotiated_strings = 1;
734 /* The inc_recurse var MUST be set to 0 or 1. */
735 inc_recurse = compat_flags & CF_INC_RECURSE ? 1 : 0;
736 want_xattr_optim = protocol_version >= 31 && !(compat_flags & CF_AVOID_XATTR_OPTIM);
737 proper_seed_order = compat_flags & CF_CHKSUM_SEED_FIX ? 1 : 0;
738 xfer_flags_as_varint = compat_flags & CF_VARINT_FLIST_FLAGS ? 1 : 0;
739 xmit_id0_names = compat_flags & CF_ID0_NAMES ? 1 : 0;
740 if (!xfer_flags_as_varint && preserve_crtimes) {
741 fprintf(stderr, "Both rsync versions must be at least 3.2.0 for --crtimes.\n");
742 exit_cleanup(RERR_PROTOCOL);
745 receiver_symlink_times = am_server
746 ? strchr(client_info, 'L') != NULL
747 : !!(compat_flags & CF_SYMLINK_TIMES);
749 #ifdef CAN_SET_SYMLINK_TIMES
751 receiver_symlink_times = 1;
754 sender_symlink_iconv = iconv_opt && (am_server
755 ? strchr(client_info, 's') != NULL
756 : !!(compat_flags & CF_SYMLINK_ICONV));
758 if (inc_recurse && !allow_inc_recurse) {
759 /* This should only be able to happen in a batch. */
761 "Incompatible options specified for inc-recursive %s.\n",
762 read_batch ? "batch file" : "connection");
763 exit_cleanup(RERR_SYNTAX);
765 use_safe_inc_flist = (compat_flags & CF_SAFE_FLIST) || protocol_version >= 31;
766 need_messages_from_generator = 1;
767 if (compat_flags & CF_INPLACE_PARTIAL_DIR)
769 #ifdef CAN_SET_SYMLINK_TIMES
770 } else if (!am_sender) {
771 receiver_symlink_times = 1;
776 do_negotiated_strings = 0;
778 if (need_unsorted_flist && (!am_sender || inc_recurse))
779 unsort_ndx = ++file_extra_cnt;
781 if (partial_dir && *partial_dir != '/' && (!am_server || local_server)) {
782 int rflags = FILTRULE_NO_PREFIXES | FILTRULE_DIRECTORY;
783 if (!am_sender || protocol_version >= 30)
784 rflags |= FILTRULE_PERISHABLE;
785 parse_filter_str(&filter_list, partial_dir, rule_template(rflags), 0);
790 if (protect_args && files_from) {
792 filesfrom_convert = filesfrom_host && ic_send != (iconv_t)-1;
794 filesfrom_convert = !filesfrom_host && ic_recv != (iconv_t)-1;
798 negotiate_the_strings(f_in, f_out);
802 checksum_seed = time(NULL) ^ (getpid() << 6);
803 write_int(f_out, checksum_seed);
805 checksum_seed = read_int(f_in);
808 parse_checksum_choice(1); /* Sets checksum_type & xfersum_type */
809 parse_compress_choice(1); /* Sets do_compression */
811 if (write_batch && !am_server)
812 write_batch_shell_file();