Don't inhibit /etc/hosts matches (fix #32)
Apending '.' to the hostname passed to `getaddrinfo()` is good for avoiding extra timeouts when the search list is non-empty and the network is broken, but searches in /etc/hosts are typically inhibited then. The fix is to try again without the trailing '.' if the first lookup failed for any reason other than a timeout.
This commit is contained in:
@@ -423,6 +423,9 @@ krb5_krbhst_get_addrinfo(krb5_context context, krb5_krbhst_info *host,
|
|||||||
* If the hostname contains a dot, assumes it's a FQDN and
|
* If the hostname contains a dot, assumes it's a FQDN and
|
||||||
* don't use search domains since that might be painfully slow
|
* don't use search domains since that might be painfully slow
|
||||||
* when machine is disconnected from that network.
|
* 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);
|
hints.ai_flags &= ~(AI_NUMERICHOST);
|
||||||
@@ -434,6 +437,12 @@ krb5_krbhst_get_addrinfo(krb5_context context, krb5_krbhst_info *host,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = getaddrinfo(hostname, portstr, &hints, &host->ai);
|
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)
|
if (hostname != host->hostname)
|
||||||
free(hostname);
|
free(hostname);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
Reference in New Issue
Block a user