Add configure check for struct in6_addr instead of relying on AF_INET6

since some systems define AF_INET6 but do not include IPv6 support.
This commit is contained in:
Todd C. Miller
2007-10-24 16:41:19 +00:00
parent c50e7d4c06
commit 0d22c2f98d
6 changed files with 93 additions and 18 deletions

View File

@@ -168,6 +168,9 @@
/* Define to 1 if your Kerberos is Heimdal. */
#undef HAVE_HEIMDAL
/* Define to 1 if <netinet/in.h> contains struct in6_addr. */
#undef HAVE_IN6_ADDR
/* Define to 1 if you have the `initgroups' function. */
#undef HAVE_INITGROUPS

69
configure vendored
View File

@@ -13984,6 +13984,73 @@ _ACEOF
fi
{ echo "$as_me:$LINENO: checking for struct in6_addr" >&5
echo $ECHO_N "checking for struct in6_addr... $ECHO_C" >&6; }
if test "${ac_cv_type_struct_in6_addr+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <sys/types.h>
#include <netinet/in.h>
typedef struct in6_addr ac__type_new_;
int
main ()
{
if ((ac__type_new_ *) 0)
return 0;
if (sizeof (ac__type_new_))
return 0;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_type_struct_in6_addr=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_type_struct_in6_addr=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ echo "$as_me:$LINENO: result: $ac_cv_type_struct_in6_addr" >&5
echo "${ECHO_T}$ac_cv_type_struct_in6_addr" >&6; }
if test $ac_cv_type_struct_in6_addr = yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_STRUCT_IN6_ADDR 1
_ACEOF
cat >>confdefs.h <<\_ACEOF
#define HAVE_IN6_ADDR 1
_ACEOF
fi
{ echo "$as_me:$LINENO: checking for size_t" >&5
echo $ECHO_N "checking for size_t... $ECHO_C" >&6; }
if test "${sudo_cv_type_size_t+set}" = set; then
@@ -23237,6 +23304,8 @@ fi

View File

