gethostbyaddr without /etc/{resolv,nsswitch}.conf
Mike Frysinger
vapier@gentoo.org
Mon Jan 20 06:28:00 GMT 2014
On Sunday 19 January 2014 15:40:04 Ludovic Courtès wrote:
> 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...?
your use case is reasonable -- if /etc/resolv.conf does not exist, looking up
an IP address which is listed in /etc/hosts should give the right answer.
if dns has no settings defined, then it should not be returning NOTFOUND imo.
it should be UNAVAIL. the pending question then is whether this is an ABI
break that matters. if it is, it should be easy to create a symbol version
that returns the old one and create a new symbol version that returns the
right value. if it isn't, then let's just change the return value and be
done.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20140120/8cbf6a36/attachment.sig>
More information about the Libc-alpha
mailing list