Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!unmvax!unmvax.cs.unm.edu!mike From: mike@unmvax.cs.unm.edu (Michael I. Bushnell) Newsgroups: gnu.bash.bug Subject: Re: gethostent call in readline.c Message-ID: <142@unmvax.unm.edu> Date: 14 Jun 89 02:45:59 GMT References: <126@unmvax.unm.edu> <13429@umn-cs.CS.UMN.EDU> Sender: news@unmvax.unm.edu Reply-To: mike@unmvax.cs.unm.edu (Michael I. Bushnell) Organization: University of No Money, Albuquerque, New Mexico Lines: 99 In article <13429@umn-cs.CS.UMN.EDU> peiffer@umn-cs.cs.umn.edu (Tim J. Peiffer) writes: >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'. Uh, I hate to burst YOUR bubble, but I know whereof I speak. The goal of GNU is to be upwardly compatable with the 4.3 BSD kernel and libraries. 4.3 BSD, when using the resolv routines (the default) has *no* gethostent function. Further, it is important to realize that local tables (/etc/hosts) are more likely wrong than are the authoritative DNX databases. > 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. Unless, of course, you don't HAVE /etc/resolv.conf. SOME of us use local nameservers. It gets the domain name from the NAMESERVER (named has a default which it appends using a sliding window match. [UNIX 101 discussion of sliding window matches deleted...] > 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. Look, Mr Condecension, I didn't say that ONE request took a long time. I said that a COMPLETION would take a long time...since it would have to build a table from the entire DNS, as /etc/hosts is wrong and incomplete. The UNM CS dept typically has only the addresses for the local machine and a few nearby important servers in /etc/hosts. >>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. Sigh!!!! The resolver uses struct rrec's for all its transactions. For once and for all: gethost* <> resolver. The gethost* routines are implemented in terms of calls to the resolver. The resolver routines either use resolv.conf to find out where to start, or they contact the local nameserver. Most importantly, in 4.3 BSD, NO reference is made to /etc/hosts if a successful communication is made to named. Your comments are quite true with respect to SUNOS. But GNU is supposed to assume the 4.3 BSD libraries as a starting point. Since I don't see the GNU implementation of gethost* or of the resolver routines, or named, I think we ought to stick with the standard. Completion of hostnames is a nice idea, but it doesn't come out that useful in the DNS environment. After all, what happens when I type: % @deimos[TAB] ??? Does it expand to deimos.unm.edu, or perhaps deimos.cis.ksu.edu, or any of a host of other possibilities? (Pun intended....) 'Nuff said. Michael I. Bushnell \ This above all; to thine own self be true GIG! \ And it must follow, as the night the day, mike@turing.cs..unm.edu /\ Thou canst not be false to any man. Snail mail: 87196-4292 / \ Farewell: my blessing season this in thee!