[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Neon and reverse address lookup

From: Ludovic Courtès
Subject: Re: Neon and reverse address lookup
Date: Sun, 19 Jan 2014 16:40:43 +0100
User-agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux)

Mark H Weaver <address@hidden> skribis:

> address@hidden (Ludovic Courtès) writes:
>> So /etc/hosts is not enough for reverse lookups to work.
>> With nscd turned off, I tried this:
>>   guile -c '(pk (gethostbyaddr (inet-pton AF_INET "")))'
>> If nsswitch.conf is removed, then that resolves to “localhost” (instead
>> of the actual host name.)
> As John said, it should resolve to "localhost".  It certainly should
> _not_ resolve to the actual host name.

Right, but my /etc/hosts has “localhost” plus another name for

>> If, in addition, resolv.conf is removed, then that fails as seen above.
>> With nsswitch.conf alone, it resolves correctly (Mark was right.)
>> And this works with only “hosts: files” in nsswitch.conf.
> When you say "it resolves correctly", which name does it resolve to?

Whatever /etc/hosts suggests.

>> It’s surprising that there’s this discrepancy between how NSS works for
>> getaddrinfo and for gethostbyaddr.  At any rate, we may be able to solve
>> this at the libc level.
> Solve what?  What are you thinking of changing in libc?

The issue is that the default config for the ‘hosts’ database when
resolv.conf is missing is (see nss/hosts-lookup.c):

  dns [!UNAVAIL=return] files

When doing a host name lookup, ‘dns’ is unavailable, so we go on with
‘files’ and /etc/hosts is honored as expected.

However, when doing a reverse lookup, the DNS resolver
(__libc_res_nquery) returns ‘notfound’, and so ‘gethostbyaddr’ returns

Changing the ‘hosts’ config to “dns files” solves this particular.

I’ll ask for advice on libc-help.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]