4a5ca5b2d3
during krb5_sname_to_principal(), and to let getaddrinfo() decide whether or not to ask for an IPv6 address based on the set of configured interfaces (RT#6922)
31 lines
1.3 KiB
Diff
31 lines
1.3 KiB
Diff
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);
|