]> granicus.if.org Git - sudo/commitdiff
Add configure check for struct in6_addr instead of relying on AF_INET6
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 24 Oct 2007 16:41:19 +0000 (16:41 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 24 Oct 2007 16:41:19 +0000 (16:41 +0000)
since some systems define AF_INET6 but do not include IPv6 support.

config.h.in
configure
configure.in
interfaces.c
interfaces.h
match.c

index a97caf4095d71719c92df318f3225c4ecd904107..aa63f2a404bc5a31af85df5338b231562fdce586 100644 (file)
 /* 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
 
index dac68dbd2795f2495bbedb601644a96f9bed4036..fc93b4a0e62350a8aa2c37c2979ee3448effb09a 100755 (executable)
--- a/configure
+++ b/configure
@@ -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
 
 
 
+
+
 
 
 
index 701ee4bf011c3ff864fbd1eab519f41daee7d86f..49d42c2cc2f8e446fac48dadf36be7b15c44f377 100644 (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.])
index f71cb8a7a73da39c2e0e58aad9b19fbc24c51b6d..537131803528f0f3b51f3d53f24b35a963942471 100644 (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 */
        }
     }
 }
index 8b6f1675c6a21251d7ad2cd5e0ccfadbb41e1adc..165a32e579b9c1c6e837f735961fdbcee231a463 100644 (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;
diff --git a/match.c b/match.c
index 5a31e0038dce688444ddff2755c499ba980c27ea..448761b100eba7f8c579cab794a4d6373267fa97 100644 (file)
--- a/match.c
+++ b/match.c
@@ -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 */
        }
     }