Bug 215283

Summary: gethostbyname() fails to resolve "localhost" in FC6
Product: [Fedora] Fedora Reporter: Tim <ack210t>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 6CC: drepper
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 2.5.90-7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-11-20 16:30:50 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
C code to demonstrate problem none

Description Tim 2006-11-13 09:01:01 UTC
Description of problem:

In FC6, calls to gethostbyname(3) with an argument of "localhost" fail to
resolve the name. Actually this seems to be a problem with the version of
/etc/hosts that is provided out-of-the-box, but I'm not sure what category
addresses such problems. The out of the box hosts file is:

# Do not remove the following line, or various programs
# that require network functionality will fail.
::1             slab    localhost.localdomain   localhost

appending a new line

127.0.0.1       slab    localhost.localdomain   localhost

fixes the problem.

Version-Release number of selected component (if applicable):

[tim@slab ~]$ uname -a
Linux slab 2.6.18-1.2849.fc6 #1 SMP Fri Nov 10 12:45:28 EST 2006 i686 i686 i386
GNU/Linux
[tim@slab ~]$ /lib/libc.so.6 
GNU C Library stable release version 2.5, by Roland McGrath et al.

How reproducible:

100% on FC6 updated as of today. The problem does not exist in current
installations of FC5, but then the /etc/hosts file for FC5 contains the IPv4
address format.

Steps to Reproduce:
1. Build the attached program
2. Run with the argument "localhost"
3.
  
Actual results:

[tim@slab src]$ ./resolve localhost
main/gethostbyname(): Unknown host

Expected results:

[tim@slab src]$ ./resolve localhost
OK: 127.0.0.1

Additional info:

The name "localhost." (with the dot) does resolve properly, so this may actually
be an issue with glibc, but I'm inclined to think it's a hosts file issue.

This problem impacts certain applications that use TCP or UDP for client/server
interaction on the local system (e.g. Kismet).

Comment 1 Tim 2006-11-13 09:01:02 UTC
Created attachment 141024 [details]
C code to demonstrate problem

Comment 2 Tobias Oed 2006-11-20 00:31:06 UTC
Same here and a couple other people I know have had the same problem. Tested
with the standard resoveip localhost
Tobias




Comment 3 Ulrich Drepper 2006-11-20 03:28:57 UTC
This isn't really a bug.  The hosts file specifies an IPv6 address and
gethostbyname() queries for an IPv4 address.  The result is a failure by design.

However, there is no problem to change this.  It won't break anything and
prevent user mistakes like this from causing problems.  I've changed the cvs
archive upstream, the change will be in the next rawhide build.

But take this as an indication that the program which has this problem is
broken.  Every program should simply use getaddrinfo() and now of the getby* crap.

Comment 4 Jakub Jelinek 2006-11-20 16:30:50 UTC
This is in glibc-2.5.90-7 in rawhide.