patch for res_nsearch()
G Muthukumar
muthu at wipro.wipsys.soft.net
Fri Feb 4 10:18:31 UTC 2000
This patch reverts the res_nsearch() behaviour to that of res_search() (of
the earlier (4.9.x & pre 8.2.x) versions), when the 'as is' query for a name
(with a dot in it) has failed.
Most of this patch code comes from the older version; checks for
trailing_dot & root_on_list and few comment lines are new.
Paul:
If you feel this patch can be included in 8.2.3, then please do so.
*** res_query.c Fri Feb 4 14:28:25 2000
--- res_query.c Fri Feb 4 15:03:28 2000
***************
*** 190,197 ****
HEADER *hp = (HEADER *) answer;
char tmp[NS_MAXDNAME];
u_int dots;
! int trailing_dot, ret;
int got_nodata = 0, got_servfail = 0, root_on_list = 0;
errno = 0;
RES_SET_H_ERRNO(statp, HOST_NOT_FOUND); /* True if we never query. */
--- 190,198 ----
HEADER *hp = (HEADER *) answer;
char tmp[NS_MAXDNAME];
u_int dots;
! int trailing_dot, ret, saved_herrno;
int got_nodata = 0, got_servfail = 0, root_on_list = 0;
+ int tried_as_is = 0;
errno = 0;
RES_SET_H_ERRNO(statp, HOST_NOT_FOUND); /* True if we never query. */
***************
*** 208,219 ****
return (res_nquery(statp, cp, class, type, answer, anslen));
/*
! * If there are enough dots in the name, do no searching.
! * (The threshold can be set with the "ndots" option.)
*/
! if (dots >= statp->ndots || trailing_dot)
! return (res_nquerydomain(statp, name, NULL, class, type,
! answer, anslen));
/*
* We do at least one level of search if
--- 209,227 ----
return (res_nquery(statp, cp, class, type, answer, anslen));
/*
! * 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 = res_nquerydomain(statp, name, NULL, class, type,
! answer, anslen);
! if (ret > 0 || trailing_dot)
! return (ret);
! saved_herrno = h_errno;
! tried_as_is++;
! }
/*
* We do at least one level of search if
***************
*** 285,294 ****
}
/*
! * If the name has any dots at all, and "." is not on the search
! * list, then try an as-is query now.
*/
! if (statp->ndots) {
ret = res_nquerydomain(statp, name, NULL, class, type,
answer, anslen);
if (ret > 0)
--- 293,303 ----
}
/*
! * 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)) {
ret = res_nquerydomain(statp, name, NULL, class, type,
answer, anslen);
if (ret > 0)
***************
*** 302,308 ****
* else send back meaningless H_ERRNO, that being the one from
* the last DNSRCH we did.
*/
! if (got_nodata)
RES_SET_H_ERRNO(statp, NO_DATA);
else if (got_servfail)
RES_SET_H_ERRNO(statp, TRY_AGAIN);
--- 311,319 ----
* else send back meaningless H_ERRNO, that being the one from
* the last DNSRCH we did.
*/
! if (saved_herrno != -1)
! RES_SET_H_ERRNO(statp, saved_herrno);
! else if (got_nodata)
RES_SET_H_ERRNO(statp, NO_DATA);
else if (got_servfail)
RES_SET_H_ERRNO(statp, TRY_AGAIN);
More information about the bind-workers
mailing list