From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: Neon and reverse address lookup Date: Sun, 19 Jan 2014 16:40:43 +0100 Message-ID: <87iotgkmis.fsf@gnu.org> References: <20140118124847.GA6166@debian> <8738klou1c.fsf@gnu.org> <87ob39osyh.fsf@netris.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W4uZN-0007lJ-9u for guix-devel@gnu.org; Sun, 19 Jan 2014 10:45:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W4uZH-0000vM-RD for guix-devel@gnu.org; Sun, 19 Jan 2014 10:45:53 -0500 Received: from hera.aquilenet.fr ([141.255.128.1]:60885) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W4uZH-0000vF-KF for guix-devel@gnu.org; Sun, 19 Jan 2014 10:45:47 -0500 In-Reply-To: <87ob39osyh.fsf@netris.org> (Mark H. Weaver's message of "Sat, 18 Jan 2014 16:55:50 -0500") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Mark H Weaver Cc: guix-devel@gnu.org Mark H Weaver skribis: > ludo@gnu.org (Ludovic Court=C3=A8s) 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 "127.0.0.1")))' >> >> If nsswitch.conf is removed, then that resolves to =E2=80=9Clocalhost=E2= =80=9D (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 =E2=80=9Clocalhost=E2=80=9D plus another name = for 127.0.0.1. >> 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 =E2=80=9Chosts: files=E2=80=9D in nsswitch.conf. > > When you say "it resolves correctly", which name does it resolve to? Whatever /etc/hosts suggests. >> It=E2=80=99s surprising that there=E2=80=99s this discrepancy between ho= w 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 =E2=80=98hosts=E2=80=99 databa= se when resolv.conf is missing is (see nss/hosts-lookup.c): dns [!UNAVAIL=3Dreturn] files When doing a host name lookup, =E2=80=98dns=E2=80=99 is unavailable, so we = go on with =E2=80=98files=E2=80=99 and /etc/hosts is honored as expected. However, when doing a reverse lookup, the DNS resolver (__libc_res_nquery) returns =E2=80=98notfound=E2=80=99, and so =E2=80=98get= hostbyaddr=E2=80=99 returns immediately. Changing the =E2=80=98hosts=E2=80=99 config to =E2=80=9Cdns files=E2=80=9D = solves this particular. I=E2=80=99ll ask for advice on libc-help. Thanks, Ludo=E2=80=99.