@@ -1661,6 +1661,8 @@ AC_CHECK_TYPE([struct timespec], [AC_DEFINE(HAVE_TIMESPEC)], [], [#include <sys/
# include <sys/time.h>
#endif
#include <time.h>])
AC_CHECK_TYPES([struct in6_addr], [AC_DEFINE(HAVE_IN6_ADDR)], [], [#include <sys/types.h>
#include <netinet/in.h>])
SUDO_TYPE_SIZE_T
SUDO_TYPE_SSIZE_T
SUDO_TYPE_DEV_T
@@ -2427,6 +2429,7 @@ AH_TEMPLATE(HAVE_GETSPNAM, [Define to 1 if you have the `getspnam' function (SVR
AH_TEMPLATE(HAVE_GETSPWUID, [Define to 1 if you have the `getspwuid' function. (HP-UX <= 9.X shadow passwords)])
AH_TEMPLATE(HAVE_GSS_KRB5_CCACHE_NAME, [Define to 1 if you have the `gss_krb5_ccache_name' function.])
AH_TEMPLATE(HAVE_HEIMDAL, [Define to 1 if your Kerberos is Heimdal.])
AH_TEMPLATE(HAVE_IN6_ADDR, [Define to 1 if <netinet/in.h> contains struct in6_addr.])
AH_TEMPLATE(HAVE_ISCOMSEC, [Define to 1 if you have the `iscomsec' function. (HP-UX >= 10.x check for shadow enabled)])
AH_TEMPLATE(HAVE_ISSECURE, [Define to 1 if you have the `issecure' function. (SunOS 4.x check for shadow enabled)])
AH_TEMPLATE(HAVE_KERB4, [Define to 1 if you use Kerberos IV.])

View File

@@ -99,7 +99,7 @@ load_interfaces()
{
struct ifaddrs *ifa, *ifaddrs;
struct sockaddr_in *sin;
#ifdef AF_INET6
#ifdef HAVE_IN6_ADDR
struct sockaddr_in6 *sin6;
#endif
int i;
@@ -116,7 +116,7 @@ load_interfaces()
switch(ifa->ifa_addr->sa_family) {
case AF_INET:
#ifdef AF_INET6
#ifdef HAVE_IN6_ADDR
case AF_INET6:
#endif
num_interfaces++;
@@ -146,7 +146,7 @@ load_interfaces()
interfaces[i].family = AF_INET;
i++;
break;
#ifdef AF_INET6
#ifdef HAVE_IN6_ADDR
case AF_INET6:
sin6 = (struct sockaddr_in6 *)ifa->ifa_addr;
memcpy(&interfaces[i].addr, &sin6->sin6_addr,
@@ -157,7 +157,7 @@ load_interfaces()
interfaces[i].family = AF_INET6;
i++;
break;
#endif /* AF_INET6 */
#endif /* HAVE_IN6_ADDR */
}
}
#ifdef HAVE_FREEIFADDRS
@@ -320,7 +320,7 @@ void
dump_interfaces()
{
int i;
#ifdef AF_INET6
#ifdef HAVE_IN6_ADDR
char addrbuf[INET6_ADDRSTRLEN], maskbuf[INET6_ADDRSTRLEN];
#endif
@@ -331,7 +331,7 @@ dump_interfaces()
printf("\t%s / ", inet_ntoa(interfaces[i].addr.ip4));
puts(inet_ntoa(interfaces[i].netmask.ip4));
break;
#ifdef AF_INET6
#ifdef HAVE_IN6_ADDR
case AF_INET6:
inet_ntop(AF_INET6, &interfaces[i].addr.ip6,
addrbuf, sizeof(addrbuf));
@@ -339,7 +339,7 @@ dump_interfaces()
maskbuf, sizeof(maskbuf));
printf("\t%s / %s\n", addrbuf, maskbuf);
break;
#endif /* AF_INET6 */
#endif /* HAVE_IN6_ADDR */
}
}
}

View File

@@ -30,13 +30,13 @@ struct interface {
int family; /* AF_INET or AF_INET6 */
union {
struct in_addr ip4;
#ifdef AF_INET6
#ifdef HAVE_IN6_ADDR
struct in6_addr ip6;
#endif
} addr;
union {
struct in_addr ip4;
#ifdef AF_INET6
#ifdef HAVE_IN6_ADDR
struct in6_addr ip6;
#endif
} netmask;

18
match.c
View File

@@ -484,13 +484,13 @@ addr_matches_if(n)
int i;
struct in_addr addr;
struct interface *ifp;
#ifdef AF_INET6
#ifdef HAVE_IN6_ADDR
struct in6_addr addr6;
int j;
#endif
int family;
#ifdef AF_INET6
#ifdef HAVE_IN6_ADDR
if (inet_pton(AF_INET6, n, &addr6) > 0) {
family = AF_INET6;
} else
@@ -511,7 +511,7 @@ addr_matches_if(n)
== addr.s_addr)
return(TRUE);
break;
#ifdef AF_INET6
#ifdef HAVE_IN6_ADDR
case AF_INET6:
if (memcmp(ifp->addr.ip6.s6_addr, addr6.s6_addr,
sizeof(addr6.s6_addr)) == 0)
@@ -537,13 +537,13 @@ addr_matches_if_netmask(n, m)
int i;
struct in_addr addr, mask;
struct interface *ifp;
#ifdef AF_INET6
#ifdef HAVE_IN6_ADDR
struct in6_addr addr6, mask6;
int j;
#endif
int family;
#ifdef AF_INET6
#ifdef HAVE_IN6_ADDR
if (inet_pton(AF_INET6, n, &addr6) > 0)
family = AF_INET6;
else
@@ -564,7 +564,7 @@ addr_matches_if_netmask(n, m)
mask.s_addr = htonl(mask.s_addr);
}
}
#ifdef AF_INET6
#ifdef HAVE_IN6_ADDR
else {
if (inet_pton(AF_INET6, m, &mask6) <= 0) {
j = atoi(m);
@@ -578,7 +578,7 @@ addr_matches_if_netmask(n, m)
}
}
}
#endif /* AF_INET6 */
#endif /* HAVE_IN6_ADDR */
for (i = 0; i < num_interfaces; i++) {
ifp = &interfaces[i];
@@ -588,7 +588,7 @@ addr_matches_if_netmask(n, m)
case AF_INET:
if ((ifp->addr.ip4.s_addr & mask.s_addr) == addr.s_addr)
return(TRUE);
#ifdef AF_INET6
#ifdef HAVE_IN6_ADDR
case AF_INET6:
for (j = 0; j < sizeof(addr6.s6_addr); j++) {
if ((ifp->addr.ip6.s6_addr[j] & mask6.s6_addr[j]) != addr6.s6_addr[j])
@@ -596,7 +596,7 @@ addr_matches_if_netmask(n, m)
}
if (j == sizeof(addr6.s6_addr))
return(TRUE);
#endif /* AF_INET6 */
#endif /* HAVE_IN6_ADDR */
}
}