In sn2princ, getaddrinfo without AI_ADDRCONFIG
authorGreg Hudson <ghudson@mit.edu>
Thu, 3 May 2012 15:15:51 +0000 (15:15 +0000)
committerGreg Hudson <ghudson@mit.edu>
Thu, 3 May 2012 15:15:51 +0000 (15:15 +0000)
When canonicalizing a principal, use AI_CANONNAME alone in the hint
flags for getaddrinfo, for two reasons.  First, it works around a gnu
libc bug where getaddrinfo does a PTR lookup for the canonical name
(we tried to work around this in r24977 bug the addition of
AI_ADDRCONFIG caused the same problem as the use of AF_INET).  Second,
an IPv4-only host should be able create a principal for an IPv6-only
host even if it can't contact the host.

This does result in extra AAAA queries in the common case (IPv4-only
host contacting IPv4-only service), which is unfortunate.  But we need
to leave that optimization up to the platform at this point.

ticket: 7124

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25844 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/os/sn2princ.c

index 1bee5ae81e2721198b3977a4c178f4756f0aba7f..f149febdadef32235a33b70fefff6b27f3c6e72f 100644 (file)
@@ -105,7 +105,7 @@ krb5_sname_to_principal(krb5_context context, const char *hostname, const char *
                hostnames associated.  */
 
             memset(&hints, 0, sizeof(hints));
                hostnames associated.  */
 
             memset(&hints, 0, sizeof(hints));
-            hints.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
+            hints.ai_flags = AI_CANONNAME;
             err = getaddrinfo(hostname, 0, &hints, &ai);
             if (err) {
 #ifdef DEBUG_REFERRALS
             err = getaddrinfo(hostname, 0, &hints, &ai);
             if (err) {
 #ifdef DEBUG_REFERRALS