summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@dtucker.net>2018-02-23 15:20:42 +1100
committerDarren Tucker <dtucker@dtucker.net>2018-02-23 15:20:42 +1100
commitb59162da99399d89bd57f71c170c0003c55b1583 (patch)
treebf440d2fb9931ef3e9589125f1c1214a55b38f02
parenta8dd6fe0aa10b6866830b4688a73ef966f0aed88 (diff)
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.
-rw-r--r--configure.ac1
-rw-r--r--sshconnect.c14
2 files changed, 14 insertions, 1 deletions
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;
}