ce1406348c06226ebf7bc4a32f42af257bd1733b
[rsync-patches.git] / stderr-compat.diff
1 This makes the default for a protocol-28 server process be --stderr=client
2 instead of --stderr=errors.  See rsync's github issue 95.
3
4 To use this patch, run these commands for a successful build:
5
6     patch -p1 <patches/stderr-compat.diff
7     ./configure                                 (optional if already run)
8     make
9
10 based-on: 58f464f4daa1b1ee00c6afd898a19ca5cd81bf58
11 diff --git a/NEWS.md b/NEWS.md
12 --- a/NEWS.md
13 +++ b/NEWS.md
14 @@ -35,6 +35,9 @@
15     where the INFO is one of "type change", "sum change" (requires `-c`), "file
16     change" (based on the quick check), "attr change", or "uptodate".
17  
18 + - Try to support a client that sent a remote rsync a wacko stderr file handle
19 +   (such as an older File::RsyncP perl library).
20 +
21   - Some manpage improvements.
22  
23  ### PACKAGING RELATED:
24 diff --git a/compat.c b/compat.c
25 --- a/compat.c
26 +++ b/compat.c
27 @@ -52,6 +52,8 @@ extern int need_messages_from_generator;
28  extern int delete_mode, delete_before, delete_during, delete_after;
29  extern int do_compression;
30  extern int do_compression_level;
31 +extern int saw_stderr_opt;
32 +extern int msgs2stderr;
33  extern char *shell_cmd;
34  extern char *partial_dir;
35  extern char *files_from;
36 @@ -622,6 +624,9 @@ void setup_protocol(int f_out,int f_in)
37         if (read_batch)
38                 check_batch_flags();
39  
40 +       if (!saw_stderr_opt && protocol_version <= 28 && am_server)
41 +               msgs2stderr = 0; /* The client side may not have stderr setup for us. */
42 +
43  #ifndef SUPPORT_PREALLOCATION
44         if (preallocate_files && !am_sender) {
45                 rprintf(FERROR, "preallocation is not supported on this %s\n",
46 diff --git a/options.c b/options.c
47 --- a/options.c
48 +++ b/options.c
49 @@ -88,6 +88,7 @@ int implied_dirs = 1;
50  int missing_args = 0; /* 0 = FERROR_XFER, 1 = ignore, 2 = delete */
51  int numeric_ids = 0;
52  int msgs2stderr = 2; /* Default: send errors to stderr for local & remote-shell transfers */
53 +int saw_stderr_opt = 0;
54  int allow_8bit_chars = 0;
55  int force_delete = 0;
56  int io_timeout = 0;
57 @@ -1875,6 +1876,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
58                                         "--stderr mode \"%s\" is not one of errors, all, or client\n", arg);
59                                 return 0;
60                         }
61 +                       saw_stderr_opt = 1;
62                         break;
63                 }
64  
65 @@ -1893,6 +1895,9 @@ int parse_arguments(int *argc_p, const char ***argv_p)
66                 }
67         }
68  
69 +       if (msgs2stderr != 2)
70 +               saw_stderr_opt = 1;
71 +
72         if (version_opt_cnt) {
73                 print_rsync_version(FINFO);
74                 exit_cleanup(0);