[PATCH] new applet gethostbyname

Paul Smith paul at mad-scientist.net
Sun Jul 8 15:15:53 UTC 2012


On Sun, 2012-07-08 at 15:59 +0200, ralda at gmx.de wrote:
> > >> as I've said is previous mail, I'll think on how I can create a
> > >> getent applet and pitch it up instead.
> > > 
> > > That's what I meant by my comment.
> > > 
> > 
> > cool :)
> 
> cool, yes ... but as Ralf mentioned, we already have that applet, with
> just a different output format: nslookup (accepting it does NSS lookup
> and not not DNS lookup) ... so we have no need to add another applet.

The nslookup program does not do NSS lookup.  If the busybox version of
nslookup uses nsswitch.conf / gethostbyname() / gethostbyaddr() then
it's not correct (I haven't looked at the implementation so I can't
say).  The "real" nslookup is provided as part of the BIND package, and
the man page says in the first sentence:

    Nslookup is a program to query Internet domain name servers.

You can test this.  Using standard programs (not busybox), assuming
your /etc/resolv.conf is set to point to an upstream nameserver (i.e.
you're not using a local caching DNS server like dnsmasq with
your /etc/resolv.conf nameserver set to 127.0.0.1) and
your /etc/nsswitch.conf file is set to query host files first then DNS,
then add a non-existent host/IP pair to your /etc/hosts file.

When you run "nslookup <non-existent host>", it will fail to resolve.
When you run "host <non-existent host>", it will fail to resolve.
When you run "getent <non-existent host>", it WILL resolve.

Also getent does a lot more than just show hostnames.  As I said before
it's a command line interface to all the get*ent() functions in libc so
in addition to hostnames it can be used to look up passwd entries, group
entries, etc.  A getent applet in busybox WOULD be very useful.

"nslookup" and "host" are mostly overlapping, except for interface.  If
busybox already correctly implements nslookup, it could be made to
implement "host" with a minimal amount of code (just a different
front-end).  That could be very handy for portability (more and more
scripts etc. use "host" as "nslookup" is kind of old-fashioned).
"getent" is something quite different however.



More information about the busybox mailing list