[PATCH][BZ #16077] Get canonical name in getaddrinfo from hosts file for AF_INET

Siddhesh Poyarekar siddhesh@redhat.com
Wed Oct 23 14:09:00 GMT 2013


On Wed, Oct 23, 2013 at 03:12:53PM +0200, Ondřej Bílka wrote:
> On Wed, Oct 23, 2013 at 03:34:31PM +0530, Siddhesh Poyarekar wrote:
> > Hi,
> > 
> > AF_INET lookup in hosts file uses _nss_files_gethostbyname2_r, which
> > is not capable of returning a canonical name if it has found one.
> > This change adds _nss_files_gethostbyname3_r, which wraps around
> > _nss_files_gethostbyname2_r and then returns result.h_name as the
> > canonical name.
> >
> How this will be used? Will there be a followup patches? A single function
> that is not called internally and has no documentation is not very useful.

getaddrinfo calls _nss_MODULE_FUNC from resolver modules, where MODULE
may be files, dns, etc. and FUNC (for getaddrinfo) could be
gethostbyname4_r, gethostbyname3_r, gethostbyname2_r, etc.  Earlier,
since _nss_files_gethostbyname3_r was not available, any non-AF_UNSPEC
query would call _nss_files_gethostbyname2_r, which doesn't set
canonname, due to which the canonical name returned is simply a copy
of the query.

So to summarize, the function is called via the horribly convoluted
callback system of the nss modules.

Siddhesh



More information about the Libc-alpha mailing list