This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
[bug] nss resolver code doesn't stop at files lookup
- To: libc-alpha at sources dot redhat dot com
- Subject: [bug] nss resolver code doesn't stop at files lookup
- From: Ben Collins <bcollins at debian dot org>
- Date: Fri, 10 Nov 2000 21:01:06 -0500
This is pretty easy to reproduce. Basically what happens (and can be seen
from an strace) is that that with getaddrinfo(), a success on a /etc/hosts
lookup does not stop the NSS lookup process, and it continues to try and
find it via DNS.
nsswitch.conf:
hosts: files dns
host.conf:
order hosts,bind
multi off
resolve.conf:
nameserver <ip of a machine without bind>
# Note, you can also just leave this file empty
hosts:
127.0.0.1 localhost
Now, if you do a name lookup for `localhost' under these conditions, I
would expect that it would not attempt a DNS lookup. This is not the case
with getaddrinfo(), but it is the case with gethostbyname().
getaddrinfo() continues to do a DNS lookup, even after it has read and
parsed /etc/hosts. Now this would not be a major problem, if it did not
cause the call to getaddrinfo to fail and return non-zero. IOW, any DNS
failure (other than notfound) for a host in /etc/hosts, will cause a
failure for the getaddrinfo call completely.
Even more odd is that if I change nsswitch.conf to:
hosts: dns files
It does not fail, but of course it still does the DNS lookup. Attached is
a simple program to make the two calls (after editing to reproduce the
above conditions).
Also, the obvious "hosts: files" makes things work aswell, but the problem
with DNS failures causing local host lookups to fail is not correct, IMO.
One thing that has brought this to my attention is that a lot of people
are reporting to me that they are getting a lot of DNS failures with this
version of glibc over the old 2.1.3 (a lot being more than normal, but not
consistent, nor reproducable). I haven't looked into this, but maybe
someone else has experienced the same issues.
--
-----------=======-=-======-=========-----------=====------------=-=------
/ Ben Collins -- ...on that fantastic voyage... -- Debian GNU/Linux \
` bcollins@debian.org -- bcollins@openldap.org -- bcollins@linux.com '
`---=========------=======-------------=-=-----=-===-======-------=--=---'