Article View: gnu.bash.bug
Article #1030Re: gethostent call in readline.c
From: Tim J. Peiffer
Date: Sun, 11 Jun 1989 03:55
Date: Sun, 11 Jun 1989 03:55
53 lines
3066 bytes
3066 bytes
In article <126@unmvax.unm.edu> mike@unmvax.cs.unm.edu writes:
>Hostname completions are a good idea, but there is a problem. With
>the resolv library (which BSD uses by DEFAULT, thank god), there is no
>gethostent function. Even if it were implemented (perhaps doing a
>depth-first search on the entire DNS), it would be far too slow when
>hooked up to the internet with named. Just too many hosts to page
>through.
Uh, I hate to burst your bubble, but that is not exactly what
happens. If the system implements gethostbyname(3N) properly,
it first looks in the host tables to see if it exists there.
Consider the name 'host' and a domain name of 'sub.sub_domain.domain'.
Then the resolvers request an address - the resolver makes
use of what is called a sliding window match. The resolver then,
if name is not fully qualified (e.g. ends with a '.'), pulls
off a domain name from /etc/resolv.conf. Then the name is presented
to the DNS - fully qualified as host.sub.sub_domain.domain.
(remember the terminating '.'). If the data is not found, a
NXDOMAIN signal is returned. Then the domain name is pruned
from the left -> host.sub_domain.domain. The name is resubmitted
to the server and repruned until 'host.' fails.
If the domain is not the same as the zone that the server is
responsible for, the query is forwarded to an upline server until
it either receives an authoritative answer or it reaches a root
server and receives a NXDOMAIN response. Typically there are
only 3-6 servers upline until you contact a root server. In
my application, for any query, 6 queries is all that are done.
This takes place inside of 10 seconds - tops at the worst of
network conditions.
>Has anyone else thought of this?
No need. By the way, gethostent returns a pointer to a
structure hostent in netdb.h. The object has the following
structure containing the broken-out fields of a line in the
network host data base, /etc/hosts.
struct hostent {
char *h_name; /* official name of host */
char **h_aliases; /* alias list */
int h_addrtype; /* address type */
int h_length; /* length of address */
char *h_addr; /* address */
};
This structure is used in *every* transaction that the
resolver goes through.
Tim Peiffer peiffer@umn-cs.cs.umn.edu
Computer Science Department
University of Minnesota, MPLS MN
P.S. I thought this spot was reserved for bashing out GNU bugs..
Technical Details
Message-ID:
<13429@umn-cs.CS.UMN.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!csd4.milw.wisc.edu!srcsip!nic.MR.NET!umn-cs!peifferReferences:
<126@unmvax.unm.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!csd4.milw.wisc.edu!srcsip!nic.MR.NET!umn-cs!peiffer From: peiffer@umn-cs.CS.UMN.EDU (Tim J. Peiffer) Newsgroups: gnu.bash.bug Subject: Re: gethostent call in readline.c Message-ID: <13429@umn-cs.CS.UMN.EDU> Date: 11 Jun 89 03:55:36 GMT References: <126@unmvax.unm.edu> Reply-To: peiffer@umn-cs.cs.umn.edu (Tim J. Peiffer) Organization: CSci Dept., University of Minnesota, Mpls. Lines: 53