On Fri, 2 Dec 2005, Alan Robertson wrote:

> Horms wrote:
> [...]
> > I think it would be better to write a small c programme that exposes
> > gethostbyname as a shell command. This would honour the previling
> > nsswitch.conf and let libc worry about the details.
> >
> > Something like the code below. Sorry its a bit over engineered,
> > I pieced it from code I had lying around the house.
>
> I don't think that anything complex is needed.  This is only test code,
> and it's never going to use this to contact the machines - just to
> figure out if the names given are valid.  If they're found in
> /etc/hosts, OR in DNS, it's all good.  It won't cover those people who
> might be using yellow pages or something like that.  But, I really don't
> care about that case for testing (which is all this code is good for).

(I'm coming at this as an outsider, so may be missing a point or two.)

This sounds like the "getent" command:
   getent <database> <key>

e.g.
   getent hosts hostname

and this automatically takes account of "nsswitch.conf" data sources
(files, NIS (formerly know as "Yellow Pages"), DNS, ...).

This command is available on both Linux and Solaris, although not (it
seems(*)) on *BSD.

If "getent" is an appropriate solution in principle, then one possible way
forward is to use that, and provide our own equivalent (sh?, perl?) for
those OSes which lack it.  (Probably not perfect, but might it be
adequate?)



(*)  Man pages for a variety of OSes available at:
   www.freebsd.org/cgi/man.cgi
A very useful resource!


-- 

:  David Lee                                I.T. Service          :
:  Senior Systems Programmer                Computer Centre       :
:                                           Durham University     :
:  http://www.dur.ac.uk/t.d.lee/            South Road            :
:                                           Durham DH1 3LE        :
:  Phone: +44 191 334 2752                  U.K.                  :
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to