Fixes bug #14163.
}
#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)
{
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;
exit_cleanup(RERR_SYNTAX);
}
shell_machine = NULL;
+ rsync_port = 0;
} else { /* hostspec was found, so dest is remote */
argv[argc] = path;
if (rsync_port)
}
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. */
}
}
+ 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);
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);
*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;
}
}
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,