Bug 10851

Summary: no fallback to nameserver 0.0.0.0 if /etc/resolv.conf is missing
Product: glibc Reporter: Aurelien Jarno <aurelien>
Component: libcAssignee: Ulrich Drepper <drepper.fsp>
Status: RESOLVED FIXED    
Severity: normal CC: glibc-bugs
Priority: P2 Flags: fweimer: security-
Version: unspecified   
Target Milestone: ---   
Host: x86_64-unknown-linux-gnu Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu Last reconfirmed:
Attachments: Patch to fix the problem
New patch
alternative patch

Description Aurelien Jarno 2009-10-26 17:38:25 UTC
Starting with glibc 2.10, there is no fallback to nameserver 0.0.0.0 anymore if
/etc/resolv.conf is missing. This is due to this change:

2008-12-02  Ulrich Drepper  <drepper@redhat.com>

        * resolv/res_init.c (__res_vinit): Initialize nscount to zero.

This value should be set back to 1 so that the following code is actually useful:
#ifdef USELOOPBACK
        statp->nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1);
#else
        statp->nsaddr.sin_addr.s_addr = INADDR_ANY;
#endif
        statp->nsaddr.sin_family = AF_INET;
        statp->nsaddr.sin_port = htons(NAMESERVER_PORT);
Comment 1 Aurelien Jarno 2009-10-26 17:38:48 UTC
Created attachment 4322 [details]
Patch to fix the problem
Comment 2 Aurelien Jarno 2009-11-08 18:41:44 UTC
Created attachment 4369 [details]
New patch

The previous patch does not work in case /etc/resolv.conf exists, but does not
contain a nameserver entry. This new patch also takes that into account.
Comment 3 Petr Baudis 2009-11-09 16:38:06 UTC
See also http://sourceware.org/ml/libc-alpha/2009-02/msg00028.html :(
Comment 4 Petr Baudis 2009-11-20 08:28:19 UTC
Created attachment 4402 [details]
alternative patch

Oops, I haven't noticed you already implemented a fix; anyway, here's what I've
done independently, somewhat simpler patch. YMMV.
Comment 5 Ulrich Drepper 2010-08-25 14:48:07 UTC
I checked in a different patch.
Comment 6 Aurelien Jarno 2010-09-02 17:55:04 UTC
(In reply to comment #5)
> I checked in a different patch.

... but broken what. You forget to set statp->nscount to 1, so it doesn't work.
Comment 7 Petr Baudis 2010-09-14 17:04:19 UTC
Fixed in Git now for good, hopefully.
Comment 8 Jackie Rosen 2014-02-16 19:42:01 UTC Comment hidden (spam)