Bug#60743: libc6: getaddrinfo tries to resolve in an order disobeying /etc/host.conf
Package: libc6
Version: 2.1.3-7
Severity: normal
This is a report which is nearly the same as #58713. That I file this again
(instead of as info of #58713) is that I want to be acknowledged for any
progress.
I've looked at the problem of that ssh ignoring /etc/hosts, and found that
the line calling getaddrinfo caused the problem. DNS is consulted by that
call, even if /etc/hosts does contain the entry required.
After some work I bring the whole problem down to the following program:
#include <netdb.h>
#include <string.h>
int
main()
{
char *host = "sinken"; /* A host in /etc/hosts */
struct addrinfo hints, *ai;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC; /* work correctly if changed to AF_INET */
hints.ai_flags = AI_CANONNAME;
hints.ai_socktype = SOCK_STREAM;
getaddrinfo(host, NULL, &hints, &ai); /* Generates DNS query */
}
I've tried to get the libc6 source for inspection, although it seems to be
more complicated than what can be handled by a clueless guy. On the other
hand, in sysdeps/posix/getaddrinfo.c, it seems to handle every gaih entries
(line 564) one by one, before the corresponding function in lib_nssXXX is
called. If this is the problem, it would be a management nightmare, since
all IPv4 addresses will be overridden by any IPv6 address. This, of course,
is also the root of the SSH problem: when the IPv6 address is searched, it
triggers DNS query. Unless the DNS query declare itself fails, /etc/hosts
will not be sought again for an IPv4 address.
-- System Information
Debian Release: 2.2
Kernel Version: Linux hwpg11 2.2.13 #1 Wed Oct 20 14:01:25 CST 1999 i486 unknown
Versions of the packages libc6 depends on:
ii ldso 1.9.11-5 The Linux dynamic linker, library and utilit
Reply to: