[openssh-commits] [openssh] 01/01: Check for ifaddrs.h for BindInterface.

git+noreply at mindrot.org git+noreply at mindrot.org
Fri Feb 23 15:23:20 AEDT 2018


This is an automated email from the git hooks/post-receive script.

dtucker pushed a commit to branch master
in repository openssh.

commit b59162da99399d89bd57f71c170c0003c55b1583
Author: Darren Tucker <dtucker at dtucker.net>
Date:   Fri Feb 23 15:20:42 2018 +1100

    Check for ifaddrs.h for BindInterface.
    
    BindInterface required getifaddr and friends so disable if not available
    (eg Solaris 10).  We should be able to add support for some systems with
    a bit more work but this gets the building again.
---
 configure.ac |  1 +
 sshconnect.c | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index cbcf9d07..e81e3ecc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -365,6 +365,7 @@ AC_CHECK_HEADERS([ \
 	glob.h \
 	ia.h \
 	iaf.h \
+	ifaddrs.h \
 	inttypes.h \
 	langinfo.h \
 	limits.h \
diff --git a/sshconnect.c b/sshconnect.c
index d9618bcf..442424b4 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -44,7 +44,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <ifaddrs.h>
+#ifdef HAVE_IFADDRS_H
+# include <ifaddrs.h>
+#endif
 
 #include "xmalloc.h"
 #include "key.h"
@@ -272,6 +274,7 @@ ssh_kill_proxy_command(void)
 		kill(proxy_command_pid, SIGHUP);
 }
 
+#ifdef HAVE_IFADDRS_H
 /*
  * Search a interface address list (returned from getifaddrs(3)) for an
  * address that matches the desired address family on the specifed interface.
@@ -332,6 +335,7 @@ check_ifaddrs(const char *ifname, int af, const struct ifaddrs *ifaddrs,
 	}
 	return -1;
 }
+#endif
 
 /*
  * Creates a (possibly privileged) socket for use as the ssh connection.
@@ -343,7 +347,9 @@ ssh_create_socket(int privileged, struct addrinfo *ai)
 	struct sockaddr_storage bindaddr;
 	socklen_t bindaddrlen = 0;
 	struct addrinfo hints, *res = NULL;
+#ifdef HAVE_IFADDRS_H
 	struct ifaddrs *ifaddrs = NULL;
+#endif
 	char ntop[NI_MAXHOST];
 
 	sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
@@ -380,6 +386,7 @@ ssh_create_socket(int privileged, struct addrinfo *ai)
 		memcpy(&bindaddr, res->ai_addr, res->ai_addrlen);
 		bindaddrlen = res->ai_addrlen;
 	} else if (options.bind_interface != NULL) {
+#ifdef HAVE_IFADDRS_H
 		if ((r = getifaddrs(&ifaddrs)) != 0) {
 			error("getifaddrs: %s: %s", options.bind_interface,
 			      strerror(errno));
@@ -392,6 +399,9 @@ ssh_create_socket(int privileged, struct addrinfo *ai)
 			      options.bind_interface);
 			goto fail;
 		}
+#else
+		error("BindInterface not supported on this platform.");
+#endif
 	}
 	if ((r = getnameinfo((struct sockaddr *)&bindaddr, bindaddrlen,
 	    ntop, sizeof(ntop), NULL, 0, NI_NUMERICHOST)) != 0) {
@@ -427,8 +437,10 @@ fail:
  out:
 	if (res != NULL)
 		freeaddrinfo(res);
+#ifdef HAVE_IFADDRS_H
 	if (ifaddrs != NULL)
 		freeifaddrs(ifaddrs);
+#endif
 	return sock;
 }
 

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list