when /etc/hosts doesn't exist, apt fails to resolve hostnames using libc6

Bug #408901 reported by LaMont Jones
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GLibC
Fix Released
Medium
eglibc (Debian)
Fix Released
Unknown
eglibc (Ubuntu)
Fix Released
High
Steve Langasek
Karmic
Fix Released
High
Steve Langasek

Bug Description

the lack of /etc/hosts should not prevent a host with /etc/resolv.conf from resolving hostnames.

Interestingly, ping and a few other applications resolve hosts just fine with no /etc/hosts on the system, apt does not.

lamont

Related branches

Revision history for this message
Steve Langasek (vorlon) wrote :

blocker for karmic alpha-4, since it breaks livefs builds.

Changed in eglibc (Ubuntu Karmic):
importance: Undecided → High
milestone: none → karmic-alpha-4
status: New → Triaged
assignee: nobody → Matthias Klose (doko)
Revision history for this message
Matthias Klose (doko) wrote :

$ sudo whoami
sudo: unable to resolve host timbuktu
root

Revision history for this message
to be removed (liw) wrote :

ping, host, nslookup, and dig, at least, do DNS lookups only, and do not use the (default) libc resolver.

Revision history for this message
to be removed (liw) wrote :

apt exhibits the problem. wget doesn't.

Revision history for this message
to be removed (liw) wrote :

The attached file provides a test case. Compile, then run it as follows: "./a.out ubuntu.com". If /etc/hosts exists, it should print "ubuntu.com 0". If it does not exist, it should print "ubuntu.com -11".

Revision history for this message
to be removed (liw) wrote :
Revision history for this message
Steve Langasek (vorlon) wrote :

patch done and tested, now finalizing the package for upload.

Changed in eglibc (Ubuntu Karmic):
assignee: Matthias Klose (doko) → Steve Langasek (vorlon)
status: Triaged → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package eglibc - 2.10.1-0ubuntu6

---------------
eglibc (2.10.1-0ubuntu6) karmic; urgency=low

  * patches/all/submitted-missing-etc-hosts.diff: a missing /etc/hosts should
    be treated as a simple "not found", not as an internal error.
    LP: #408901.

 -- Steve Langasek <email address hidden> Tue, 11 Aug 2009 19:58:18 +0000

Changed in eglibc (Ubuntu Karmic):
status: In Progress → Fix Released
Revision history for this message
In , Steve Langasek (vorlon) wrote :

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.

Revision history for this message
In , Steve Langasek (vorlon) wrote :

Created attachment 4142
test case

Revision history for this message
In , Steve Langasek (vorlon) wrote :

Created attachment 4143
patch to nss_files fixing getaddrinfo when /etc/hosts is absent

Changed in glibc:
status: Unknown → Confirmed
Revision history for this message
In , Drepper-fsp (drepper-fsp) wrote :

I applied the patch.

Changed in glibc:
status: Confirmed → Fix Released
Revision history for this message
In , Hermier (hermier) wrote :

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.

Changed in glibc:
status: Fix Released → Confirmed
Changed in glibc:
importance: Unknown → Medium
Changed in eglibc (Debian):
status: Unknown → Fix Released
Revision history for this message
In , Andreas Schwab (schwab-linux-m68k) wrote :

Appears to be working fine with 2.17.

Changed in glibc:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.