From: Ken Raeburn Date: Tue, 28 Feb 2012 16:15:56 +0000 (+0000) Subject: Require IPv6 support X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=666d801d3b1a288f59dc458ea1fb438dc4f4329a;p=krb5.git Require IPv6 support The configure-time options to enable and disable IPv6 support have been deprecated for some time, but the checks for OS support were kept. This removes those checks, and unconditionally compiles in the IPv6 support. There was a configure-time test to see if the macro INET6 needed to be defined in order to enable (visibility of) OS support for IPv6, which was needed on an IRIX system we tested with. That check is retained, but the revised code is untested on IRIX. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25719 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/aclocal.m4 b/src/aclocal.m4 index 7944532c6..c7aaf0c6e 100644 --- a/src/aclocal.m4 +++ b/src/aclocal.m4 @@ -389,8 +389,7 @@ if test $ac_cv_func_getaddrinfo = yes; then fi dnl AC_REQUIRE([KRB5_SOCKADDR_SA_LEN])dnl -AC_ARG_ENABLE([ipv6], , AC_MSG_WARN(enable/disable-ipv6 option is deprecated))dnl -AC_MSG_CHECKING(for IPv6 compile-time support) +AC_MSG_CHECKING(for IPv6 compile-time support without -DINET6) AC_CACHE_VAL(krb5_cv_inet6,[ if test "$ac_cv_func_inet_ntop" != "yes" ; then krb5_cv_inet6=no @@ -433,7 +432,6 @@ if test $krb5_cv_inet6 = yes || test "$krb5_cv_inet6_with_dinet6" = yes; then if test "$krb5_cv_inet6_with_dinet6" = yes; then AC_DEFINE(INET6,1,[May need to be defined to enable IPv6 support, for example on IRIX]) fi - AC_DEFINE(KRB5_USE_INET6,1,[Define if we should compile in IPv6 support (even if we can't use it at run time)]) fi ])dnl dnl diff --git a/src/clients/klist/klist.c b/src/clients/klist/klist.c index a9a917156..503a1149d 100644 --- a/src/clients/klist/klist.c +++ b/src/clients/klist/klist.c @@ -776,7 +776,6 @@ void one_addr(a) memcpy (&sinp->sin_addr, a->contents, 4); } break; -#ifdef KRB5_USE_INET6 case ADDRTYPE_INET6: if (a->length != 16) goto broken; @@ -789,7 +788,6 @@ void one_addr(a) memcpy (&sin6p->sin6_addr, a->contents, 16); } break; -#endif default: printf(_("unknown addrtype %d"), a->addrtype); return; diff --git a/src/include/fake-addrinfo.h b/src/include/fake-addrinfo.h index 5063ae800..03666a0aa 100644 --- a/src/include/fake-addrinfo.h +++ b/src/include/fake-addrinfo.h @@ -203,7 +203,7 @@ struct addrinfo { # define AI_DEFAULT (AI_ADDRCONFIG|AI_V4MAPPED) #endif -#if defined(KRB5_USE_INET6) && defined(NEED_INSIXADDR_ANY) +#if defined(NEED_INSIXADDR_ANY) /* If compiling with IPv6 support and C library does not define in6addr_any */ extern const struct in6_addr krb5int_in6addr_any; #undef in6addr_any diff --git a/src/include/socket-utils.h b/src/include/socket-utils.h index 19145c85f..484e294f8 100644 --- a/src/include/socket-utils.h +++ b/src/include/socket-utils.h @@ -51,7 +51,7 @@ Do NOT install this file. */ -/* for HAVE_SOCKLEN_T, KRB5_USE_INET6, etc */ +/* for HAVE_SOCKLEN_T etc */ #include "autoconf.h" /* for sockaddr_storage */ #include "port-sockets.h" @@ -72,12 +72,10 @@ static inline struct sockaddr_in *sa2sin (struct sockaddr *sa) { return (struct sockaddr_in *) (void *) sa; } -#ifdef KRB5_USE_INET6 static inline struct sockaddr_in6 *sa2sin6 (struct sockaddr *sa) { return (struct sockaddr_in6 *) (void *) sa; } -#endif static inline struct sockaddr *ss2sa (struct sockaddr_storage *ss) { return (struct sockaddr *) ss; @@ -86,23 +84,17 @@ static inline struct sockaddr_in *ss2sin (struct sockaddr_storage *ss) { return (struct sockaddr_in *) ss; } -#ifdef KRB5_USE_INET6 static inline struct sockaddr_in6 *ss2sin6 (struct sockaddr_storage *ss) { return (struct sockaddr_in6 *) ss; } -#endif #if !defined (socklen) /* socklen_t socklen (struct sockaddr *) */ # ifdef HAVE_SA_LEN # define socklen(X) ((X)->sa_len) # else -# ifdef KRB5_USE_INET6 -# define socklen(X) ((X)->sa_family == AF_INET6 ? (socklen_t) sizeof (struct sockaddr_in6) : (X)->sa_family == AF_INET ? (socklen_t) sizeof (struct sockaddr_in) : (socklen_t) sizeof (struct sockaddr)) -# else -# define socklen(X) ((X)->sa_family == AF_INET ? (socklen_t) sizeof (struct sockaddr_in) : (socklen_t) sizeof (struct sockaddr)) -# endif +# define socklen(X) ((X)->sa_family == AF_INET6 ? (socklen_t) sizeof (struct sockaddr_in6) : (X)->sa_family == AF_INET ? (socklen_t) sizeof (struct sockaddr_in) : (socklen_t) sizeof (struct sockaddr)) # endif #endif diff --git a/src/include/win-mac.h b/src/include/win-mac.h index 82d3ff736..53f274af7 100644 --- a/src/include/win-mac.h +++ b/src/include/win-mac.h @@ -115,7 +115,6 @@ typedef _W64 int ssize_t; #define SYS_ERRLIST_DECLARED /* if __STDC_VERSION__ >= 199901L this shouldn't be needed */ #define inline __inline -#define KRB5_USE_INET6 #define NEED_INSIXADDR_ANY #define ENABLE_THREADS #endif diff --git a/src/kadmin/server/schpw.c b/src/kadmin/server/schpw.c index d2df5db73..5b5bd9b90 100644 --- a/src/kadmin/server/schpw.c +++ b/src/kadmin/server/schpw.c @@ -244,7 +244,6 @@ process_chpw_request(krb5_context context, void *server_handle, char *realm, salen = sizeof(*sin); break; } -#ifdef KRB5_USE_INET6 case ADDRTYPE_INET6: { struct sockaddr_in6 *sin6 = ss2sin6(&ss); @@ -254,7 +253,6 @@ process_chpw_request(krb5_context context, void *server_handle, char *realm, salen = sizeof(*sin6); break; } -#endif default: { struct sockaddr *sa = ss2sa(&ss); diff --git a/src/kdc/kdc_util.h b/src/kdc/kdc_util.h index e80ce106f..982508a88 100644 --- a/src/kdc/kdc_util.h +++ b/src/kdc/kdc_util.h @@ -409,13 +409,8 @@ struct krb5_kdcpreauth_rock_st { #define max(a, b) ((a) > (b) ? (a) : (b)) #endif -#ifdef KRB5_USE_INET6 #define ADDRTYPE2FAMILY(X) \ ((X) == ADDRTYPE_INET6 ? AF_INET6 : (X) == ADDRTYPE_INET ? AF_INET : -1) -#else -#define ADDRTYPE2FAMILY(X) \ - ((X) == ADDRTYPE_INET ? AF_INET : -1) -#endif /* RFC 4120: KRB5KDC_ERR_KEY_TOO_WEAK * RFC 4556: KRB5KDC_ERR_DH_KEY_PARAMETERS_NOT_ACCEPTED */ diff --git a/src/lib/apputils/net-server.c b/src/lib/apputils/net-server.c index 43be27c95..fcc660d35 100644 --- a/src/lib/apputils/net-server.c +++ b/src/lib/apputils/net-server.c @@ -78,11 +78,9 @@ set_sa_port(struct sockaddr *addr, int port) case AF_INET: sa2sin(addr)->sin_port = port; break; -#ifdef KRB5_USE_INET6 case AF_INET6: sa2sin6(addr)->sin6_port = port; break; -#endif default: break; } @@ -91,7 +89,6 @@ set_sa_port(struct sockaddr *addr, int port) static int ipv6_enabled() { -#ifdef KRB5_USE_INET6 static int result = -1; if (result == -1) { int s; @@ -103,9 +100,6 @@ ipv6_enabled() result = 0; } return result; -#else - return 0; -#endif } static int @@ -114,7 +108,7 @@ setreuseaddr(int sock, int value) return setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &value, sizeof(value)); } -#if defined(KRB5_USE_INET6) && defined(IPV6_V6ONLY) +#if defined(IPV6_V6ONLY) static int setv6only(int sock, int value) { @@ -611,7 +605,6 @@ create_server_socket(struct socksetup *data, struct sockaddr *addr, int type) _("Cannot enable SO_REUSEADDR on fd %d"), sock); } -#ifdef KRB5_USE_INET6 if (addr->sa_family == AF_INET6) { #ifdef IPV6_V6ONLY if (setv6only(sock, 1)) @@ -624,7 +617,6 @@ create_server_socket(struct socksetup *data, struct sockaddr *addr, int type) krb5_klog_syslog(LOG_INFO, _("no IPV6_V6ONLY socket option support")); #endif /* IPV6_V6ONLY */ } -#endif /* KRB5_USE_INET6 */ if (bind(sock, addr, socklen(addr)) == -1) { data->retval = errno; @@ -737,9 +729,7 @@ static int setup_tcp_listener_ports(struct socksetup *data) { struct sockaddr_in sin4; -#ifdef KRB5_USE_INET6 struct sockaddr_in6 sin6; -#endif int i, port; memset(&sin4, 0, sizeof(sin4)); @@ -749,14 +739,12 @@ setup_tcp_listener_ports(struct socksetup *data) #endif sin4.sin_addr.s_addr = INADDR_ANY; -#ifdef KRB5_USE_INET6 memset(&sin6, 0, sizeof(sin6)); sin6.sin6_family = AF_INET6; #ifdef SIN6_LEN sin6.sin6_len = sizeof(sin6); #endif sin6.sin6_addr = in6addr_any; -#endif FOREACH_ELT (tcp_port_data, i, port) { int s4, s6; @@ -768,9 +756,6 @@ setup_tcp_listener_ports(struct socksetup *data) return -1; s6 = -1; } else { -#ifndef KRB5_USE_INET6 - abort(); -#else s4 = s6 = -1; set_sa_port((struct sockaddr *)&sin6, htons(port)); @@ -780,7 +765,6 @@ setup_tcp_listener_ports(struct socksetup *data) return -1; s4 = setup_a_tcp_listener(data, (struct sockaddr *)&sin4); -#endif /* KRB5_USE_INET6 */ } /* Sockets are created, prepare to listen on them. */ @@ -792,7 +776,6 @@ setup_tcp_listener_ports(struct socksetup *data) s4, paddr((struct sockaddr *)&sin4)); } } -#ifdef KRB5_USE_INET6 if (s6 >= 0) { if (add_tcp_listener_fd(data, s6) == NULL) { close(s6); @@ -805,7 +788,6 @@ setup_tcp_listener_ports(struct socksetup *data) krb5_klog_syslog(LOG_INFO, _("assuming IPv6 socket accepts IPv4")); } -#endif } return 0; } @@ -814,9 +796,7 @@ static int setup_rpc_listener_ports(struct socksetup *data) { struct sockaddr_in sin4; -#ifdef KRB5_USE_INET6 struct sockaddr_in6 sin6; -#endif int i; struct rpc_svc_data svc; @@ -827,20 +807,16 @@ setup_rpc_listener_ports(struct socksetup *data) #endif sin4.sin_addr.s_addr = INADDR_ANY; -#ifdef KRB5_USE_INET6 memset(&sin6, 0, sizeof(sin6)); sin6.sin6_family = AF_INET6; #ifdef HAVE_SA_LEN sin6.sin6_len = sizeof(sin6); #endif sin6.sin6_addr = in6addr_any; -#endif FOREACH_ELT (rpc_svc_data, i, svc) { int s4; -#ifdef KRB5_USE_INET6 int s6; -#endif set_sa_port((struct sockaddr *)&sin4, htons(svc.port)); s4 = create_server_socket(data, (struct sockaddr *)&sin4, SOCK_STREAM); @@ -853,7 +829,6 @@ setup_rpc_listener_ports(struct socksetup *data) krb5_klog_syslog(LOG_INFO, _("listening on fd %d: rpc %s"), s4, paddr((struct sockaddr *)&sin4)); -#ifdef KRB5_USE_INET6 if (ipv6_enabled()) { set_sa_port((struct sockaddr *)&sin6, htons(svc.port)); s6 = create_server_socket(data, (struct sockaddr *)&sin6, @@ -867,7 +842,6 @@ setup_rpc_listener_ports(struct socksetup *data) krb5_klog_syslog(LOG_INFO, _("listening on fd %d: rpc %s"), s6, paddr((struct sockaddr *)&sin6)); } -#endif } return 0; @@ -992,18 +966,7 @@ setup_udp_port(void *P_data, struct sockaddr *addr) break; #ifdef AF_INET6 case AF_INET6: -#ifdef KRB5_USE_INET6 break; -#else - { - static int first = 1; - if (first) { - krb5_klog_syslog(LOG_INFO, _("skipping local ipv6 addresses")); - first = 0; - } - return 0; - } -#endif #endif #ifdef AF_LINK /* some BSD systems, AIX */ case AF_LINK: @@ -1312,7 +1275,6 @@ init_addr(krb5_fulladdr *faddr, struct sockaddr *sa) faddr->address->contents = (krb5_octet *) &sa2sin(sa)->sin_addr; faddr->port = ntohs(sa2sin(sa)->sin_port); break; -#ifdef KRB5_USE_INET6 case AF_INET6: if (IN6_IS_ADDR_V4MAPPED(&sa2sin6(sa)->sin6_addr)) { faddr->address->addrtype = ADDRTYPE_INET; @@ -1325,7 +1287,6 @@ init_addr(krb5_fulladdr *faddr, struct sockaddr *sa) } faddr->port = ntohs(sa2sin6(sa)->sin6_port); break; -#endif default: faddr->address->addrtype = -1; faddr->address->length = 0; @@ -1412,8 +1373,7 @@ recv_from_to(int s, void *buf, size_t len, int flags, return r; } #endif -#if defined(KRB5_USE_INET6) && defined(IPV6_PKTINFO) && \ - defined(HAVE_STRUCT_IN6_PKTINFO) +#if defined(IPV6_PKTINFO) && defined(HAVE_STRUCT_IN6_PKTINFO) if (cmsgptr->cmsg_level == IPPROTO_IPV6 && cmsgptr->cmsg_type == IPV6_PKTINFO && *tolen >= sizeof(struct sockaddr_in6)) { @@ -1489,8 +1449,7 @@ send_to_from(int s, void *buf, size_t len, int flags, msg.msg_controllen = CMSG_SPACE(sizeof(struct in_pktinfo)); break; #endif -#if defined(KRB5_USE_INET6) && defined(IPV6_PKTINFO) && \ - defined(HAVE_STRUCT_IN6_PKTINFO) +#if defined(IPV6_PKTINFO) && defined(HAVE_STRUCT_IN6_PKTINFO) case AF_INET6: if (fromlen != sizeof(struct sockaddr_in6)) goto use_sendto; diff --git a/src/lib/krb5/os/genaddrs.c b/src/lib/krb5/os/genaddrs.c index b31c0bca6..5ef7af5a3 100644 --- a/src/lib/krb5/os/genaddrs.c +++ b/src/lib/krb5/os/genaddrs.c @@ -47,7 +47,6 @@ static void *cvtaddr (struct sockaddr_storage *a, struct addrpair *ap) SET (ap->port, ss2sin(a)->sin_port, ADDRTYPE_IPPORT); SET (ap->addr, ss2sin(a)->sin_addr, ADDRTYPE_INET); return a; -#ifdef KRB5_USE_INET6 case AF_INET6: SET (ap->port, ss2sin6(a)->sin6_port, ADDRTYPE_IPPORT); if (IN6_IS_ADDR_V4MAPPED (&ss2sin6(a)->sin6_addr)) { @@ -57,7 +56,6 @@ static void *cvtaddr (struct sockaddr_storage *a, struct addrpair *ap) } else SET (ap->addr, ss2sin6(a)->sin6_addr, ADDRTYPE_INET6); return a; -#endif default: return 0; } diff --git a/src/lib/krb5/os/hostaddr.c b/src/lib/krb5/os/hostaddr.c index 5046f9b31..6be2abea8 100644 --- a/src/lib/krb5/os/hostaddr.c +++ b/src/lib/krb5/os/hostaddr.c @@ -59,9 +59,7 @@ krb5_os_hostaddr(krb5_context context, const char *name, for (i = 0, aip = ai; aip; aip = aip->ai_next) { switch (aip->ai_addr->sa_family) { case AF_INET: -#ifdef KRB5_USE_INET6 case AF_INET6: -#endif i++; default: /* Ignore addresses of unknown families. */ @@ -87,13 +85,11 @@ krb5_os_hostaddr(krb5_context context, const char *name, ptr = &((struct sockaddr_in *)aip->ai_addr)->sin_addr; atype = ADDRTYPE_INET; break; -#ifdef KRB5_USE_INET6 case AF_INET6: addrlen = sizeof (struct in6_addr); ptr = &((struct sockaddr_in6 *)aip->ai_addr)->sin6_addr; atype = ADDRTYPE_INET6; break; -#endif default: continue; } diff --git a/src/lib/krb5/os/localaddr.c b/src/lib/krb5/os/localaddr.c index 08f628a55..faa214a4a 100644 --- a/src/lib/krb5/os/localaddr.c +++ b/src/lib/krb5/os/localaddr.c @@ -114,7 +114,7 @@ */ -#if defined(__linux__) && defined(KRB5_USE_INET6) && !defined(HAVE_IFADDRS_H) +#if defined(__linux__) && !defined(HAVE_IFADDRS_H) #define LINUX_IPV6_HACK #endif @@ -183,12 +183,10 @@ is_loopback_address(struct sockaddr *sa) struct sockaddr_in *s4 = (struct sockaddr_in *)sa; return s4->sin_addr.s_addr == htonl(INADDR_LOOPBACK); } -#ifdef KRB5_USE_INET6 case AF_INET6: { struct sockaddr_in6 *s6 = (struct sockaddr_in6 *)sa; return IN6_IS_ADDR_LOOPBACK(&s6->sin6_addr); } -#endif default: return 0; } @@ -1123,9 +1121,7 @@ count_addrs (void *P_data, struct sockaddr *a) struct localaddr_data *data = P_data; switch (a->sa_family) { case AF_INET: -#ifdef KRB5_USE_INET6 case AF_INET6: -#endif #ifdef KRB5_USE_NS case AF_XNS: #endif @@ -1197,7 +1193,6 @@ add_addr (void *P_data, struct sockaddr *a) data->mem_err++; break; -#ifdef KRB5_USE_INET6 case AF_INET6: { const struct sockaddr_in6 *in = (const struct sockaddr_in6 *) a; @@ -1211,7 +1206,6 @@ add_addr (void *P_data, struct sockaddr *a) data->mem_err++; break; } -#endif /* KRB5_USE_INET6 */ #endif /* netinet/in.h */ #ifdef KRB5_USE_NS @@ -1414,7 +1408,6 @@ get_localaddrs (krb5_context context, krb5_address ***addr, int use_profile) #endif break; } -#ifdef KRB5_USE_INET6 case ADDRTYPE_INET6: { struct sockaddr_in6 *sin6p = ss2sin6 (&ss); @@ -1425,7 +1418,6 @@ get_localaddrs (krb5_context context, krb5_address ***addr, int use_profile) #endif break; } -#endif default: ss2sa(&ss)->sa_family = 0; break; diff --git a/src/lib/krb5/os/locate_kdc.c b/src/lib/krb5/os/locate_kdc.c index acfce8c87..89ef549a0 100644 --- a/src/lib/krb5/os/locate_kdc.c +++ b/src/lib/krb5/os/locate_kdc.c @@ -361,10 +361,8 @@ module_callback(void *cbdata, int socktype, struct sockaddr *sa) return 0; if (sa->sa_family == AF_INET) addrlen = sizeof(struct sockaddr_in); -#ifdef KRB5_USE_INET6 else if (sa->sa_family == AF_INET6) addrlen = sizeof(struct sockaddr_in6); -#endif else return 0; if (add_addr_to_list(d->list, socktype, sa->sa_family, addrlen, diff --git a/src/lib/krb5/os/t_std_conf.c b/src/lib/krb5/os/t_std_conf.c index 59ca7d605..74987b157 100644 --- a/src/lib/krb5/os/t_std_conf.c +++ b/src/lib/krb5/os/t_std_conf.c @@ -133,7 +133,6 @@ test_locate_kdc(krb5_context ctx, char *realm) ntohs(s_sin->sin_port)); } break; -#ifdef KRB5_USE_INET6 case AF_INET6: { struct sockaddr_in6 *s_sin6 = (struct sockaddr_in6 *)&entry->addr; @@ -146,7 +145,6 @@ test_locate_kdc(krb5_context ctx, char *realm) printf("/%d", ntohs(s_sin6->sin6_port)); break; } -#endif default: printf(" unknown-af-%d", entry->family); break; diff --git a/src/slave/kpropd.c b/src/slave/kpropd.c index 73e8da93e..14304c4fb 100644 --- a/src/slave/kpropd.c +++ b/src/slave/kpropd.c @@ -248,12 +248,10 @@ get_wildcard_addr(struct addrinfo **res) memset(&hints, 0, sizeof(hints)); hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG; -#ifdef KRB5_USE_INET6 hints.ai_family = AF_INET6; error = getaddrinfo(NULL, port, &hints, res); if (error == 0) return 0; -#endif hints.ai_family = AF_INET; return getaddrinfo(NULL, port, &hints, res); } @@ -288,7 +286,7 @@ retry: if (setsockopt(finet, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) < 0) com_err(progname, errno, _("while setting SO_REUSEADDR option")); -#if defined(KRB5_USE_INET6) && defined(IPV6_V6ONLY) +#if defined(IPV6_V6ONLY) /* Make sure dual-stack support is enabled on IPv6 listener sockets if * possible. */ val = 0; diff --git a/src/util/support/fake-addrinfo.c b/src/util/support/fake-addrinfo.c index 64d84e5ca..4efecd540 100644 --- a/src/util/support/fake-addrinfo.c +++ b/src/util/support/fake-addrinfo.c @@ -552,9 +552,7 @@ static inline int fai_add_entry (struct addrinfo **result, void *addr, if (n == 0) return EAI_MEMORY; if (template->ai_family != AF_INET -#ifdef KRB5_USE_INET6 && template->ai_family != AF_INET6 -#endif ) return EAI_FAMILY; *n = *template; @@ -572,7 +570,6 @@ static inline int fai_add_entry (struct addrinfo **result, void *addr, sin4->sin_len = sizeof (struct sockaddr_in); #endif } -#ifdef KRB5_USE_INET6 if (template->ai_family == AF_INET6) { struct sockaddr_in6 *sin6; sin6 = malloc (sizeof (struct sockaddr_in6)); @@ -587,7 +584,6 @@ static inline int fai_add_entry (struct addrinfo **result, void *addr, sin6->sin6_len = sizeof (struct sockaddr_in6); #endif } -#endif n->ai_next = *result; *result = n; return 0; @@ -1355,15 +1351,8 @@ static int krb5int_unlock_fac (void) } #endif -#if defined(KRB5_USE_INET6) /* Some systems don't define in6addr_any. */ const struct in6_addr krb5int_in6addr_any = IN6ADDR_ANY_INIT; -#else -/* Are any of the systems without IPv6 support among those where - we cross-check the actual exported symbols against the export - list? Not sure, play it safe. */ -const char krb5int_in6addr_any = 0; -#endif int krb5int_getaddrinfo (const char *node, const char *service, const struct addrinfo *hints,