glibc 2.10 introduces a regression in getaddrinfo(); with a standard nsswitch.conf: $ grep host /etc/nsswitch.conf hosts: files dns $ and no /etc/hosts file on the system (which is legitimate; e.g., in a chroot): $ cat /etc/hosts cat: /etc/hosts: No such file or directory $ all calls to getaddrinfo() will fail, short-circuited by an nss_files failure before invoking nss_dns. Trivial test case, patch to follow.
Created attachment 4142 [details] test case
Created attachment 4143 [details] patch to nss_files fixing getaddrinfo when /etc/hosts is absent
I applied the patch.
Seems the fix is incorrect, on 2.11 I get: bash-4.0# gcc bug-408901.c bash-4.0# ./a.out www.redhat.com www.redhat.com -5 bash-4.0# touch /etc/hosts bash-4.0# ./a.out www.redhat.com www.redhat.com 0 It seems that returning NO_DATA (in the patch) stops the host search prematurely. Instead returning HOST_NOT_FOUND fix the issue, and sounds more logical.
Appears to be working fine with 2.17.