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).
Created attachment 141024 [details] C code to demonstrate problem
Same here and a couple other people I know have had the same problem. Tested with the standard resoveip localhost Tobias
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.
This is in glibc-2.5.90-7 in rawhide.