Bug still present.

$ 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
# ./a.out
Making resolv.conf empty
Results of looking up www.google.com: status = -2, errno = 2
Results of looking up a bogus name: status = -2, errno = 2
Writing correct nameserver option to resolv.conf
Results of looking up www.google.com: status = 0, errno = 101
Results of looking up a bogus name: status = -2, errno = 2
Writing incorrect nameserver option to resolv.conf
Results of looking up www.google.com: status = -2, errno = 2
Results of looking up a bogus name: status = -2, errno = 2

# 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();
}

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

Title:
  getaddrinfo() returns -11 (EAI_SYSTEM) instead of -2

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/1154599/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to