Don't suppress DNS search list by appending '.'
The original motivation was to avoid extra timeouts when the network is broken. However this doesn't avoid one of the timeouts and adds complexity and introduced bugs. To really suppress search lists use ndots.
This commit is contained in:
@@ -403,48 +403,11 @@ krb5_krbhst_get_addrinfo(krb5_context context, krb5_krbhst_info *host,
|
||||
if (host->ai == NULL) {
|
||||
struct addrinfo hints;
|
||||
char portstr[NI_MAXSERV];
|
||||
char *hostname = host->hostname;
|
||||
|
||||
snprintf (portstr, sizeof(portstr), "%d", host->port);
|
||||
make_hints(&hints, host->proto);
|
||||
|
||||
/**
|
||||
* First try this as an IP address, this allows us to add a
|
||||
* dot at the end to stop using the search domains.
|
||||
*/
|
||||
|
||||
hints.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV;
|
||||
|
||||
ret = getaddrinfo(host->hostname, portstr, &hints, &host->ai);
|
||||
if (ret == 0)
|
||||
goto out;
|
||||
|
||||
/**
|
||||
* If the hostname contains a dot, assumes it's a FQDN and
|
||||
* don't use search domains since that might be painfully slow
|
||||
* when machine is disconnected from that network.
|
||||
*
|
||||
* This does, however, inhibit /etc/hosts matches on some
|
||||
* systems. So we want to try it twice.
|
||||
*/
|
||||
|
||||
hints.ai_flags &= ~(AI_NUMERICHOST | AI_NUMERICSERV);
|
||||
|
||||
if (strchr(hostname, '.') && hostname[strlen(hostname) - 1] != '.') {
|
||||
ret = asprintf(&hostname, "%s.", host->hostname);
|
||||
if (ret < 0 || hostname == NULL)
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
ret = getaddrinfo(hostname, portstr, &hints, &host->ai);
|
||||
/*
|
||||
* Retry without the trailing '.' if the lookup failed for any
|
||||
* reason other than a timeout.
|
||||
*/
|
||||
if (ret != 0 && ret != EAI_AGAIN && ret != EAI_FAIL && hostname != host->hostname)
|
||||
ret = getaddrinfo(host->hostname, portstr, &hints, &host->ai);
|
||||
if (hostname != host->hostname)
|
||||
free(hostname);
|
||||
if (ret) {
|
||||
ret = krb5_eai_to_heim_errno(ret, errno);
|
||||
goto out;
|
||||
|
Reference in New Issue
Block a user