This is the mail archive of the
libc-alpha@sourceware.cygnus.com
mailing list for the glibc project.
Re: gethostbyname and multiple addresses for one host
- To: Andreas Jaeger <aj@arthur.rhein-neckar.de>
- Subject: Re: gethostbyname and multiple addresses for one host
- From: Thorsten Kukuk <kukuk@suse.de>
- Date: Mon, 5 Jul 1999 16:59:09 +0200
- Cc: libc-alpha Mailinglist <libc-alpha@sourceware.cygnus.com>,Matthias Barnutz <barney@nef.wh.uni-dortmund.de>
- References: <u8yagyrlb9.fsf@arthur.rhein-neckar.de>
Hello,
On Sat, Jul 03, Andreas Jaeger wrote:
>
> Matthias described a problem with his setup and gethostbyname. His
> /etc/hosts contains:
> 10.0.0.254 emil.nef.wh.uni-dortmund.de emil
> 127.0.0.1 localhost
> 129.217.240.1 emil.nef.wh.uni-dortmund.de emil
> 129.217.255.132 emil.nef.wh.uni-dortmund.de emil
> 129.217.255.249 emil.nef.wh.uni-dortmund.de emil
>
> and gethostbyname ("emil") only returns the first IP address but
This is correct. This was the behaviour from all Unix, including
Solaris 2.6.
> should return all IP addresses. I checked all documentation I could
> find for the format of /etc/hosts and only Solaris 7 mentioned this
> case:
I haven't checked Solaris 7 for this. If Solaris returns all
entries, it is new in Version 7. I don't think this is a bug
in glibc, it's an very old behaviour.
>
>
> The hosts file has one entry for each IP address of each
> host. If a host has more than one IP address, it will have
> one entry for each, on consecutive lines. The format of each
> line is:
>
> IP-addressofficial-host-namenicknames...
>
> Items are separated by any number of SPACE and/or TAB char-
> acters. The first item on a line is the host's IP address.
> The second entry is the host's official name. Subsequent
> entries on the same line are alternative names for the same
> machine, or "nicknames." Nicknames are optional.
>
> For a host with more than one IP address, consecutive
> entries for these addresses may contain the same or differ-
> ing nicknames. Different nicknames are useful for assigning
> distinct names to different addresses.
>
> A call to gethostbyname(3N) returns a hostent structure con-
> taining the union of all addresses and nicknames from each
> line containing a matching official name or nickname.
>
> Matthias' /etc/hosts doesn't contain email on consecutive lines -
> there the localhost between. Nevertheless (just checked) this doesn't
> work.
>
> Is this a bug in glibc?
>
> Andreas
> --
> Andreas Jaeger aj@arthur.rhein-neckar.de jaeger@informatik.uni-kl.de
> for pgp-key finger ajaeger@aixd1.rhrk.uni-kl.de
--
Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de
SuSE GmbH Schanzaeckerstr. 10 90443 Nuernberg
Linux is like a Vorlon. It is incredibly powerful, gives terse,
cryptic answers and has a lot of things going on in the background.