[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#836541: marked as done (libc6-dev: res_query does not use external nameservers when set)



Your message dated Sun, 26 Nov 2017 23:51:15 +0100
with message-id <20171126225115.ak7gnwxeblmzxn4m@aurel32.net>
and subject line Re: Bug#794336: [e]glibc breaks res_init() functionality
has caused the Debian Bug report #794336,
regarding libc6-dev: res_query does not use external nameservers when set
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
794336: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=794336
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: libc6-dev
Version: 2.19-18+deb8u4
Severity: important

Dear Maintainer,

Regarding the resolver library, when nameservers are explicitly
specified after the call to res_init and before the actual call
to res_query, the res_query code uses internal resolution first
rather than the specified nameservers.

Example code attached below.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <netinet/in.h>
#include <resolv.h>
#include <netdb.h>

#define N 4096

/* --------------------------------- */
/* CODE BEGINS                       */
/* --------------------------------- */

int main (int argc, char *argv[]) {
    u_char nsbuf[N];
    char dispbuf[N];
    ns_msg msg;
    ns_rr rr;
    int i, l;

    if (argc < 2) {
        printf ("Usage: %s <domain>\n", argv[0]);
        exit (1);
    }

/* Initialize to use the Google nameservers */
     res_init();
     _res.nscount = 2;
     _res.nsaddr_list[0].sin_family = AF_INET;
     _res.nsaddr_list[0].sin_addr.s_addr = inet_addr("8.8.8.8");
     _res.nsaddr_list[0].sin_port = htons(53);
     _res.nsaddr_list[1].sin_family = AF_INET;
     _res.nsaddr_list[1].sin_addr.s_addr = inet_addr("8.8.4.4");
     _res.nsaddr_list[1].sin_port = htons(53);

    printf("Domain:   %s\n\n", argv[1]);

 /* Print the A record return or the error code */
    printf("A record(s):\n");

    l = res_query(argv[1], ns_c_any, ns_t_a, nsbuf, sizeof(nsbuf));
    if (l < 0) perror(argv[1]);
    ns_initparse(nsbuf, l, &msg);
    l = ns_msg_count(msg, ns_s_an);
    for (i = 0; i < l; i++) {
      ns_parserr(&msg, ns_s_an, i, &rr);
      ns_sprintrr(&msg, &rr, NULL, NULL, dispbuf, sizeof(dispbuf));
      printf("\t%s \n", dispbuf);
    }

    // NS RECORD
    printf("\nNS record(s):\n");
    l = res_query(argv[1], ns_c_any, ns_t_ns, nsbuf, sizeof(nsbuf));
    if (l < 0) perror(argv[1]);
    ns_initparse(nsbuf, l, &msg);
    l = ns_msg_count(msg, ns_s_an);
    for (i = 0; i < l; i++) {
      ns_parserr(&msg, ns_s_an, 0, &rr);
      ns_sprintrr(&msg, &rr, NULL, NULL, dispbuf, sizeof(dispbuf));
      printf("\t%s \n", dispbuf);
    }
    return 0;
}

When the test program is run it incorrectly returns the LAN address
of the host from resolv.conf.  It should return the internet address
of the host from the external nameservers, as seen below.

sysmgr@www:~$ ./a.out www.somewhere.com
Domain: www.somewhere.com

A record(s):
www.somewhere.com. 6H IN A 192.168.0.209

NS record(s):
www.somewhere.com. 6H IN NS localhost.



-- System Information:
Debian Release: 8.5
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: armel (armv5tel)

Kernel: Linux 4.4.0-kirkwood-tld-1 (PREEMPT)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages libc6-dev depends on:
ii  libc-dev-bin    2.19-18+deb8u4
ii  libc6           2.19-18+deb8u4
ii  linux-libc-dev  3.16.7-ckt25-2+deb8u2

libc6-dev recommends no packages.

Versions of packages libc6-dev suggests:
pn  glibc-doc     <none>
pn  manpages-dev  <none>

-- no debconf information

--- End Message ---
--- Begin Message ---
Version: 2.26-0experimental0

On 2015-08-02 01:16, Joshua Rogers wrote:
> package: glibc
> 
> I don't know whether this is still relevant or not, as I know Debian has
> switched back to the original glibc, which does not contain this bug, but...
> 
> A patch to Debian's glibc, introduced here:
> https://lists.debian.org/debian-glibc/2006/06/msg00154.html contains a
> bug, which breaks the functionality of res_init().
> 
> res_init() is supposed to initalize the _res struct, and then allow for
> modifications to the _res struct by the user, before resolving something
> using res_query().
> 
> The introduction of the 'last_mtime' stat struct was used to determine
> whether or not the _res struct had to be re-initalized, as the last
> modification time of /etc/resolv.conf had changed. However, res_query()
> uses __res_maybe_init() to determine whether or not to reset _res, but
> res_init() does not set statbuf. So, calling res_init() effectively does
> nothing, since all the changes will be overwritten by the first call to
> res_query(), because res_query() runs __res_maybe_init().
> 
> 
> Ubuntu report here, for reference:
> https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1432378/comments/4

This bug has been fixed in glibc 2.26, as way to reload /etc/resolv.conf
rewritten and merged differently upstream. Marking the bug as closed for
this version.

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                 http://www.aurel32.net

Attachment: signature.asc
Description: PGP signature


--- End Message ---

Reply to: