]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Tweak stderr handling for older BackupPC versions
authorWayne Davison <wayne@opencoder.net>
Sun, 2 Jan 2022 22:46:27 +0000 (14:46 -0800)
committerWayne Davison <wayne@opencoder.net>
Sun, 2 Jan 2022 22:48:04 +0000 (14:48 -0800)
This makes the default for a protocol-28 server process be --stderr=client
instead of --stderr=errors.  See rsync's github issue #95.

NEWS.md
compat.c
options.c

diff --git a/NEWS.md b/NEWS.md
index 6635ccab20e6bda6295328a7a33f046e745c64ad..05215c08a48b71f331355e676bb7e8e705f9dead 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
 
  - Work around a glibc bug where lchmod() breaks in a chroot w/o /proc mounted.
 
+ - Try to support a client that sent a remote rsync a wacko stderr file handle
+   (such as an older File::RsyncP perl library used by BackupPC).
+
  - Some manpage improvements.
 
 ### PACKAGING RELATED:
index 0a882cda00e2764d73c0f55d3395d666e3d09209..e84cc8c0358cef76cac30d37c70375d3e543a17c 100644 (file)
--- a/compat.c
+++ b/compat.c
@@ -52,6 +52,8 @@ extern int need_messages_from_generator;
 extern int delete_mode, delete_before, delete_during, delete_after;
 extern int do_compression;
 extern int do_compression_level;
+extern int saw_stderr_opt;
+extern int msgs2stderr;
 extern char *shell_cmd;
 extern char *partial_dir;
 extern char *files_from;
@@ -622,6 +624,9 @@ void setup_protocol(int f_out,int f_in)
        if (read_batch)
                check_batch_flags();
 
+       if (!saw_stderr_opt && protocol_version <= 28 && am_server)
+               msgs2stderr = 0; /* The client side may not have stderr setup for us. */
+
 #ifndef SUPPORT_PREALLOCATION
        if (preallocate_files && !am_sender) {
                rprintf(FERROR, "preallocation is not supported on this %s\n",
index eb5744a12ad396168b501e1022b51741f1a1d9b1..eb16c4f6de9a4b1f89b677c0ebedeb57b4badc6d 100644 (file)
--- a/options.c
+++ b/options.c
@@ -91,6 +91,7 @@ int implied_dirs = 1;
 int missing_args = 0; /* 0 = FERROR_XFER, 1 = ignore, 2 = delete */
 int numeric_ids = 0;
 int msgs2stderr = 2; /* Default: send errors to stderr for local & remote-shell transfers */
+int saw_stderr_opt = 0;
 int allow_8bit_chars = 0;
 int force_delete = 0;
 int io_timeout = 0;
@@ -1882,6 +1883,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
                                        "--stderr mode \"%s\" is not one of errors, all, or client\n", arg);
                                return 0;
                        }
+                       saw_stderr_opt = 1;
                        break;
                }
 
@@ -1900,6 +1902,9 @@ int parse_arguments(int *argc_p, const char ***argv_p)
                }
        }
 
+       if (msgs2stderr != 2)
+               saw_stderr_opt = 1;
+
        if (version_opt_cnt) {
                print_rsync_version(FINFO);
                exit_cleanup(0);