summaryrefslogtreecommitdiffstats
path: root/krb5-1.9.1-ai_addrconfig.patch
blob: 5e2d2012329922214f3ec024694060a5e2a27826 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
From RT#6922.  When we're converting a host/service pair into a principal
name, specify AF_UNSPEC instead of AF_INET4 and then maybe AF_INET6 to try
to avoid libc having doing a PTR lookup because we also specify
AI_CANONNAME.  Add AI_ADDRCONFIG because it's usually the right idea.

Index: src/lib/krb5/os/sn2princ.c
===================================================================
--- src/lib/krb5/os/sn2princ.c	(revision 24976)
+++ src/lib/krb5/os/sn2princ.c	(revision 24977)
@@ -105,19 +105,12 @@
                hostnames associated.  */
 
             memset(&hints, 0, sizeof(hints));
-            hints.ai_family = AF_INET;
-            hints.ai_flags = AI_CANONNAME;
-        try_getaddrinfo_again:
+            hints.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
             err = getaddrinfo(hostname, 0, &hints, &ai);
             if (err) {
 #ifdef DEBUG_REFERRALS
                 printf("sname_to_princ: probably punting due to bad hostname of %s\n",hostname);
 #endif
-                if (hints.ai_family == AF_INET) {
-                    /* Just in case it's an IPv6-only name.  */
-                    hints.ai_family = 0;
-                    goto try_getaddrinfo_again;
-                }
                 return KRB5_ERR_BAD_HOSTNAME;
             }
             remote_host = strdup(ai->ai_canonname ? ai->ai_canonname : hostname);