[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Behaviour of resoov

From: Martin Fuzzey
Subject: Behaviour of resoov
Date: Sat, 13 Dec 2003 01:30:18 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007


I am seeing the following behaviour with glibc2.2.5  (Mandrake 9.0)

hostname = myhost.example.net
no search or domain entries in /etc/resolv.conf

resolve attempt on "somehost"
=> DNS query sent to somehost.example.net.  [1]
=> DNS query sent to somehost.  [2]

resolve attempt on "somehost.somewhere"
=> DNS query sent to somehost.somewhere.  [3]
=> DNS query sent to somehost.somewhere.example.net  [4]

In particular this means that DNS queries are made from localhost in some cases as has been noted

I question case 2 therefore.
Indeed looking at the code from res_query.c

   /* If there aren't any dots, it could be a user-level alias. */
   if (!dots && (cp = res_hostalias(statp, name, tmp, sizeof tmp))!= NULL)
       return (__libc_res_nquery(statp, cp, class, type, answer,
                     anslen, answerp));

    * If there are enough dots in the name, let's just give it a
    * try 'as is'. The threshold can be set with the "ndots" option.
    * Also, query 'as is', if there is a trailing dot in the name.
   saved_herrno = -1;
   if (dots >= statp->ndots || trailing_dot) {
       ret = __libc_res_nquerydomain(statp, name, NULL, class, type,
                         answer, anslen, answerp);
       if (ret > 0 || trailing_dot)
           return (ret);
       saved_herrno = h_errno;
       if (answerp && *answerp != answer) {
           answer = *answerp;
           anslen = MAXPACKET;

    * We do at least one level of search if
    *    - there is no dot and RES_DEFNAME is set, or
    *    - there is at least one dot, there is no trailing dot,
    *      and RES_DNSRCH is set.
   if ((!dots && (statp->options & RES_DEFNAMES) != 0) ||
       (dots && !trailing_dot && (statp->options & RES_DNSRCH) != 0)) {
       int done = 0;

       for (domain = (const char * const *)statp->dnsrch;
            *domain && !done;
            domain++) {

           if (domain[0][0] == '\0' ||
               (domain[0][0] == '.' && domain[0][1] == '\0'))

           ret = __libc_res_nquerydomain(statp, name, *domain,
                             class, type,
                             answer, anslen, answerp);


    * If the name has any dots at all, and no earlier 'as-is' query
    * for the name, and "." is not on the search list, then try an as-is
    * query now.
if (statp->ndots && !(tried_as_is || root_on_list)) { <=========== Doesn't seem coherent with comment above. Shouldn't this be dots rathet than statp->ndots??
       ret = __libc_res_nquerydomain(statp, name, NULL, class, type,
                         answer, anslen, answerp);
       if (ret > 0)
           return (ret);

The same code appears in the current glibc relasese (2.3.2)

I'm no DNS expert so I may be completely wrong but I'd be very interested to know if this is "correct".


Martin Fuzzey

reply via email to

[Prev in Thread] Current Thread [Next in Thread]