[SCM] The rsync repository. - branch master updated

Rsync CVS commit messages rsync-cvs at lists.samba.org
Sat Jul 25 17:10:32 UTC 2020


The branch, master has been updated
       via  21ecc833 Change new stderr options to `--stderr=MODE`.
       via  f9bb8f76 Change daemon variable & simplify some option code
      from  a5a9f268 Tweak NEWS & src_file().

https://git.samba.org/?p=rsync.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 21ecc833ea36e35a9a6c13766d7eb8648c007e61
Author: Wayne Davison <wayne at opencoder.net>
Date:   Sat Jul 25 09:37:17 2020 -0700

    Change new stderr options to `--stderr=MODE`.

commit f9bb8f76ee728bd1391a2b4890ce0281457a7bf2
Author: Wayne Davison <wayne at opencoder.net>
Date:   Sat Jul 25 09:15:41 2020 -0700

    Change daemon variable & simplify some option code
    
    - Rename daemon_over_rsh -> daemon_connection since it is also used to
      indicate if a non-rsh daemon connection is active.
    - Move the daemon-over-rsh exception out of server_options() to the one
      caller that needs that behavior.
    - Don't allow noop_io_until_death() to be short-circuited when talking
      to a daemon over a socket, because it can't send errors via stderr.

-----------------------------------------------------------------------

Summary of changes:
 NEWS.md        | 23 ++++++++++++-----------
 clientserver.c |  5 -----
 io.c           |  7 ++++++-
 main.c         | 28 ++++++++++++++++------------
 options.c      | 31 ++++++++++++++++++++-----------
 rsync.1.md     | 30 ++++++++++++++++--------------
 6 files changed, 70 insertions(+), 54 deletions(-)


Changeset truncated at 500 lines:

diff --git a/NEWS.md b/NEWS.md
index 1f58f825..5f5a6e76 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -45,9 +45,18 @@
  - Added `--mkpath` option to tell rsync that it should create a non-existing
    path component of the destination arg.
 
- - Added `--errors2stdout` (the new default) and `--msgs2protocol` (the old
-   default).  The new output idiom should help error messages get to the user
-   more quickly when doing a push (which includes local copying).
+ - Added `--stderr=errors|all|client` to replace the `--msgs2stderr` and
+   `--no-msgs2stderr` options (which are still accepted).  The default use of
+   stderr was changed to be `--stderr=errors` where all the processes that have
+   stderr available output directly to stderr, which should help error messages
+   get to the user more quickly, especially when doing a push (which includes
+   local copying).  This also allows rsync to exit quickly when a receiver
+   failure occurs, since rsync doesn't need to try to keep the connection alive
+   long enough for the fatal error to go from the receiver to the generator to
+   the sender.  The old default can be requested via `--stderr=client`.  Also
+   changed is that a non-default stderr mode is conveyed to the remote rsync
+   (using the older option names) instead of requiring the user to use
+   `--remote-option` (`-M`) to tell the remote rsync what to do.
 
  - Added the ability to specify "@netgroup" names to the `hosts allow` and
    `hosts deny` daemon parameters.  This is a finalized version of the
@@ -56,14 +65,6 @@
  - Output file+line info on out-of-memory & overflow errors while also avoiding
    the output of alternate build-dir path info that is not useful to the user.
 
- - Improve the error handling for local and remote-shell transfers by sending
-   error messages directly to stderr, even on the remote side (instead of
-   having an error wind its way through the pipelined backlog).  This also
-   allows rsync to exit quickly when a receiver failure occurs, since rsync
-   doesn't need to try to keep the connection alive long enough for the fatal
-   error to go from the receiver to the generator to the sender.  To disable
-   this new default you can use the `--no-msgs2stderr` option.
-
  - Change configure to know that Cywin supports Linux xattrs.
 
  - Improved the testsuite on FreeBSD & Cygwin.
diff --git a/clientserver.c b/clientserver.c
index f324a989..0f54dcab 100644
--- a/clientserver.c
+++ b/clientserver.c
@@ -37,7 +37,6 @@ extern int protect_args;
 extern int ignore_errors;
 extern int preserve_xattrs;
 extern int kluge_around_eof;
-extern int daemon_over_rsh;
 extern int munge_symlinks;
 extern int open_noatime;
 extern int sanitize_paths;
@@ -282,10 +281,6 @@ int start_inband_exchange(int f_in, int f_out, const char *user, int argc, char
 		fclose(f);
 	}
 
-	/* set daemon_over_rsh to false since we need to build the
-	 * true set of args passed through the rsh/ssh connection;
-	 * this is a no-op for direct-socket-connection mode */
-	daemon_over_rsh = 0;
 	server_options(sargs, &sargc);
 
 	if (sargc >= MAX_ARGS - 2)
diff --git a/io.c b/io.c
index fe4a8778..b50a066c 100644
--- a/io.c
+++ b/io.c
@@ -54,6 +54,7 @@ extern int read_batch;
 extern int compat_flags;
 extern int protect_args;
 extern int checksum_seed;
+extern int daemon_connection;
 extern int protocol_version;
 extern int remove_source_files;
 extern int preserve_hard_links;
@@ -917,7 +918,11 @@ void noop_io_until_death(void)
 {
 	char buf[1024];
 
-	if (!iobuf.in.buf || !iobuf.out.buf || iobuf.in_fd < 0 || iobuf.out_fd < 0 || kluge_around_eof || msgs2stderr)
+	if (!iobuf.in.buf || !iobuf.out.buf || iobuf.in_fd < 0 || iobuf.out_fd < 0 || kluge_around_eof)
+		return;
+
+	/* If we're talking to a daemon over a socket, don't short-circuit this logic */
+	if (msgs2stderr && daemon_connection >= 0)
 		return;
 
 	kluge_around_eof = 2;
diff --git a/main.c b/main.c
index 04b32e74..e68d73c4 100644
--- a/main.c
+++ b/main.c
@@ -108,7 +108,7 @@ gid_t our_gid;
 int am_receiver = 0;  /* Only set to 1 after the receiver/generator fork. */
 int am_generator = 0; /* Only set to 1 after the receiver/generator fork. */
 int local_server = 0;
-int daemon_over_rsh = 0;
+int daemon_connection = 0; /* 0 = no daemon, 1 = daemon via remote shell, -1 = daemon via socket */
 mode_t orig_umask = 0;
 int batch_gen_fd = -1;
 int sender_keeps_checksum = 0;
@@ -566,12 +566,12 @@ static pid_t do_cmd(char *cmd, char *machine, char *user, char **remote_argv, in
 #ifdef HAVE_REMSH
 		/* remsh (on HPUX) takes the arguments the other way around */
 		args[argc++] = machine;
-		if (user && !(daemon_over_rsh && dash_l_set)) {
+		if (user && !(daemon_connection && dash_l_set)) {
 			args[argc++] = "-l";
 			args[argc++] = user;
 		}
 #else
-		if (user && !(daemon_over_rsh && dash_l_set)) {
+		if (user && !(daemon_connection && dash_l_set)) {
 			args[argc++] = "-l";
 			args[argc++] = user;
 		}
@@ -591,7 +591,11 @@ static pid_t do_cmd(char *cmd, char *machine, char *user, char **remote_argv, in
 		if (blocking_io < 0 && (strcmp(t, "rsh") == 0 || strcmp(t, "remsh") == 0))
 			blocking_io = 1;
 
-		server_options(args, &argc);
+		if (daemon_connection > 0) {
+			args[argc++] = "--server";
+			args[argc++] = "--daemon";
+		} else
+			server_options(args, &argc);
 
 		if (argc >= MAX_ARGS - 2)
 			goto arg_overflow;
@@ -599,7 +603,7 @@ static pid_t do_cmd(char *cmd, char *machine, char *user, char **remote_argv, in
 
 	args[argc++] = ".";
 
-	if (!daemon_over_rsh) {
+	if (!daemon_connection) {
 		while (remote_argc > 0) {
 			if (argc >= MAX_ARGS - 1) {
 			  arg_overflow:
@@ -652,7 +656,7 @@ static pid_t do_cmd(char *cmd, char *machine, char *user, char **remote_argv, in
 #ifdef ICONV_CONST
 		setup_iconv();
 #endif
-		if (protect_args && !daemon_over_rsh)
+		if (protect_args && !daemon_connection)
 			send_protected_args(*f_out_p, args);
 	}
 
@@ -1407,7 +1411,7 @@ static int start_client(int argc, char *argv[])
 			}
 			am_sender = 0;
 			if (rsync_port)
-				daemon_over_rsh = shell_cmd ? 1 : -1;
+				daemon_connection = shell_cmd ? 1 : -1;
 		} else { /* source is local, check dest arg */
 			am_sender = 1;
 
@@ -1439,7 +1443,7 @@ static int start_client(int argc, char *argv[])
 			} else { /* hostspec was found, so dest is remote */
 				argv[argc] = path;
 				if (rsync_port)
-					daemon_over_rsh = shell_cmd ? 1 : -1;
+					daemon_connection = shell_cmd ? 1 : -1;
 			}
 		}
 	} else {  /* read_batch */
@@ -1502,10 +1506,10 @@ static int start_client(int argc, char *argv[])
 	else
 		env_port = rsync_port;
 
-	if (daemon_over_rsh < 0)
+	if (daemon_connection < 0)
 		return start_socket_client(shell_machine, remote_argc, remote_argv, argc, argv);
 
-	if (password_file && !daemon_over_rsh) {
+	if (password_file && !daemon_connection) {
 		rprintf(FERROR, "The --password-file option may only be "
 				"used when accessing an rsync daemon.\n");
 		exit_cleanup(RERR_SYNTAX);
@@ -1533,7 +1537,7 @@ static int start_client(int argc, char *argv[])
 	}
 
 #ifdef HAVE_PUTENV
-	if (daemon_over_rsh)
+	if (daemon_connection)
 		set_env_num("RSYNC_PORT", env_port);
 #endif
 
@@ -1541,7 +1545,7 @@ static int start_client(int argc, char *argv[])
 
 	/* if we're running an rsync server on the remote host over a
 	 * remote shell command, we need to do the RSYNCD protocol first */
-	if (daemon_over_rsh) {
+	if (daemon_connection) {
 		int tmpret;
 		tmpret = start_inband_exchange(f_in, f_out, shell_user, remote_argc, remote_argv);
 		if (tmpret < 0)
diff --git a/options.c b/options.c
index 3e74a086..36e88621 100644
--- a/options.c
+++ b/options.c
@@ -28,7 +28,6 @@
 extern int module_id;
 extern int local_server;
 extern int sanitize_paths;
-extern int daemon_over_rsh;
 extern unsigned int module_dirlen;
 extern struct name_num_obj valid_checksums;
 extern struct name_num_obj valid_compressions;
@@ -795,7 +794,7 @@ enum {OPT_SERVER = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
       OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW, OPT_MIN_SIZE, OPT_CHMOD,
       OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH, OPT_MAX_SIZE,
       OPT_NO_D, OPT_APPEND, OPT_NO_ICONV, OPT_INFO, OPT_DEBUG, OPT_BLOCK_SIZE,
-      OPT_USERMAP, OPT_GROUPMAP, OPT_CHOWN, OPT_BWLIMIT,
+      OPT_USERMAP, OPT_GROUPMAP, OPT_CHOWN, OPT_BWLIMIT, OPT_STDERR,
       OPT_OLD_COMPRESS, OPT_NEW_COMPRESS, OPT_NO_COMPRESS,
       OPT_STOP_AFTER, OPT_STOP_AT,
       OPT_REFUSED_BASE = 9000};
@@ -809,9 +808,8 @@ static struct poptOption long_options[] = {
   {"no-v",             0,  POPT_ARG_VAL,    &verbose, 0, 0, 0 },
   {"info",             0,  POPT_ARG_STRING, 0, OPT_INFO, 0, 0 },
   {"debug",            0,  POPT_ARG_STRING, 0, OPT_DEBUG, 0, 0 },
-  {"errors2stderr",    0,  POPT_ARG_VAL,    &msgs2stderr, 2, 0, 0 },
+  {"stderr",           0,  POPT_ARG_STRING, 0, OPT_STDERR, 0, 0 },
   {"msgs2stderr",      0,  POPT_ARG_VAL,    &msgs2stderr, 1, 0, 0 },
-  {"msgs2protocol",    0,  POPT_ARG_VAL,    &msgs2stderr, 0, 0, 0 },
   {"no-msgs2stderr",   0,  POPT_ARG_VAL,    &msgs2stderr, 0, 0, 0 },
   {"quiet",           'q', POPT_ARG_NONE,   0, 'q', 0, 0 },
   {"motd",             0,  POPT_ARG_VAL,    &output_motd, 1, 0, 0 },
@@ -2095,6 +2093,24 @@ int parse_arguments(int *argc_p, const char ***argv_p)
 			break;
 #endif
 
+		case OPT_STDERR: {
+			int len;
+			arg = poptGetOptArg(pc);
+			len = strlen(arg);
+			if (len && strncmp("errors", arg, len) == 0)
+				msgs2stderr = 2;
+			else if (len && strncmp("all", arg, len) == 0)
+				msgs2stderr = 1;
+			else if (len && strncmp("client", arg, len) == 0)
+				msgs2stderr = 0;
+			else {
+				snprintf(err_buf, sizeof err_buf,
+					"--stderr mode \"%s\" is not one of errors, all, or client\n", arg);
+				return 0;
+			}
+			break;
+		}
+
 		default:
 			/* A large opt value means that set_refuse_options()
 			 * turned this option off. */
@@ -2683,13 +2699,6 @@ void server_options(char **args, int *argc_p)
 	/* This should always remain first on the server's command-line. */
 	args[ac++] = "--server";
 
-	if (daemon_over_rsh > 0) {
-		args[ac++] = "--daemon";
-		*argc_p = ac;
-		/* if we're passing --daemon, we're done */
-		return;
-	}
-
 	if (!am_sender)
 		args[ac++] = "--sender";
 
diff --git a/rsync.1.md b/rsync.1.md
index cb26b5af..08ea68bc 100644
--- a/rsync.1.md
+++ b/rsync.1.md
@@ -334,9 +334,7 @@ detailed description below for a complete description.
 --verbose, -v            increase verbosity
 --info=FLAGS             fine-grained informational verbosity
 --debug=FLAGS            fine-grained debug verbosity
---errors2stderr          output errors directly to stderr (the default)
---msgs2stderr            output all messages directly to stderr
---msgs2protocol          forward all messages via the protocol stream
+--stderr=e|a|c           change stderr output mode (default: errors)
 --quiet, -q              suppress non-error messages
 --no-motd                suppress daemon-mode MOTD
 --checksum, -c           skip based on checksum, not mod-time & size
@@ -584,7 +582,7 @@ your home directory (remove the '=' for that).
     >     rsync -avvv --debug=none src/ dest/
     >     rsync -avA --del --debug=del2,acl src/ dest/
 
-    Note that some debug messages will only be output when `--msgs2stderr` is
+    Note that some debug messages will only be output when `--stderr=all` is
     specified, especially those pertaining to I/O and buffer debugging.
 
     Beginning in 3.2.0, this option is no longer auto-forwared to the server
@@ -596,18 +594,20 @@ your home directory (remove the '=' for that).
 
     >     rsync -aiv {-M,}--debug=del2 src/ dest/
 
-0.  `--errors2stderr`, `--msgs2stderr`, `--msgs2protocol`
+0.  `--stderr=errors|all|client`
 
-    Rsync handles messages in 3 possible ways:
+    This option controls which processes output to stderr and if info messages
+    are also changed to stderr.  The mode strings can be abbreviaated, so feel
+    free to use a single letter value.  The 3 possible choices are:
 
-    - `--errors2stderr` (the default) causes all the rsync processes to send an
+    - `errors` - (the default) causes all the rsync processes to send an
       error directly to stderr, even if the process is on the remote side of
       the transfer.  Info messages are sent to the client side via the protocol
       stream.  If stderr is not available (i.e. when directly connecting with a
       daemon via a socket) errors fall back to being sent via the protocol
-      stream.  This option and the default are new for version 3.2.3.
+      stream.
 
-    - `--msgs2stderr` causes all rsync messages (info and error) to get written
+    - `all` - causes all rsync messages (info and error) to get written
       directly to stderr from all (possible) processes.  This causes stderr to
       become line-buffered (instead of raw) and eliminates the ability to
       divide up the info and error messages by file handle.  For those doing
@@ -616,17 +616,19 @@ your home directory (remove the '=' for that).
       a deadlock bug hanging things up).  It also enables the outputting of some
       I/O related debug messages.
 
-    - `--msgs2protocol` causes all rsync messages to be sent to the client side
+    - `client` - causes all rsync messages to be sent to the client side
       via the protocol stream.  One client process outputs all messages, with
       errors on stderr and info messages on stdout.  This **was** the default
       in older rsync versions, but can cause error delays when a lot of
       transfer data is ahead of the messages.  If you're pushing files to an
-      older rsync, you may want to use `--msgs2stderr` since that option has
+      older rsync, you may want to use `--stderr=all` since that idiom has
       been around for several releases.
 
-    Starting with rsync 3.2.3, the `--msgs2stderr` and `--msgs2protocol`
-    options are forwarded to the remote rsync, though the latter is conveyed
-    using the backward-compatible `--no-msgs2stderr` option.
+    This option was added in rsync 3.2.3.  This version also began the
+    forwarding of a non-default setting to the remote side, though rsync uses
+    the backward-compatible options `--msgs2stderr` and `--no-msgs2stderr` to
+    represent the `all` and `client` settings, respectively.  A newer rsync
+    will continue to accept these older option names to maintain compatibility.
 
 0.  `--quiet`, `-q`
 


-- 
The rsync repository.



More information about the rsync-cvs mailing list