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.
This commit is contained in:
parent
a8dd6fe0aa
commit
b59162da99
|
@ -365,6 +365,7 @@ AC_CHECK_HEADERS([ \
|
||||||
glob.h \
|
glob.h \
|
||||||
ia.h \
|
ia.h \
|
||||||
iaf.h \
|
iaf.h \
|
||||||
|
ifaddrs.h \
|
||||||
inttypes.h \
|
inttypes.h \
|
||||||
langinfo.h \
|
langinfo.h \
|
||||||
limits.h \
|
limits.h \
|
||||||
|
|
14
sshconnect.c
14
sshconnect.c
|
@ -44,7 +44,9 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ifaddrs.h>
|
#ifdef HAVE_IFADDRS_H
|
||||||
|
# include <ifaddrs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
|
@ -272,6 +274,7 @@ ssh_kill_proxy_command(void)
|
||||||
kill(proxy_command_pid, SIGHUP);
|
kill(proxy_command_pid, SIGHUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_IFADDRS_H
|
||||||
/*
|
/*
|
||||||
* Search a interface address list (returned from getifaddrs(3)) for an
|
* Search a interface address list (returned from getifaddrs(3)) for an
|
||||||
* address that matches the desired address family on the specifed interface.
|
* 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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Creates a (possibly privileged) socket for use as the ssh connection.
|
* 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;
|
struct sockaddr_storage bindaddr;
|
||||||
socklen_t bindaddrlen = 0;
|
socklen_t bindaddrlen = 0;
|
||||||
struct addrinfo hints, *res = NULL;
|
struct addrinfo hints, *res = NULL;
|
||||||
|
#ifdef HAVE_IFADDRS_H
|
||||||
struct ifaddrs *ifaddrs = NULL;
|
struct ifaddrs *ifaddrs = NULL;
|
||||||
|
#endif
|
||||||
char ntop[NI_MAXHOST];
|
char ntop[NI_MAXHOST];
|
||||||
|
|
||||||
sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
|
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);
|
memcpy(&bindaddr, res->ai_addr, res->ai_addrlen);
|
||||||
bindaddrlen = res->ai_addrlen;
|
bindaddrlen = res->ai_addrlen;
|
||||||
} else if (options.bind_interface != NULL) {
|
} else if (options.bind_interface != NULL) {
|
||||||
|
#ifdef HAVE_IFADDRS_H
|
||||||
if ((r = getifaddrs(&ifaddrs)) != 0) {
|
if ((r = getifaddrs(&ifaddrs)) != 0) {
|
||||||
error("getifaddrs: %s: %s", options.bind_interface,
|
error("getifaddrs: %s: %s", options.bind_interface,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
@ -392,6 +399,9 @@ ssh_create_socket(int privileged, struct addrinfo *ai)
|
||||||
options.bind_interface);
|
options.bind_interface);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
error("BindInterface not supported on this platform.");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if ((r = getnameinfo((struct sockaddr *)&bindaddr, bindaddrlen,
|
if ((r = getnameinfo((struct sockaddr *)&bindaddr, bindaddrlen,
|
||||||
ntop, sizeof(ntop), NULL, 0, NI_NUMERICHOST)) != 0) {
|
ntop, sizeof(ntop), NULL, 0, NI_NUMERICHOST)) != 0) {
|
||||||
|
@ -427,8 +437,10 @@ fail:
|
||||||
out:
|
out:
|
||||||
if (res != NULL)
|
if (res != NULL)
|
||||||
freeaddrinfo(res);
|
freeaddrinfo(res);
|
||||||
|
#ifdef HAVE_IFADDRS_H
|
||||||
if (ifaddrs != NULL)
|
if (ifaddrs != NULL)
|
||||||
freeifaddrs(ifaddrs);
|
freeifaddrs(ifaddrs);
|
||||||
|
#endif
|
||||||
return sock;
|
return sock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue