This service will be undergoing maintenance at 00:00 UTC, 2016-09-28. It is expected to last about 1 hours
Bug 9871 - getaddrinfo() isn't obeying search rules...
getaddrinfo() isn't obeying search rules...
Status: CLOSED CURRENTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
8.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-02-29 16:45 EST by Rob Seace
Modified: 2007-04-18 12:26 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-04-21 19:54:11 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
Test program to illustrate getaddrinfo()'s misbehavior... (2.35 KB, text/plain)
2000-03-13 12:16 EST, Rob Seace
no flags Details

  None (edit)
Description Rob Seace 2000-02-29 16:45:20 EST
It looks to me (based on "strace" output, after noticing some odd slowness
trying to lookup "localhost") that getaddrinfo() is ignoring the search
orders specified in either "/etc/host.conf" or "/etc/nsswitch.conf", and
instead is always trying a DNS lookup first, and a local "/etc/hosts"
lookup last (which is just an utterly bass-ackwards way of doing things,
even as a hard-coded default, IMHO)...  It should further be noted that
gethostbyname() does NOT exhibit this same flaw; it correctly uses the
defined search orders, and so a lookup of "localhost" via it never tries
a DNS query at all...  But, for some reason getaddrinfo() is behaving
differently, and ALWAYS wants to do the DNS query (and, FIRST)...  Which,
of course, can be a pain, for looking up simple local stuff like that...
(And, no, I can't just switch to using gethostbyname() instead...  I need
a thread-safe function for one thing, and gethostbyname() is NOT...  And,
I want to code for future IPv6 compatibility, so getaddrinfo() is the best
choice...)
Comment 1 Rob Seace 2000-03-13 12:16:59 EST
Created attachment 152 [details]
Test program to illustrate getaddrinfo()'s misbehavior...
Comment 2 Cristian Gafton 2000-05-22 10:52:59 EDT
assign to jakub
Comment 3 Ryan Koski 2002-12-26 12:41:56 EST
This bug still exists in 8.0 (glibc 2.2.93-5).  Thanks much to Mr. Seace for the
test program.

This causes, among other things, a problem with the default sendmail config
where it only listens to 127.0.0.1.  Even though I have both the FQDN and short
hostname assigned to 127.0.0.1 in /etc/hosts, and "hosts: files dns" in
/etc/nsswitch.conf, glibc is always using DNS.  Therefore, when sendmail,
running on the local box, tries to connect to the FQDN of the local box, it
pulls the eth0 IP from DNS instead of the 127.0.0.1 from /etc/hosts, and it
can't connect.

Interestingly enough, if I change /etc/nsswitch.conf to:

hosts: files [NOTFOUND=return] dns

then getaddrinfo() actually returns the correct IP from /etc/hosts (which seems
contrary to the meaning of "NOTFOUND").  Of course, if I do this, then I cannot
resolve any names from DNS whatsoever...

Please fix!  I pay cash bribes under the table as necessary. ;-)
Comment 4 Ulrich Drepper 2003-04-21 19:54:11 EDT
Try it with RHL9.  Running the test program on an RHL9 system with an
nsswitch.conf entry like

hosts: files dns

does not show any DNS activity in the strace log.

Note You need to log in before you can comment on or make changes to this bug.