summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/lib/interfaces.c17
-rw-r--r--source3/lib/system.c24
-rw-r--r--source3/lib/util_sock.c7
-rw-r--r--source3/utils/net_lookup.c2
4 files changed, 43 insertions, 7 deletions
diff --git a/source3/lib/interfaces.c b/source3/lib/interfaces.c
index 38abb9299b..01481c50e9 100644
--- a/source3/lib/interfaces.c
+++ b/source3/lib/interfaces.c
@@ -696,6 +696,16 @@ int get_interfaces(struct iface_struct *ifaces, int max_interfaces)
#ifdef AUTOCONF_TEST
/* this is the autoconf driver to test get_interfaces() */
+static socklen_t calc_sa_size(struct sockaddr *psa)
+{
+ socklen_t sl = sizeof(struct sockaddr_in);
+#if defined(HAVE_IPV6)
+ if (psa->sa_family == AF_INET6) {
+ salen = sizeof(struct sockaddr_in6);
+ }
+#endif
+}
+
int main()
{
struct iface_struct ifaces[MAX_INTERFACES];
@@ -710,22 +720,23 @@ int get_interfaces(struct iface_struct *ifaces, int max_interfaces)
for (i=0;i<total;i++) {
char addr[INET6_ADDRSTRLEN];
int ret;
+ socklen_t sl;
printf("%-10s ", ifaces[i].name);
addr[0] = '\0';
ret = getnameinfo((struct sockaddr *)&ifaces[i].ip,
- sizeof(ifaces[i].ip),
+ calc_sa_size(&ifaces[i].ip),
addr, sizeof(addr),
NULL, 0, NI_NUMERICHOST);
printf("IP=%s ", addr);
addr[0] = '\0';
ret = getnameinfo((struct sockaddr *)&ifaces[i].netmask,
- sizeof(ifaces[i].netmask),
+ calc_sa_size(&ifaces[i].netmask),
addr, sizeof(addr),
NULL, 0, NI_NUMERICHOST);
printf("NETMASK=%s ", addr);
addr[0] = '\0';
ret = getnameinfo((struct sockaddr *)&ifaces[i].bcast,
- sizeof(ifaces[i].bcast),
+ calc_sa_size(&ifaces[i].bcast),
addr, sizeof(addr),
NULL, 0, NI_NUMERICHOST);
printf("BCAST=%s\n", addr);
diff --git a/source3/lib/system.c b/source3/lib/system.c
index 604228233c..fe4e700176 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -2545,3 +2545,27 @@ int sys_getpeereid( int s, uid_t *uid)
return -1;
#endif
}
+
+int sys_getnameinfo(const struct sockaddr *psa,
+ socklen_t salen,
+ char *host,
+ size_t hostlen,
+ char *service,
+ size_t servlen,
+ int flags)
+{
+ /*
+ * For Solaris we must make sure salen is the
+ * correct length for the incoming sa_family.
+ */
+
+ if (salen == sizeof(struct sockaddr_storage)) {
+ salen = sizeof(struct sockaddr_in);
+#if defined(HAVE_IPV6)
+ if (psa->sa_family == AF_INET6) {
+ salen = sizeof(struct sockaddr_in6);
+ }
+#endif
+ }
+ return getnameinfo(psa, salen, host, hostlen, service, servlen, flags);
+}
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index bbcbcacb4a..b4fda54ebd 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -495,7 +495,7 @@ bool is_address_any(const struct sockaddr_storage *psa)
Print out an IPv4 or IPv6 address from a struct sockaddr_storage.
****************************************************************************/
-char *print_sockaddr_len(char *dest,
+static char *print_sockaddr_len(char *dest,
size_t destlen,
const struct sockaddr_storage *psa,
socklen_t psalen)
@@ -503,7 +503,7 @@ char *print_sockaddr_len(char *dest,
if (destlen > 0) {
dest[0] = '\0';
}
- (void)getnameinfo((const struct sockaddr *)psa,
+ (void)sys_getnameinfo((const struct sockaddr *)psa,
psalen,
dest, destlen,
NULL, 0,
@@ -519,7 +519,8 @@ char *print_sockaddr(char *dest,
size_t destlen,
const struct sockaddr_storage *psa)
{
- return print_sockaddr_len(dest, destlen, psa, sizeof(*psa));
+ return print_sockaddr_len(dest, destlen, psa,
+ sizeof(struct sockaddr_storage));
}
/****************************************************************************
diff --git a/source3/utils/net_lookup.c b/source3/utils/net_lookup.c
index f7af1f2bb3..5e3551b781 100644
--- a/source3/utils/net_lookup.c
+++ b/source3/utils/net_lookup.c
@@ -131,7 +131,7 @@ static int net_lookup_ldap(int argc, const char **argv)
return -1;
}
- ret = getnameinfo((struct sockaddr *)&ss,
+ ret = sys_getnameinfo((struct sockaddr *)&ss,
sizeof(struct sockaddr_storage),
h_name, sizeof(h_name),
NULL, 0,