Summary: | host tool and possibly gethostbyname do not respect /etc/nsswitch.conf | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | mike wakerly <mikew> |
Component: | [OLD] Core system | Assignee: | Jared H. Hudson (RETIRED) <jhhudso> |
Status: | RESOLVED INVALID | ||
Severity: | normal | CC: | h3y |
Priority: | High | ||
Version: | 1.3 | ||
Hardware: | x86 | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- |
Description
mike wakerly
2002-10-19 02:43:57 UTC
The "host" program uses your /etc/resolv.conf and queries a DNS server directly. It does not use /etc/nsswitch.conf, /lib/libnss.so, or gethostbyname(). Whereas a general network program like ping, looks at /etc/nsswitch.conf and uses /etc/hosts (if files is listed), ect. Mozzila should as well, I would think. A simple C program can test the gethostbyname() interface, to proove this: #include <netdb.h> #include <stdio.h> int main(int argc, char **argv) { char **ptr; char str[INET6_ADDRSTRLEN]; struct hostent *h; if (argc < 2) return 1; h = gethostbyname(argv[1]); ptr = h->h_addr_list; for ( ; *ptr != NULL; ptr++) { printf("[%s]\n", inet_ntop(h->h_addrtype, *ptr, str, sizeof(str))); } return 0; } To compile run gcc -o test test.c (assuming source is put into test.c) ./test foobar (assuming foobar is in your /etc/hosts, and /etc/nsswitch.conf is setup properly) Also, there's a command called strace that will allow you to see all the system calls that a program runs. emerge strace to install it. Then you can do something like strace host foobar 2> strace.log less strace.log and you will see that it never looks at or uses /etc/nsswitch.conf, it connects directly to your nameservers listed in /etc/resolv.conf where as if you do a strace ping foobar 2> strace.log less strace.log You will see it look at /etc/nsswitch.conf, and go from there. |