This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
gethostbyaddr without /etc/{resolv,nsswitch}.conf
- From: ludo at gnu dot org (Ludovic CourtÃs)
- To: libc-alpha at sourceware dot org
- Date: Sun, 19 Jan 2014 21:40:04 +0100
- Subject: gethostbyaddr without /etc/{resolv,nsswitch}.conf
- Authentication-results: sourceware.org; auth=none
Hello,
(Resent from libc-help as Carlos suggested.)
Guix builds packages in Linux containers where only âloâ is available,
/etc/{nsswitch,resolv}.conf are missing, and /etc/hosts maps 127.0.0.1
to âlocalhostâ.
In that context, looking up âlocalhostâ works fine.
However, gethostbyaddr("127.0.0.1") fails with TRY_AGAIN.
The problem stems from the fact that the default config for the âhostsâ
database when resolv.conf is missing is (from nss/hosts-lookup.c):
dns [!UNAVAIL=return] files
When doing a host name lookup, âdnsâ returns NSS_STATUS_UNAVAIL, so we
go on with âfilesâ and /etc/hosts is honored as expected.
Conversely, when doing a reverse lookup, the DNS name service returns
NSS_STATUS_NOTFOUND, and so âgethostbyaddrâ returns the error directly.
(Of course, changing the âhostsâ config to âdns filesâ solves this
particular problem.)
Should the DNS name service always return NSS_STATUS_UNAVAIL when
resolv.conf is missing? Or should the default config for reverse hosts
lookups be âdns filesâ? Or...?
Thanks,
Ludoâ.