[Bug 1295229] Re: With 'hosts: mdns4' in nsswitch.conf, getaddrinfo() returns -5 (EAI_NODATA) when network interface is down

TJ ubuntu at iam.tj
Sat Nov 25 07:18:44 UTC 2017


The 17.10 install was default, with:

hosts: files mdns4_minimal [NOTFOUND=return] dns

The user gave up and re-installed with 16.04 so we don't have access any
more to diagnostic output.

However, the issue here was that the lookup should have been satisfied
by 'files' since the system hostname was in /etc/hosts, both for IPv4
and IPv6.

Regardless of that, what nacc and myself found perplexing is the
[NOTFOUND=return] - if mdns fails to resolve the name surely NSS should
'continue' and try to resolve using DNS, not return?

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to nss-mdns in Ubuntu.
https://bugs.launchpad.net/bugs/1295229

Title:
  With 'hosts: mdns4' in nsswitch.conf, getaddrinfo() returns -5
  (EAI_NODATA) when network interface is down

Status in nss-mdns package in Ubuntu:
  Confirmed

Bug description:
  When  the "hosts:" line in nsswitch.conf includes `mdns4` or
  `mdns4_minimal` last and the network interface is taken down,
  getaddrinfo() returns -5 (EAI_NODATA — "No address associated with
  hostname") instead of something more appropriate such as -4 (EAI_FAIL
  — "Non-recoverable failure in name resolution").

  $ dpkg -l libc6
  [...]
  ii libc6:amd64 2.17-93ubuntu4 amd64

  $ grep hosts /etc/nsswitch.conf
  hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

  $ sudo su
  # ifconfig eth0 down
  # ./a.out
  Making resolv.conf empty
  Results of looking up www.google.com: status = -5, errno = 110
  Results of looking up a bogus name: status = -5, errno = 110
  Writing correct nameserver option to resolv.conf
  Results of looking up www.google.com: status = -5, errno = 110
  Results of looking up a bogus name: status = -5, errno = 110
  Writing incorrect nameserver option to resolv.conf
  Results of looking up www.google.com: status = -5, errno = 110
  Results of looking up a bogus name: status = -5, errno = 110

  # cat x.c
  #include <sys/types.h>
  #include <sys/socket.h>
  #include <netdb.h>
  #include <errno.h>
  #include <stdio.h>

  struct addrinfo *res;

  void check_google()
  {
      int status;
      status = getaddrinfo("www.google.com", NULL, NULL, &res);
      printf("Results of looking up www.google.com: status = %d, errno = %d\n", status, errno);
      status = getaddrinfo("sjfkdsjfswfloo0f02938sjf28398sd.com", NULL, NULL, &res);
      printf("Results of looking up a bogus name: status = %d, errno = %d\n", status, errno);
  }

  int main()
  {
      FILE *fp;

      printf("Making resolv.conf empty\n");
      fp = fopen("/etc/resolv.conf", "w+"); fclose(fp);
      sleep(1);
      check_google();

      printf("Writing nameserver option to resolv.conf\n");
      fp = fopen("/etc/resolv.conf", "w+"); fprintf(fp, "nameserver 193.67.79.39\n"); fclose(fp);
      sleep(1);
      check_google();

      printf("Writing incorrect nameserver option to resolv.conf\n");
      fp = fopen("/etc/resolv.conf", "w+"); fprintf(fp, "nameserver 192.168.5.4\n"); fclose(fp);
      sleep(1);
      check_google();
  }

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/nss-mdns/+bug/1295229/+subscriptions



More information about the foundations-bugs mailing list