[SCM] The rsync repository. - branch master updated

Rsync CVS commit messages rsync-cvs at lists.samba.org
Mon Apr 6 02:41:02 UTC 2020


The branch, master has been updated
       via  70cbc66b Set RSYNC_PORT in the env for a daemon-over-rsh connection. Fixes bug #14163.
      from  b63276e7 A quick fix for some perl patch-helper scripts.

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


- Log -----------------------------------------------------------------
commit 70cbc66b7f504f9ba5f396aeafa38aa8d483b799
Author: Wayne Davison <wayned at samba.org>
Date:   Sun Apr 5 19:32:40 2020 -0700

    Set RSYNC_PORT in the env for a daemon-over-rsh connection.
    Fixes bug #14163.

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

Summary of changes:
 clientserver.c |  2 +-
 main.c         | 14 +++++++++++++-
 options.c      |  2 +-
 rsync.yo       |  9 +++++++++
 4 files changed, 24 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/clientserver.c b/clientserver.c
index 2f8f2f25..692a4047 100644
--- a/clientserver.c
+++ b/clientserver.c
@@ -487,7 +487,7 @@ static void set_env_str(const char *var, const char *str)
 }
 
 #ifdef HAVE_PUTENV
-static void set_env_num(const char *var, long num)
+void set_env_num(const char *var, long num)
 {
 	char *mem;
 	if (asprintf(&mem, "%s=%ld", var, num) < 0)
diff --git a/main.c b/main.c
index b594ab82..1328c504 100644
--- a/main.c
+++ b/main.c
@@ -1359,7 +1359,7 @@ static int start_client(int argc, char *argv[])
 {
 	char *p, *shell_machine = NULL, *shell_user = NULL;
 	char **remote_argv;
-	int remote_argc;
+	int remote_argc, env_port = rsync_port;
 	int f_in, f_out;
 	int ret;
 	pid_t pid;
@@ -1425,6 +1425,7 @@ static int start_client(int argc, char *argv[])
 					exit_cleanup(RERR_SYNTAX);
 				}
 				shell_machine = NULL;
+				rsync_port = 0;
 			} else { /* hostspec was found, so dest is remote */
 				argv[argc] = path;
 				if (rsync_port)
@@ -1439,6 +1440,7 @@ static int start_client(int argc, char *argv[])
 		}
 		remote_argv = argv += argc - 1;
 		remote_argc = argc = 1;
+		rsync_port = 0;
 	}
 
 	if (!rsync_port && remote_argc && !**remote_argv) /* Turn an empty arg into a dot dir. */
@@ -1485,6 +1487,11 @@ static int start_client(int argc, char *argv[])
 		}
 	}
 
+	if (rsync_port < 0)
+		rsync_port = RSYNC_PORT;
+	else
+		env_port = rsync_port;
+
 	if (daemon_over_rsh < 0)
 		return start_socket_client(shell_machine, remote_argc, remote_argv, argc, argv);
 
@@ -1515,6 +1522,11 @@ static int start_client(int argc, char *argv[])
 			NS(remote_argv[0]));
 	}
 
+#ifdef HAVE_PUTENV
+	if (daemon_over_rsh)
+		set_env_num("RSYNC_PORT", env_port);
+#endif
+
 	pid = do_cmd(shell_cmd, shell_machine, shell_user, remote_argv, remote_argc,
 		     &f_in, &f_out);
 
diff --git a/options.c b/options.c
index 96e5ffba..2db357e2 100644
--- a/options.c
+++ b/options.c
@@ -2926,7 +2926,7 @@ char *check_for_hostspec(char *s, char **host_ptr, int *port_ptr)
 		*host_ptr = parse_hostspec(s + strlen(URL_PREFIX), &path, port_ptr);
 		if (*host_ptr) {
 			if (!*port_ptr)
-				*port_ptr = RSYNC_PORT;
+				*port_ptr = -1; /* -1 indicates they want the default */
 			return path;
 		}
 	}
diff --git a/rsync.yo b/rsync.yo
index 71378614..bcb33a79 100644
--- a/rsync.yo
+++ b/rsync.yo
@@ -1594,6 +1594,15 @@ shell connection, rather than through a direct socket connection to a
 running rsync daemon on the remote host.  See the section "USING
 RSYNC-DAEMON FEATURES VIA A REMOTE-SHELL CONNECTION" above.
 
+Beginning with rsync 3.1.4, the RSYNC_PORT environment variable will be
+set when a daemon connection is being made via a remote-shell
+connection.  It is set to 0 if the default daemon port is being assumed,
+or it is set to the value of the rsync port that was specified via
+either the bf(--port) option or a non-empty port value in an rsync://
+URL.  This allows the script to discern if a non-default port is being
+requested, allowing for things such as an SSL or stunnel helper script
+to connect to a default or alternate port.
+
 Command-line arguments are permitted in COMMAND provided that COMMAND is
 presented to rsync as a single argument.  You must use spaces (not tabs
 or other whitespace) to separate the command and args from each other,


-- 
The rsync repository.



More information about the rsync-cvs mailing list