[PATCH] new applet gethostbyname

Paul Smith paul at mad-scientist.net
Wed Jul 4 07:02:24 UTC 2012


On Wed, 2012-07-04 at 09:14 +0300, Eial Czerwacki wrote:
> that is right but assuming /etc/hosts parsing is added, how can we be
> sure that there isn't any changes in file format?

I don't understand what you mean.  There's no need to add parsing
for /etc/hosts to anything.  The library already has that parsing code;
it's all embedded under the gethostbyname() function.  Since you're
already invoking gethostbyname() you're already paying for the overhead
of the code that parses the /etc/hosts file.

> in that case I think that keeping it the host format is the right
> thing to do.

The right thing to do in what sense?  The right thing to do for your
environment?  Obviously only you can decide whether you'd rather have
the host(1) or getent(1) applets.  Both are useful, in different
contexts.

The getent(1) utility is useful for all sorts of scripting needs.  It's
far and away the most likely to be useful in a normal Busybox
environment.  The lucky thing is it's also simpler to write and will
result in much less code added to Busybox.

The host(1) utility is really mainly useful when you're debugging DNS
problems and/or servers.  It's not so useful for general scripting
because the IP address you get back from it might not be the same IP
address as some program you invoke (ping or ssh or telnet or whatever
for example) would use for that same hostname, which can be confusing.

Also as far as I'm aware there's no standard C runtime function which
you can use to implement host(1), so you'll have to recreate a
significant chunk of the DNS server access code, which WOULD be a lot of
work and a lot of new, somewhat complex code added to Busybox.  My
suspicion is that the Busybox maintainers would be leery of accepting
this and might suggest you just go get the real host(1) application from
BIND and use that instead.



More information about the busybox mailing list