NetBSD-Users archive

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

Re: gethostbyname(3) doesn't appear to work under NetBSD-5.2 and NetBSD-6.1.x when hostnames appear only in /etc/hosts



On Jun 19, 10:07pm, Martin Husemann wrote:
} Subject: Re: gethostbyname(3) doesn't appear to work under NetBSD-5.2 and 
} On Thu, Jun 19, 2014 at 01:00:51PM -0700, Brian Buhrow wrote:
} >     Hello.  If you turn off dns resolution for the hosts database in
} > nsswitch.conf, can you reproduce it for both ipv4 and ipv6 entries?
} 
} No, IPv4 entries work for me in -current with "hosts: files" too.
} 
} Martin
        Hello.  Interesting...  Ok, I didn't have a chance to test on a
-current system.  Still, I think gethostbyname() and gethostbyname2() are
pretty broken when used with NetBSD-5.2 and netbsd-6  with any entries that
don't appear in dns and only appear in /etc/hosts.
Interestingly enough, getaddrinfo(3) seems to do the right thing when
presented with the same scenario.  As a quick test, try turning off dns
resolution in nsswitch.conf and then using telnet, which uses
getaddrinfo(3) to do its resolution, to get to your ipv6 host that only
shows up in /etc/hosts.  My guess is that you'll get resolution while
getent(1)  against the same host will give you nothing.  
        A bit more experimentation shows that getent(1) against the hosts
database hasn't worked for IPV6 hosts since at least NetBSD-3.0.  However,
IPV4 hosts work fine and getaddrinfo(3) works fine for both IPV4 and IPV6
hosts in NetBSD-3.  Getaddrinfo(3) works fine for IPV4 hosts in NetBSD-5.1,
but doesn't work for IPV6 hosts.  Getent(1), which uses gethostbyname(3)
works for IPV4 hosts on NetBSD-5.1 but doesn't work for IPV6 hosts.
        So, to summarize, the thing that's changed, and in my view, broken,
between NetBSD-5.1 and NetBSD-5.2 is that gethostbyname and
gethostbyname2 no longer work on IPV4 hosts when those hostnames appear in
/etc/hosts and not DNS.  IPV6 has probably never worked with this scenario
and while this is undoubtedly a bug, it's so long outstanding that I don't
think anyone will trip over it.  Getaddrinfo(3) has also suffered a bit
from NetBSD-3 to NetBSD-5, but again, only with IPV6 hosts, so it's
probably not so bad.    Clearly, this code is in need of a complete
overhaul, but the value probably isn't worth the effort.  since ktrace
shows the file /etc/hosts gets read even when things don't work, it is probably
a simple logic bug that got introduced when the NetBSD-5 files were
patched.  I'll see if I can figure that one out.
        If it's any consolation, FreeBSD-9.2 has the same issue with IPV6
entries as we do.  That is, neither  gethostbyname, hostbyname2 or
getaddrinfo can retrieve IPV6 entries if they appear only in the /etc/hosts
file.

-thanks
-Brian



Home | Main Index | Thread Index | Old Index