summaryrefslogtreecommitdiff
path: root/clientname.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2013-06-15 14:40:52 -0700
committerWayne Davison <wayned@samba.org>2013-06-15 16:40:10 -0700
commit70d4a945f7d1ab1aca2c3ca8535240fad4bdf06b (patch)
treeae7f7090c6f8726ebd5eb4e03d4c71c72a810c8b /clientname.c
parent0488a14b9930bf91719ac0f1d1c0c8770ca10646 (diff)
downloadrsync-70d4a945f7d1ab1aca2c3ca8535240fad4bdf06b.tar.gz
Support rsync daemon over SSL via stunnel.
Added the client rsync-ssl script and various client/daemon support files needed for talking to an rsync daemon over SSL on port 874 (no tls support). This uses an elegant stunnel setup that was detailed by dozzie (see the resources page) now that stunnel4 has improved command-spawning support. Also incorporates some tweaks by devzero (e.g. the nice no-tmpfile-config client-side code) and a few by me (including logging of the actual remote IP that came in to the stunnel process). This probably still needs a little work.
Diffstat (limited to 'clientname.c')
-rw-r--r--clientname.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/clientname.c b/clientname.c
index 8f8460dc..d085fc78 100644
--- a/clientname.c
+++ b/clientname.c
@@ -41,7 +41,6 @@ char *client_addr(int fd)
static int initialised;
struct sockaddr_storage ss;
socklen_t length = sizeof ss;
- char *ssh_info, *p;
if (initialised)
return addr_buf;
@@ -49,11 +48,14 @@ char *client_addr(int fd)
initialised = 1;
if (am_server) { /* daemon over --rsh mode */
+ char *env_str;
strlcpy(addr_buf, "0.0.0.0", sizeof addr_buf);
- if ((ssh_info = getenv("SSH_CONNECTION")) != NULL
- || (ssh_info = getenv("SSH_CLIENT")) != NULL
- || (ssh_info = getenv("SSH2_CLIENT")) != NULL) {
- strlcpy(addr_buf, ssh_info, sizeof addr_buf);
+ if ((env_str = getenv("SSH_CONNECTION")) != NULL
+ || (env_str = getenv("SSH_CLIENT")) != NULL
+ || (env_str = getenv("SSH2_CLIENT")) != NULL
+ || (env_str = getenv("REMOTE_HOST")) != NULL) {
+ char *p;
+ strlcpy(addr_buf, env_str, sizeof addr_buf);
/* Truncate the value to just the IP address. */
if ((p = strchr(addr_buf, ' ')) != NULL)
*p = '\0';