This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gethostbyaddr without /etc/{resolv,nsswitch}.conf


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

Attachment: signature.asc
Description: This is a digitally signed message part.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]