summaryrefslogtreecommitdiff
path: root/clientname.c
diff options
context:
space:
mode:
authorDavid Dykstra <dwd@samba.org>2002-08-01 21:57:23 +0000
committerDavid Dykstra <dwd@samba.org>2002-08-01 21:57:23 +0000
commita6d8c3f336deebfff152e1d3f6d646ba1dc59eea (patch)
treeab3146baca6ac71b3a4a13d1a3d8615aaeb82fb1 /clientname.c
parentbb4aa89c1019a39c073ef14620d22da06b106930 (diff)
downloadrsync-a6d8c3f336deebfff152e1d3f6d646ba1dc59eea.tar.gz
rsync-a6d8c3f336deebfff152e1d3f6d646ba1dc59eea.tar.bz2
rsync-a6d8c3f336deebfff152e1d3f6d646ba1dc59eea.zip
Fix last change to use correct IPv6 structure names when using INET6.
Doesn't yet look up names correctly on Linux with INET6 enabled, however; needs further work but I don't have time right now.
Diffstat (limited to 'clientname.c')
-rw-r--r--clientname.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/clientname.c b/clientname.c
index 8d22fc8b..caf0af6c 100644
--- a/clientname.c
+++ b/clientname.c
@@ -51,8 +51,7 @@ char *client_addr(int fd)
initialised = 1;
- ssh_client = getenv("SSH_CLIENT");
- if (ssh_client != NULL) {
+ if ((ssh_client = getenv("SSH_CLIENT")) != NULL) {
strlcpy(addr_buf, ssh_client, sizeof(addr_buf));
/* truncate SSH_CLIENT to just IP address */
p = strchr(addr_buf, ' ');
@@ -112,8 +111,14 @@ char *client_name(int fd)
socklen_t sin_len = sizeof sin;
memset(&sin, 0, sin_len);
+
+#ifdef INET6
+ sin.sin6_family = af;
+ inet_pton(af, client_addr(fd), &sin.sin6_addr.s6_addr);
+#else
sin.sin_family = af;
inet_pton(af, client_addr(fd), &sin.sin_addr.s_addr);
+#endif
if (!lookup_name(fd, (struct sockaddr_storage *)&sin, sin_len,
name_buf, sizeof name_buf, port_buf, sizeof port_buf))