Bug 10851 - no fallback to nameserver if /etc/resolv.conf is missing
Summary: no fallback to nameserver if /etc/resolv.conf is missing
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
Depends on:
Reported: 2009-10-26 17:38 UTC by Aurelien Jarno
Modified: 2014-07-01 05:33 UTC (History)
1 user (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Last reconfirmed:
fweimer: security-

Patch to fix the problem (262 bytes, patch)
2009-10-26 17:38 UTC, Aurelien Jarno
Details | Diff
New patch (512 bytes, patch)
2009-11-08 18:41 UTC, Aurelien Jarno
Details | Diff
alternative patch (447 bytes, patch)
2009-11-20 08:28 UTC, Petr Baudis
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Aurelien Jarno 2009-10-26 17:38:25 UTC
Starting with glibc 2.10, there is no fallback to nameserver 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:
        statp->nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1);
        statp->nsaddr.sin_addr.s_addr = INADDR_ANY;
        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)