Add support for negotiated checksum names.
[rsync.git] / compat.c
1 /*
2  * Compatibility routines for older rsync protocol versions.
3  *
4  * Copyright (C) Andrew Tridgell 1996
5  * Copyright (C) Paul Mackerras 1996
6  * Copyright (C) 2004-2020 Wayne Davison
7  *
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.
12  *
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.
17  *
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.
20  */
21
22 #include "rsync.h"
23
24 extern int am_server;
25 extern int am_sender;
26 extern int local_server;
27 extern int inplace;
28 extern int recurse;
29 extern int use_qsort;
30 extern int allow_inc_recurse;
31 extern int preallocate_files;
32 extern int append_mode;
33 extern int fuzzy_basis;
34 extern int read_batch;
35 extern int write_batch;
36 extern int delay_updates;
37 extern int checksum_seed;
38 extern int basis_dir_cnt;
39 extern int prune_empty_dirs;
40 extern int protocol_version;
41 extern int protect_args;
42 extern int preserve_uid;
43 extern int preserve_gid;
44 extern int preserve_atimes;
45 extern int preserve_acls;
46 extern int preserve_xattrs;
47 extern int xfer_flags_as_varint;
48 extern int need_messages_from_generator;
49 extern int delete_mode, delete_before, delete_during, delete_after;
50 extern int xfersum_type;
51 extern int checksum_type;
52 extern int do_compression;
53 extern char *shell_cmd;
54 extern char *partial_dir;
55 extern char *dest_option;
56 extern char *files_from;
57 extern char *filesfrom_host;
58 extern char *checksum_choice;
59 extern char *compress_choice;
60 extern filter_rule_list filter_list;
61 extern int need_unsorted_flist;
62 #ifdef ICONV_OPTION
63 extern iconv_t ic_send, ic_recv;
64 extern char *iconv_opt;
65 #endif
66 extern struct name_num_obj valid_checksums;
67
68 int remote_protocol = 0;
69 int file_extra_cnt = 0; /* count of file-list extras that everyone gets */
70 int inc_recurse = 0;
71 int compat_flags = 0;
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
78 /* These index values are for the file-list's extra-attribute array. */
79 int pathname_ndx, depth_ndx, atimes_ndx, uid_ndx, gid_ndx, acls_ndx, xattrs_ndx, unsort_ndx;
80
81 int receiver_symlink_times = 0; /* receiver can set the time on a symlink */
82 int sender_symlink_iconv = 0;   /* sender should convert symlink content */
83
84 #ifdef ICONV_OPTION
85 int filesfrom_convert = 0;
86 #endif
87
88 #define MAX_NSTR_STRLEN 256
89
90 #define CPRES_NONE 0
91 #define CPRES_ZLIB 1
92
93 struct name_num_obj valid_compressions = {
94         "compress", NULL, NULL, 0, 0, {
95                 { CPRES_ZLIB, "zlib", NULL },
96                 { CPRES_NONE, "none", "" }, /* The "" prevents us from listing this name by default */
97                 { 0, NULL, NULL }
98         }
99 };
100
101 #define CF_INC_RECURSE   (1<<0)
102 #define CF_SYMLINK_TIMES (1<<1)
103 #define CF_SYMLINK_ICONV (1<<2)
104 #define CF_SAFE_FLIST    (1<<3)
105 #define CF_AVOID_XATTR_OPTIM (1<<4)
106 #define CF_CHKSUM_SEED_FIX (1<<5)
107 #define CF_INPLACE_PARTIAL_DIR (1<<6)
108 #define CF_VARINT_FLIST_FLAGS (1<<7)
109
110 static const char *client_info;
111
112 /* The server makes sure that if either side only supports a pre-release
113  * version of a protocol, that both sides must speak a compatible version
114  * of that protocol for it to be advertised as available. */
115 static void check_sub_protocol(void)
116 {
117         char *dot;
118         int their_protocol, their_sub;
119 #if SUBPROTOCOL_VERSION != 0
120         int our_sub = protocol_version < PROTOCOL_VERSION ? 0 : SUBPROTOCOL_VERSION;
121 #else
122         int our_sub = 0;
123 #endif
124
125         /* client_info starts with VER.SUB string if client is a pre-release. */
126         if (!(their_protocol = atoi(client_info))
127          || !(dot = strchr(client_info, '.'))
128          || !(their_sub = atoi(dot+1))) {
129 #if SUBPROTOCOL_VERSION != 0
130                 if (our_sub)
131                         protocol_version--;
132 #endif
133                 return;
134         }
135
136         if (their_protocol < protocol_version) {
137                 if (their_sub)
138                         protocol_version = their_protocol - 1;
139                 return;
140         }
141
142         if (their_protocol > protocol_version)
143                 their_sub = 0; /* 0 == final version of older protocol */
144         if (their_sub != our_sub)
145                 protocol_version--;
146 }
147
148 void set_allow_inc_recurse(void)
149 {
150         client_info = shell_cmd ? shell_cmd : "";
151
152         if (!recurse || use_qsort)
153                 allow_inc_recurse = 0;
154         else if (!am_sender
155          && (delete_before || delete_after
156           || delay_updates || prune_empty_dirs))
157                 allow_inc_recurse = 0;
158         else if (am_server && !local_server
159          && (strchr(client_info, 'i') == NULL))
160                 allow_inc_recurse = 0;
161 }
162
163 struct name_num_item *get_nni_by_name(struct name_num_obj *nno, const char *name, int len)
164 {
165         struct name_num_item *nni;
166
167         if (len < 0)
168                 len = strlen(name);
169
170         for (nni = nno->list; nni->name; nni++) {
171                 if (strncasecmp(name, nni->name, len) == 0 && nni->name[len] == '\0')
172                         return nni;
173         }
174
175         return NULL;
176 }
177
178 struct name_num_item *get_nni_by_num(struct name_num_obj *nno, int num)
179 {
180         struct name_num_item *nni;
181
182         for (nni = nno->list; nni->name; nni++) {
183                 if (num == nni->num)
184                         return nni;
185         }
186
187         return NULL;
188 }
189
190 static void init_nno_saw(struct name_num_obj *nno, int val)
191 {
192         struct name_num_item *nni;
193         int cnt;
194
195         if (!nno->saw_len) {
196                 for (nni = nno->list; nni->name; nni++) {
197                         if (nni->num >= nno->saw_len)
198                                 nno->saw_len = nni->num + 1;
199                 }
200         }
201
202         if (!nno->saw) {
203                 if (!(nno->saw = new_array0(uchar, nno->saw_len)))
204                         out_of_memory("init_nno_saw");
205
206                 /* We'll take this opportunity to make sure that the main_name values are set right. */
207                 for (cnt = 1, nni = nno->list; nni->name; nni++, cnt++) {
208                         if (nno->saw[nni->num])
209                                 nni->main_name = nno->list[nno->saw[nni->num]-1].name;
210                         else
211                                 nno->saw[nni->num] = cnt;
212                 }
213         }
214
215         memset(nno->saw, val, nno->saw_len);
216 }
217
218 /* Simplify the user-provided string so that it contains valid names without any duplicates.
219  * It also sets the "saw" flags to a 1-relative count of which name was seen first. */
220 static int parse_nni_str(struct name_num_obj *nno, const char *from, char *tobuf, int tobuf_len)
221 {
222         char *to = tobuf, *tok = NULL;
223         int cnt = 0;
224
225         while (1) {
226                 if (*from == ' ' || !*from) {
227                         if (tok) {
228                                 struct name_num_item *nni = get_nni_by_name(nno, tok, to - tok);
229                                 if (nni && !nno->saw[nni->num]) {
230                                         nno->saw[nni->num] = ++cnt;
231                                         if (nni->main_name && *nni->main_name) {
232                                                 to = tok + strlcpy(tok, nni->main_name, tobuf_len - (tok - tobuf));
233                                                 if (to - tobuf >= tobuf_len) {
234                                                         to = tok - 1;
235                                                         break;
236                                                 }
237                                         } else
238                                                 nni->main_name = NULL; /* Override a "" entry */
239                                 } else
240                                         to = tok - (tok != tobuf);
241                                 tok = NULL;
242                         }
243                         if (!*from++)
244                                 break;
245                         continue;
246                 }
247                 if (!tok) {
248                         if (to != tobuf)
249                                 *to++ = ' ';
250                         tok = to;
251                 }
252                 if (to - tobuf >= tobuf_len - 1) {
253                         to = tok - (tok != tobuf);
254                         break;
255                 }
256                 *to++ = *from++;
257         }
258         *to = '\0';
259
260         return to - tobuf;
261 }
262
263 static void recv_negotiate_str(int f_in, struct name_num_obj *nno, char *tmpbuf, int len)
264 {
265         struct name_num_item *ret = NULL;
266
267         if (len < 0)
268                 len = read_vstring(f_in, tmpbuf, MAX_NSTR_STRLEN);
269
270         if (DEBUG_GTE(NSTR, am_server ? 4 : 2))
271                 rprintf(FINFO, "Server %s list: %s%s\n", nno->type, tmpbuf, am_server ? " (on server)" : "");
272
273         if (len > 0) {
274                 int best = nno->saw_len; /* We want best == 1 from the client list, so start with a big number. */
275                 char *tok;
276                 if (am_server)
277                         init_nno_saw(nno, 1); /* Since we're parsing client names, anything we parse first is #1. */
278                 for (tok = strtok(tmpbuf, " \t"); tok; tok = strtok(NULL, " \t")) {
279                         struct name_num_item *nni = get_nni_by_name(nno, tok, -1);
280                         if (!nni || !nno->saw[nni->num] || best <= nno->saw[nni->num])
281                                 continue;
282                         ret = nni;
283                         best = nno->saw[nni->num];
284                         if (best == 1)
285                                 break;
286                 }
287                 if (ret) {
288                         free(nno->saw);
289                         nno->saw = NULL;
290                         nno->negotiated_name = ret->main_name ? ret->main_name : ret->name;
291                         nno->negotiated_num = ret->num;
292                         return;
293                 }
294         }
295
296         if (!am_server)
297                 rprintf(FERROR, "Failed to negotiate a common %s\n", nno->type);
298         exit_cleanup(RERR_UNSUPPORTED);
299 }
300
301 static void send_negotiate_str(int f_out, struct name_num_obj *nno, const char *env_name)
302 {
303         char tmpbuf[MAX_NSTR_STRLEN];
304         struct name_num_item *nni;
305         const char *list_str = getenv(env_name);
306         int len, fail_if_empty = list_str && strstr(list_str, "FAIL");
307
308         if (!do_negotiated_strings) {
309                 if (!am_server && fail_if_empty) {
310                         rprintf(FERROR, "Remote rsync is too old for %s negotation\n", nno->type);
311                         exit_cleanup(RERR_UNSUPPORTED);
312                 }
313                 return;
314         }
315
316         init_nno_saw(nno, 0);
317
318         if (list_str && *list_str && (!am_server || local_server)) {
319                 len = parse_nni_str(nno, list_str, tmpbuf, MAX_NSTR_STRLEN);
320                 if (fail_if_empty && !len)
321                         len = strlcpy(tmpbuf, "FAIL", MAX_NSTR_STRLEN);
322                 list_str = tmpbuf;
323         } else
324                 list_str = NULL;
325
326         if (!list_str || !*list_str) {
327                 int cnt = 0;
328                 for (nni = nno->list, len = 0; nni->name; nni++) {
329                         if (nni->main_name)
330                                 continue;
331                         if (len)
332                                 tmpbuf[len++]= ' ';
333                         len += strlcpy(tmpbuf+len, nni->name, MAX_NSTR_STRLEN - len);
334                         if (len >= (int)MAX_NSTR_STRLEN - 1)
335                                 exit_cleanup(RERR_UNSUPPORTED); /* IMPOSSIBLE... */
336                         nno->saw[nni->num] = ++cnt;
337                 }
338         }
339
340         if (DEBUG_GTE(NSTR, am_server ? 4 : 2))
341                 rprintf(FINFO, "Client %s list: %s%s\n", nno->type, tmpbuf, am_server ? " (on server)" : "");
342
343         if (local_server) {
344                 /* A local server doesn't bother to send/recv the strings, it just constructs
345                  * and parses the same string on both sides. */
346                 if (!read_batch)
347                         recv_negotiate_str(-1, nno, tmpbuf, len);
348         } else {
349                 /* Each side sends their list of valid names to the other side and then both sides
350                  * pick the first name in the client's list that is also in the server's list. */
351                 write_vstring(f_out, tmpbuf, len);
352         }
353 }
354
355 static void negotiate_the_strings(int f_in, int f_out)
356 {
357         /* We send all the negotiation strings before we start to read them to help avoid a slow startup. */
358
359         if (!checksum_choice)
360                 send_negotiate_str(f_out, &valid_checksums, "RSYNC_CHECKSUM_LIST");
361
362         if (do_compression && !compress_choice)
363                 send_negotiate_str(f_out, &valid_compressions, "RSYNC_COMPRESS_LIST");
364
365         if (valid_checksums.saw) {
366                 char tmpbuf[MAX_NSTR_STRLEN];
367                 recv_negotiate_str(f_in, &valid_checksums, tmpbuf, -1);
368         }
369         if (valid_checksums.negotiated_name)
370                 xfersum_type = checksum_type = valid_checksums.negotiated_num;
371
372         if (valid_compressions.saw) {
373                 char tmpbuf[MAX_NSTR_STRLEN];
374                 recv_negotiate_str(f_in, &valid_compressions, tmpbuf, -1);
375         }
376 #if 0
377         if (valid_compressions.negotiated_name)
378                 compress_type = valid_checksums.negotiated_num;
379 #endif
380 }
381
382 void setup_protocol(int f_out,int f_in)
383 {
384         assert(file_extra_cnt == 0);
385         assert(EXTRA64_CNT == 2 || EXTRA64_CNT == 1);
386
387         /* All int64 values must be set first so that they are guaranteed to be
388          * aligned for direct int64-pointer memory access. */
389         if (preserve_atimes)
390                 atimes_ndx = (file_extra_cnt += EXTRA64_CNT);
391         if (am_sender) /* This is most likely in the in64 union as well. */
392                 pathname_ndx = (file_extra_cnt += PTR_EXTRA_CNT);
393         else
394                 depth_ndx = ++file_extra_cnt;
395         if (preserve_uid)
396                 uid_ndx = ++file_extra_cnt;
397         if (preserve_gid)
398                 gid_ndx = ++file_extra_cnt;
399         if (preserve_acls && !am_sender)
400                 acls_ndx = ++file_extra_cnt;
401         if (preserve_xattrs)
402                 xattrs_ndx = ++file_extra_cnt;
403
404         if (am_server)
405                 set_allow_inc_recurse();
406
407         if (remote_protocol == 0) {
408                 if (am_server && !local_server)
409                         check_sub_protocol();
410                 if (!read_batch)
411                         write_int(f_out, protocol_version);
412                 remote_protocol = read_int(f_in);
413                 if (protocol_version > remote_protocol)
414                         protocol_version = remote_protocol;
415         }
416         if (read_batch && remote_protocol > protocol_version) {
417                 rprintf(FERROR, "The protocol version in the batch file is too new (%d > %d).\n",
418                         remote_protocol, protocol_version);
419                 exit_cleanup(RERR_PROTOCOL);
420         }
421
422         if (DEBUG_GTE(PROTO, 1)) {
423                 rprintf(FINFO, "(%s) Protocol versions: remote=%d, negotiated=%d\n",
424                         am_server? "Server" : "Client", remote_protocol, protocol_version);
425         }
426         if (remote_protocol < MIN_PROTOCOL_VERSION
427          || remote_protocol > MAX_PROTOCOL_VERSION) {
428                 rprintf(FERROR,"protocol version mismatch -- is your shell clean?\n");
429                 rprintf(FERROR,"(see the rsync man page for an explanation)\n");
430                 exit_cleanup(RERR_PROTOCOL);
431         }
432         if (remote_protocol < OLD_PROTOCOL_VERSION) {
433                 rprintf(FINFO,"%s is very old version of rsync, upgrade recommended.\n",
434                         am_server? "Client" : "Server");
435         }
436         if (protocol_version < MIN_PROTOCOL_VERSION) {
437                 rprintf(FERROR, "--protocol must be at least %d on the %s.\n",
438                         MIN_PROTOCOL_VERSION, am_server? "Server" : "Client");
439                 exit_cleanup(RERR_PROTOCOL);
440         }
441         if (protocol_version > PROTOCOL_VERSION) {
442                 rprintf(FERROR, "--protocol must be no more than %d on the %s.\n",
443                         PROTOCOL_VERSION, am_server? "Server" : "Client");
444                 exit_cleanup(RERR_PROTOCOL);
445         }
446         if (read_batch)
447                 check_batch_flags();
448
449 #ifndef SUPPORT_PREALLOCATION
450         if (preallocate_files && !am_sender) {
451                 rprintf(FERROR, "preallocation is not supported on this %s\n",
452                         am_server ? "Server" : "Client");
453                 exit_cleanup(RERR_SYNTAX);
454         }
455 #endif
456
457         if (protocol_version < 30) {
458                 if (append_mode == 1)
459                         append_mode = 2;
460                 if (preserve_acls && !local_server) {
461                         rprintf(FERROR,
462                             "--acls requires protocol 30 or higher"
463                             " (negotiated %d).\n",
464                             protocol_version);
465                         exit_cleanup(RERR_PROTOCOL);
466                 }
467                 if (preserve_xattrs && !local_server) {
468                         rprintf(FERROR,
469                             "--xattrs requires protocol 30 or higher"
470                             " (negotiated %d).\n",
471                             protocol_version);
472                         exit_cleanup(RERR_PROTOCOL);
473                 }
474         }
475
476         if (delete_mode && !(delete_before+delete_during+delete_after)) {
477                 if (protocol_version < 30)
478                         delete_before = 1;
479                 else
480                         delete_during = 1;
481         }
482
483         if (protocol_version < 29) {
484                 if (fuzzy_basis) {
485                         rprintf(FERROR,
486                             "--fuzzy requires protocol 29 or higher"
487                             " (negotiated %d).\n",
488                             protocol_version);
489                         exit_cleanup(RERR_PROTOCOL);
490                 }
491
492                 if (basis_dir_cnt && inplace) {
493                         rprintf(FERROR,
494                             "%s with --inplace requires protocol 29 or higher"
495                             " (negotiated %d).\n",
496                             dest_option, protocol_version);
497                         exit_cleanup(RERR_PROTOCOL);
498                 }
499
500                 if (basis_dir_cnt > 1) {
501                         rprintf(FERROR,
502                             "Using more than one %s option requires protocol"
503                             " 29 or higher (negotiated %d).\n",
504                             dest_option, protocol_version);
505                         exit_cleanup(RERR_PROTOCOL);
506                 }
507
508                 if (prune_empty_dirs) {
509                         rprintf(FERROR,
510                             "--prune-empty-dirs requires protocol 29 or higher"
511                             " (negotiated %d).\n",
512                             protocol_version);
513                         exit_cleanup(RERR_PROTOCOL);
514                 }
515         } else if (protocol_version >= 30) {
516                 if (am_server) {
517                         compat_flags = allow_inc_recurse ? CF_INC_RECURSE : 0;
518 #ifdef CAN_SET_SYMLINK_TIMES
519                         compat_flags |= CF_SYMLINK_TIMES;
520 #endif
521 #ifdef ICONV_OPTION
522                         compat_flags |= CF_SYMLINK_ICONV;
523 #endif
524                         if (local_server || strchr(client_info, 'f') != NULL)
525                                 compat_flags |= CF_SAFE_FLIST;
526                         if (local_server || strchr(client_info, 'x') != NULL)
527                                 compat_flags |= CF_AVOID_XATTR_OPTIM;
528                         if (local_server || strchr(client_info, 'C') != NULL)
529                                 compat_flags |= CF_CHKSUM_SEED_FIX;
530                         if (local_server || strchr(client_info, 'I') != NULL)
531                                 compat_flags |= CF_INPLACE_PARTIAL_DIR;
532                         if (local_server || strchr(client_info, 'v') != NULL) {
533                                 if (!write_batch || protocol_version >= 30) {
534                                         do_negotiated_strings = 1;
535                                         compat_flags |= CF_VARINT_FLIST_FLAGS;
536                                 }
537                         }
538                         if (strchr(client_info, 'V') != NULL) { /* Support a pre-release 'V' that got superseded */
539                                 if (!write_batch)
540                                         compat_flags |= CF_VARINT_FLIST_FLAGS;
541                                 write_byte(f_out, compat_flags);
542                         } else
543                                 write_varint(f_out, compat_flags);
544                 } else { /* read_varint() is compatible with the older write_byte() when the 0x80 bit isn't on. */
545                         compat_flags = read_varint(f_in);
546                         if  (compat_flags & CF_VARINT_FLIST_FLAGS)
547                                 do_negotiated_strings = 1;
548                 }
549                 /* The inc_recurse var MUST be set to 0 or 1. */
550                 inc_recurse = compat_flags & CF_INC_RECURSE ? 1 : 0;
551                 want_xattr_optim = protocol_version >= 31 && !(compat_flags & CF_AVOID_XATTR_OPTIM);
552                 proper_seed_order = compat_flags & CF_CHKSUM_SEED_FIX ? 1 : 0;
553                 xfer_flags_as_varint = compat_flags & CF_VARINT_FLIST_FLAGS ? 1 : 0;
554                 if (am_sender) {
555                         receiver_symlink_times = am_server
556                             ? strchr(client_info, 'L') != NULL
557                             : !!(compat_flags & CF_SYMLINK_TIMES);
558                 }
559 #ifdef CAN_SET_SYMLINK_TIMES
560                 else
561                         receiver_symlink_times = 1;
562 #endif
563 #ifdef ICONV_OPTION
564                 sender_symlink_iconv = iconv_opt && (am_server
565                     ? local_server || strchr(client_info, 's') != NULL
566                     : !!(compat_flags & CF_SYMLINK_ICONV));
567 #endif
568                 if (inc_recurse && !allow_inc_recurse) {
569                         /* This should only be able to happen in a batch. */
570                         fprintf(stderr,
571                             "Incompatible options specified for inc-recursive %s.\n",
572                             read_batch ? "batch file" : "connection");
573                         exit_cleanup(RERR_SYNTAX);
574                 }
575                 use_safe_inc_flist = (compat_flags & CF_SAFE_FLIST) || protocol_version >= 31;
576                 need_messages_from_generator = 1;
577                 if (compat_flags & CF_INPLACE_PARTIAL_DIR)
578                         inplace_partial = 1;
579 #ifdef CAN_SET_SYMLINK_TIMES
580         } else if (!am_sender) {
581                 receiver_symlink_times = 1;
582 #endif
583         }
584
585         if (need_unsorted_flist && (!am_sender || inc_recurse))
586                 unsort_ndx = ++file_extra_cnt;
587
588         if (partial_dir && *partial_dir != '/' && (!am_server || local_server)) {
589                 int rflags = FILTRULE_NO_PREFIXES | FILTRULE_DIRECTORY;
590                 if (!am_sender || protocol_version >= 30)
591                         rflags |= FILTRULE_PERISHABLE;
592                 parse_filter_str(&filter_list, partial_dir, rule_template(rflags), 0);
593         }
594
595
596 #ifdef ICONV_OPTION
597         if (protect_args && files_from) {
598                 if (am_sender)
599                         filesfrom_convert = filesfrom_host && ic_send != (iconv_t)-1;
600                 else
601                         filesfrom_convert = !filesfrom_host && ic_recv != (iconv_t)-1;
602         }
603 #endif
604
605         negotiate_the_strings(f_in, f_out);
606
607         if (am_server) {
608                 if (!checksum_seed)
609                         checksum_seed = time(NULL) ^ (getpid() << 6);
610                 write_int(f_out, checksum_seed);
611         } else {
612                 checksum_seed = read_int(f_in);
613         }
614
615         init_flist();
616 }
617
618 void maybe_write_negotiated_strings(int batch_fd)
619 {
620         if (valid_checksums.negotiated_name)
621                 write_vstring(batch_fd, valid_checksums.negotiated_name, strlen(valid_checksums.negotiated_name));
622
623         if (valid_compressions.negotiated_name)
624                 write_vstring(batch_fd, valid_compressions.negotiated_name, strlen(valid_compressions.negotiated_name));
625 }