NetBSD Problem Report #13794

Received: (qmail 6353 invoked from network); 27 Aug 2001 15:52:10 -0000
Message-Id: <200108271414.f7REEh913608@zorkmid.mit.edu>
Date: Mon, 27 Aug 2001 10:14:43 -0400 (EDT)
From: John Hawkinson <jhawk@mit.edu>
Reply-To: jhawk@mit.edu
To: gnats-bugs@gnats.netbsd.org
Subject: RES_OPTIONS=debug is broken due to res_init.o build issue
X-Send-Pr-Version: 3.95

>Number:         13794
>Category:       lib
>Synopsis:       RES_OPTIONS=debug is broken due to res_init.o build issue
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 27 15:53:01 +0000 2001
>Closed-Date:    
>Last-Modified:  Tue Aug 28 08:05:00 +0000 2001
>Originator:     John Hawkinson
>Release:        NetBSD 1.5.1
>Organization:
MIT
>Environment:

System: NetBSD zorkmid.mit.edu 1.5W NetBSD 1.5W (ZORKMID-$Revision: 1.12 $) #104: Sun Jun 24 21:48:35 EDT 2001 jhawk@zorkmid.mit.edu:/usr/local/netbsd-current/src/sys/arch/i386/compile/ZORKMID i386


>Description:
Setting "RES_OPTIONS=debug" does not work for resolver debugging.

This appears to be because, despite the fact that libresolv is built
with -DDEBUG to get this support, res_init.o, which is part of libc,
is not so-built.
>How-To-Repeat:
"env RES_OPTIONS=debug ping and.mit.edu" and watch it fail.

>Fix:
Build res_init.o with -DDEBUG. I'm not sure of the best way, though.
Setting CPPFLAGS+=-DEDBUG in src/lib/libc/Makefile would certainly do
it, but that would build other things with -DDEBUG and that is probably
undesirable.

Conversly, changing the #ifdef DEBUG to #ifdef RES_DEBUG in res_init.c
would probably complicate merging.

Perhaps setting -DRES_DEBUG in the Makefile and then adding

	#ifdef RES_DEBUG
	#define DEBUG
	#endif

at the head of res_init.c?

Thoughts?
>Release-Note:
>Audit-Trail:

From: matthew green <mrg@eterna.com.au>
To: jhawk@mit.edu
Cc: gnats-bugs@gnats.netbsd.org
Subject: re: lib/13794: RES_OPTIONS=debug is broken due to res_init.o build issue 
Date: Tue, 28 Aug 2001 02:18:42 +1000

 even if libresolv were to include res_init.o, this shouldn't help you
 with ping (a static *and* set-id binary).  if it were a normal shared
 binary, one could use LD_PRELOAD to load libresolv.so, given it was
 built with res_init.so....  


 BTW, actually changing the libc resolver to be built with it's DEBUG
 support is something else....

From: John Hawkinson <jhawk@MIT.EDU>
To: matthew green <mrg@eterna.com.au>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: lib/13794: RES_OPTIONS=debug is broken due to res_init.o build issue
Date: Mon, 27 Aug 2001 12:21:41 -0400

 matthew green <mrg@eterna.com.au> wrote on Tue, 28 Aug 2001
 at 02:18:42 +1000 in <10008.998929122@splode.eterna.com.au>:

 > even if libresolv were to include res_init.o,

 That was not the proposal. The proposal was to fix res_init.o in libc.

 > this shouldn't help you with ping (a static *and* set-id binary).
 > if it were a normal shared binary, one could use LD_PRELOAD to load
 > libresolv.so, given it was built with res_init.so....

 Actually, I wasn't at all concerned about ping, it was just a convenient
 example.

 > BTW, actually changing the libc resolver to be built with it's DEBUG
 > support is something else....

 That's really what I was proposing, but I suppose I had my head warped
 around "some other OS" which places most resolver routines in libresolv
 and not in libc. But of course that's not how we do things here.

 So, yes, a better choice would be to do as I proposed for all
 the res_* files.

 --jhawk

From: woods@weird.com (Greg A. Woods)
To: gnats-bugs@gnats.netbsd.org (NetBSD GNATS submissions and followups),
	netbsd-bugs@NetBSD.ORG (NetBSD Bugs and PR posting List)
Cc:  
Subject: Re: lib/13794: RES_OPTIONS=debug is broken due to res_init.o build issue
Date: Mon, 27 Aug 2001 17:29:04 -0400 (EDT)

 [ On Monday, August 27, 2001 at 10:14:43 (-0400), John Hawkinson wrote: ]
 > Subject: lib/13794: RES_OPTIONS=debug is broken due to res_init.o build issue
 >
 > Conversly, changing the #ifdef DEBUG to #ifdef RES_DEBUG in res_init.c
 > would probably complicate merging.

 Not that much since such lines will rarely change in the vendor sources:

 I've not had any conflicts needing manual resolution since I introduced
 thse changes quite some time ago (since before the last resolver update).

 (This patch also includes my "ALLOW_HOSTALIASES" patch which allows you
 to permanently disable support for the HOSTALIASES env var; as well as a
 few minor documentation tweaks.)

 Index: Makefile.inc
 ===================================================================
 RCS file: /cvs/NetBSD/src/lib/libc/net/Makefile.inc,v
 retrieving revision 1.1.1.6
 diff -c -r1.1.1.6 Makefile.inc
 *** Makefile.inc	12 Jun 2001 21:12:26 -0000	1.1.1.6
 --- Makefile.inc	13 Jun 2001 15:32:48 -0000
 ***************
 *** 15,20 ****
 --- 15,21 ----
   	res_mkquery.c res_query.c res_send.c send.c sethostent.c

   SRCS+=	__dn_comp.c __res_close.c __res_send.c _inet_aton.c _inet_pton.c
 + CPPFLAGS+=-DRESOLVDEBUG
   CPPFLAGS+=-DRESOLVSORT -I.

   # IPv6
 Index: getaddrinfo.c
 ===================================================================
 RCS file: /cvs/NetBSD/src/lib/libc/net/getaddrinfo.c,v
 retrieving revision 1.1.1.3
 diff -c -r1.1.1.3 getaddrinfo.c
 *** getaddrinfo.c	25 Mar 2001 06:24:28 -0000	1.1.1.3
 --- getaddrinfo.c	7 May 2001 20:59:49 -0000
 ***************
 *** 1696,1702 ****
   		type = t->qtype;
   		answer = t->answer;
   		anslen = t->anslen;
 ! #ifdef DEBUG
   		if (_res.options & RES_DEBUG)
   			printf(";; res_query(%s, %d, %d)\n", name, class, type);
   #endif
 --- 1696,1702 ----
   		type = t->qtype;
   		answer = t->answer;
   		anslen = t->anslen;
 ! #ifdef RESOLVDEBUG
   		if (_res.options & RES_DEBUG)
   			printf(";; res_query(%s, %d, %d)\n", name, class, type);
   #endif
 ***************
 *** 1708,1714 ****
   			n = res_opt(n, buf, sizeof(buf), anslen);
   #endif
   		if (n <= 0) {
 ! #ifdef DEBUG
   			if (_res.options & RES_DEBUG)
   				printf(";; res_query: mkquery failed\n");
   #endif
 --- 1708,1714 ----
   			n = res_opt(n, buf, sizeof(buf), anslen);
   #endif
   		if (n <= 0) {
 ! #ifdef RESOLVDEBUG
   			if (_res.options & RES_DEBUG)
   				printf(";; res_query: mkquery failed\n");
   #endif
 ***************
 *** 1718,1724 ****
   		n = res_send(buf, n, answer, anslen);
   #if 0
   		if (n < 0) {
 ! #ifdef DEBUG
   			if (_res.options & RES_DEBUG)
   				printf(";; res_query: send error\n");
   #endif
 --- 1718,1724 ----
   		n = res_send(buf, n, answer, anslen);
   #if 0
   		if (n < 0) {
 ! #ifdef RESOLVDEBUG
   			if (_res.options & RES_DEBUG)
   				printf(";; res_query: send error\n");
   #endif
 ***************
 *** 1729,1735 ****

   		if (n < 0 || hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
   			rcode = hp->rcode;	/* record most recent error */
 ! #ifdef DEBUG
   			if (_res.options & RES_DEBUG)
   				printf(";; rcode = %d, ancount=%d\n", hp->rcode,
   				    ntohs(hp->ancount));
 --- 1729,1735 ----

   		if (n < 0 || hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
   			rcode = hp->rcode;	/* record most recent error */
 ! #ifdef RESOLVDEBUG
   			if (_res.options & RES_DEBUG)
   				printf(";; rcode = %d, ancount=%d\n", hp->rcode,
   				    ntohs(hp->ancount));
 ***************
 *** 1801,1811 ****
 --- 1801,1813 ----
   	if (cp > name && *--cp == '.')
   		trailing_dot++;

 + #ifdef ALLOW_HOSTALIASES
   	/*
   	 * if there aren't any dots, it could be a user-level alias
   	 */
   	if (!dots && (cp = __hostalias(name)) != NULL)
   		return (res_queryN(cp, target));
 + #endif

   	/*
   	 * If there are dots in the name already, let's just give it a try
 ***************
 *** 1931,1937 ****
   		h_errno = NETDB_INTERNAL;
   		return (-1);
   	}
 ! #ifdef DEBUG
   	if (_res.options & RES_DEBUG)
   		printf(";; res_querydomain(%s, %s)\n",
   			name, domain?domain:"<Nil>");
 --- 1933,1939 ----
   		h_errno = NETDB_INTERNAL;
   		return (-1);
   	}
 ! #ifdef RESOLVDEBUG
   	if (_res.options & RES_DEBUG)
   		printf(";; res_querydomain(%s, %s)\n",
   			name, domain?domain:"<Nil>");
 Index: gethnamaddr.c
 ===================================================================
 RCS file: /cvs/NetBSD/src/lib/libc/net/gethnamaddr.c,v
 retrieving revision 1.1.1.6
 diff -c -r1.1.1.6 gethnamaddr.c
 *** gethnamaddr.c	12 Jun 2001 21:12:27 -0000	1.1.1.6
 --- gethnamaddr.c	13 Jun 2001 15:32:48 -0000
 ***************
 *** 145,151 ****
       char ac;
   } align;

 ! #ifdef DEBUG
   static void dprintf __P((char *, ...))
   	__attribute__((__format__(__printf__, 1, 2)));
   #endif
 --- 145,151 ----
       char ac;
   } align;

 ! #ifdef RESOLVDEBUG
   static void dprintf __P((char *, ...))
   	__attribute__((__format__(__printf__, 1, 2)));
   #endif
 ***************
 *** 185,191 ****
   };


 ! #ifdef DEBUG
   static void
   dprintf(char *msg, ...)
   {
 --- 185,191 ----
   };


 ! #ifdef RESOLVDEBUG
   static void
   dprintf(char *msg, ...)
   {
 ***************
 *** 576,581 ****
 --- 576,582 ----
   	host.h_addrtype = af;
   	host.h_length = size;

 + #ifdef ALLOW_HOSTALIASES
   	/*
   	 * if there aren't any dots, it could be a user-level alias.
   	 * this is also done in res_query() since we are not the only
 ***************
 *** 583,588 ****
 --- 584,590 ----
   	 */
   	if (!strchr(name, '.') && (cp = __hostalias(name)))
   		name = cp;
 + #endif

   	/*
   	 * disallow names consisting only of digits/dots, unless
 Index: gethostbyname.3
 ===================================================================
 RCS file: /cvs/NetBSD/src/lib/libc/net/gethostbyname.3,v
 retrieving revision 1.1.1.6
 diff -c -r1.1.1.6 gethostbyname.3
 *** gethostbyname.3	12 Jun 2001 21:12:27 -0000	1.1.1.6
 --- gethostbyname.3	13 Jun 2001 15:32:48 -0000
 ***************
 *** 121,128 ****
   and
   .Fn gethostbyname2
   will search for the named host in the current domain and its parents
 ! unless the name ends in a dot.
 ! If the name contains no dot, and if the environment variable
   .Dq Ev HOSTALIASES
   contains the name of an alias file, the alias file will first be searched
   for an alias matching the input name.
 --- 121,129 ----
   and
   .Fn gethostbyname2
   will search for the named host in the current domain and its parents
 ! unless the name ends in a dot.  If the name contains no dot, and if
 ! support for the following feature has been compiled into the system (it
 ! is not by default), and if the environment variable
   .Dq Ev HOSTALIASES
   contains the name of an alias file, the alias file will first be searched
   for an alias matching the input name.
 Index: getnameinfo.3
 ===================================================================
 RCS file: /cvs/NetBSD/src/lib/libc/net/getnameinfo.3,v
 retrieving revision 1.1.1.4
 diff -c -r1.1.1.4 getnameinfo.3
 *** getnameinfo.3	12 Jun 2001 21:12:28 -0000	1.1.1.4
 --- getnameinfo.3	13 Jun 2001 15:32:48 -0000
 ***************
 *** 261,266 ****
 --- 261,267 ----
   .El
   .\"
   .Sh SEE ALSO
 + .Xr gai_strerror 3 ,
   .Xr getaddrinfo 3 ,
   .Xr gethostbyaddr 3 ,
   .Xr getservbyport 3 ,
 Index: getnetnamadr.c
 ===================================================================
 RCS file: /cvs/NetBSD/src/lib/libc/net/getnetnamadr.c,v
 retrieving revision 1.1.1.5
 diff -c -r1.1.1.5 getnetnamadr.c
 *** getnetnamadr.c	25 Mar 2001 06:24:30 -0000	1.1.1.5
 --- getnetnamadr.c	7 May 2001 21:00:25 -0000
 ***************
 *** 319,325 ****
   	anslen = res_query(qbuf, C_IN, T_PTR, (u_char *)(void *)&buf,
   	    sizeof(buf));
   	if (anslen < 0) {
 ! #ifdef DEBUG
   		if (_res.options & RES_DEBUG)
   			printf("res_query failed\n");
   #endif
 --- 319,325 ----
   	anslen = res_query(qbuf, C_IN, T_PTR, (u_char *)(void *)&buf,
   	    sizeof(buf));
   	if (anslen < 0) {
 ! #ifdef RESOLVDEBUG
   		if (_res.options & RES_DEBUG)
   			printf("res_query failed\n");
   #endif
 ***************
 *** 424,430 ****
   	anslen = res_search(qbuf, C_IN, T_PTR, (u_char *)(void *)&buf,
   	    sizeof(buf));
   	if (anslen < 0) {
 ! #ifdef DEBUG
   		if (_res.options & RES_DEBUG)
   			printf("res_query failed\n");
   #endif
 --- 424,430 ----
   	anslen = res_search(qbuf, C_IN, T_PTR, (u_char *)(void *)&buf,
   	    sizeof(buf));
   	if (anslen < 0) {
 ! #ifdef RESOLVDEBUG
   		if (_res.options & RES_DEBUG)
   			printf("res_query failed\n");
   #endif
 Index: inet.3
 ===================================================================
 RCS file: /cvs/NetBSD/src/lib/libc/net/inet.3,v
 retrieving revision 1.1.1.4
 diff -c -r1.1.1.4 inet.3
 *** inet.3	25 Mar 2001 06:24:35 -0000	1.1.1.4
 --- inet.3	25 Mar 2001 20:34:41 -0000
 ***************
 *** 115,120 ****
 --- 115,121 ----
   functions return numbers suitable for use
   as Internet addresses and Internet network
   numbers, respectively.
 + The return values of both functions are in network byte order.
   .Pp
   The function
   .Fn inet_ntop
 ***************
 *** 151,160 ****
   break apart Internet host addresses, returning the network number and
   local network address part, respectively (both in host order).
   .Pp
 ! All Internet addresses are returned in network
 ! order (bytes ordered from left to right).
   All network numbers and local address parts are
   returned as machine format integer values.
   .Sh INTERNET ADDRESSES (IP VERSION 4)
   Values specified using the
   .Qq dotted quad
 --- 152,165 ----
   break apart Internet host addresses, returning the network number and
   local network address part, respectively (both in host order).
   .Pp
 ! All Internet addresses (in
 ! .Ft struct in_addr
 ! form) are in network byte order (bytes ordered with the most significant
 ! byte from left to right, i.e. big endian, i.e. 4321).
 ! .Pp
   All network numbers and local address parts are
   returned as machine format integer values.
 + .\"
   .Sh INTERNET ADDRESSES (IP VERSION 4)
   Values specified using the
   .Qq dotted quad
 Index: res_debug.c
 ===================================================================
 RCS file: /cvs/NetBSD/src/lib/libc/net/res_debug.c,v
 retrieving revision 1.1.1.5
 diff -c -r1.1.1.5 res_debug.c
 *** res_debug.c	25 Mar 2001 06:24:43 -0000	1.1.1.5
 --- res_debug.c	26 Mar 2001 00:29:15 -0000
 ***************
 *** 1086,1091 ****
 --- 1086,1097 ----
   	case RES_DNSRCH:	return "dnsrch";
   	case RES_INSECURE1:	return "insecure1";
   	case RES_INSECURE2:	return "insecure2";
 + #ifdef ALLOW_HOSTALIASES
 + 	case RES_NOALIASES:	return "noaliases";
 + #else
 + 	case RES_NOALIASES:	return "noaliases(always)";
 + #endif
 + 	case RES_USE_INET6:	return "inet6";
   #ifdef RES_USE_EDNS0
   	case RES_USE_EDNS0:	return "edns0";
   #endif
 Index: res_init.c
 ===================================================================
 RCS file: /cvs/NetBSD/src/lib/libc/net/res_init.c,v
 retrieving revision 1.1.1.6
 diff -c -r1.1.1.6 res_init.c
 *** res_init.c	25 Mar 2001 06:24:43 -0000	1.1.1.6
 --- res_init.c	7 May 2001 21:00:59 -0000
 ***************
 *** 494,507 ****
   			dots--;
   		}
   		*pp = NULL;
 ! #ifdef DEBUG
   		if (_res.options & RES_DEBUG) {
   			printf(";; res_init()... default dnsrch list:\n");
   			for (pp = _res.dnsrch; *pp; pp++)
   				printf(";;\t%s\n", *pp);
   			printf(";;\t..END..\n");
   		}
 ! #endif /* DEBUG */
   #endif /* !RFC1535 */
   	}

 --- 494,507 ----
   			dots--;
   		}
   		*pp = NULL;
 ! #ifdef RESOLVDEBUG
   		if (_res.options & RES_DEBUG) {
   			printf(";; res_init()... default dnsrch list:\n");
   			for (pp = _res.dnsrch; *pp; pp++)
   				printf(";;\t%s\n", *pp);
   			printf(";;\t..END..\n");
   		}
 ! #endif /* RESOLVDEBUG */
   #endif /* !RFC1535 */
   	}

 ***************
 *** 522,528 ****
   	_DIAGASSERT(options != NULL);
   	_DIAGASSERT(source != NULL);

 ! #ifdef DEBUG
   	if (_res.options & RES_DEBUG)
   		printf(";; res_setoptions(\"%s\", \"%s\")...\n",
   		       options, source);
 --- 522,528 ----
   	_DIAGASSERT(options != NULL);
   	_DIAGASSERT(source != NULL);

 ! #ifdef RESOLVDEBUG
   	if (_res.options & RES_DEBUG)
   		printf(";; res_setoptions(\"%s\", \"%s\")...\n",
   		       options, source);
 ***************
 *** 538,549 ****
   				_res.ndots = i;
   			else
   				_res.ndots = RES_MAXNDOTS;
 ! #ifdef DEBUG
   			if (_res.options & RES_DEBUG)
   				printf(";;\tndots=%d\n", _res.ndots);
   #endif
   		} else if (!strncmp(cp, "debug", sizeof("debug") - 1)) {
 ! #ifdef DEBUG
   			if (!(_res.options & RES_DEBUG)) {
   				printf(";; res_setoptions(\"%s\", \"%s\")..\n",
   				       options, source);
 --- 538,549 ----
   				_res.ndots = i;
   			else
   				_res.ndots = RES_MAXNDOTS;
 ! #ifdef RESOLVDEBUG
   			if (_res.options & RES_DEBUG)
   				printf(";;\tndots=%d\n", _res.ndots);
   #endif
   		} else if (!strncmp(cp, "debug", sizeof("debug") - 1)) {
 ! #ifdef RESOLVDEBUG
   			if (!(_res.options & RES_DEBUG)) {
   				printf(";; res_setoptions(\"%s\", \"%s\")..\n",
   				       options, source);
 Index: res_mkquery.c
 ===================================================================
 RCS file: /cvs/NetBSD/src/lib/libc/net/res_mkquery.c,v
 retrieving revision 1.1.1.5
 diff -c -r1.1.1.5 res_mkquery.c
 *** res_mkquery.c	25 Mar 2001 06:24:44 -0000	1.1.1.5
 --- res_mkquery.c	7 May 2001 21:01:21 -0000
 ***************
 *** 110,116 ****
   		h_errno = NETDB_INTERNAL;
   		return (-1);
   	}
 ! #ifdef DEBUG
   	if (_res.options & RES_DEBUG)
   		printf(";; res_mkquery(%d, %s, %d, %d)\n",
   		       op, dname, class, type);
 --- 110,116 ----
   		h_errno = NETDB_INTERNAL;
   		return (-1);
   	}
 ! #ifdef RESOLVDEBUG
   	if (_res.options & RES_DEBUG)
   		printf(";; res_mkquery(%d, %s, %d, %d)\n",
   		       op, dname, class, type);
 ***************
 *** 121,127 ****
   	/*CONSTCOND*/
   	if (sizeof(HEADER) != HFIXEDSZ) {
   		/* XXX should raise compile time error, not runtime error */
 ! #ifdef DEBUG
   		if (_res.options & RES_DEBUG)
   			printf(";; HFIXEDSZ mismatch with sizeof(HEADER)\n");
   #endif
 --- 121,127 ----
   	/*CONSTCOND*/
   	if (sizeof(HEADER) != HFIXEDSZ) {
   		/* XXX should raise compile time error, not runtime error */
 ! #ifdef RESOLVDEBUG
   		if (_res.options & RES_DEBUG)
   			printf(";; HFIXEDSZ mismatch with sizeof(HEADER)\n");
   #endif
 Index: res_query.c
 ===================================================================
 RCS file: /cvs/NetBSD/src/lib/libc/net/res_query.c,v
 retrieving revision 1.1.1.5
 diff -c -r1.1.1.5 res_query.c
 *** res_query.c	25 Mar 2001 06:24:44 -0000	1.1.1.5
 --- res_query.c	7 May 2001 21:01:39 -0000
 ***************
 *** 124,130 ****
   		h_errno = NETDB_INTERNAL;
   		return (-1);
   	}
 ! #ifdef DEBUG
   	if (_res.options & RES_DEBUG)
   		printf(";; res_query(%s, %d, %d)\n", name, class, type);
   #endif
 --- 124,130 ----
   		h_errno = NETDB_INTERNAL;
   		return (-1);
   	}
 ! #ifdef RESOLVDEBUG
   	if (_res.options & RES_DEBUG)
   		printf(";; res_query(%s, %d, %d)\n", name, class, type);
   #endif
 ***************
 *** 136,142 ****
   		n = res_opt(n, buf, sizeof(buf), anslen);
   #endif
   	if (n <= 0) {
 ! #ifdef DEBUG
   		if (_res.options & RES_DEBUG)
   			printf(";; res_query: mkquery failed\n");
   #endif
 --- 136,142 ----
   		n = res_opt(n, buf, sizeof(buf), anslen);
   #endif
   	if (n <= 0) {
 ! #ifdef RESOLVDEBUG
   		if (_res.options & RES_DEBUG)
   			printf(";; res_query: mkquery failed\n");
   #endif
 ***************
 *** 145,151 ****
   	}
   	n = res_send(buf, n, answer, anslen);
   	if (n < 0) {
 ! #ifdef DEBUG
   		if (_res.options & RES_DEBUG)
   			printf(";; res_query: send error\n");
   #endif
 --- 145,151 ----
   	}
   	n = res_send(buf, n, answer, anslen);
   	if (n < 0) {
 ! #ifdef RESOLVDEBUG
   		if (_res.options & RES_DEBUG)
   			printf(";; res_query: send error\n");
   #endif
 ***************
 *** 154,160 ****
   	}

   	if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
 ! #ifdef DEBUG
   		if (_res.options & RES_DEBUG)
   			printf(";; rcode = %d, ancount=%d\n", hp->rcode,
   			    ntohs(hp->ancount));
 --- 154,160 ----
   	}

   	if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
 ! #ifdef RESOLVDEBUG
   		if (_res.options & RES_DEBUG)
   			printf(";; rcode = %d, ancount=%d\n", hp->rcode,
   			    ntohs(hp->ancount));
 ***************
 *** 217,227 ****
 --- 217,229 ----
   	if (cp > name && *--cp == '.')
   		trailing_dot++;

 + #ifdef ALLOW_HOSTALIASES
   	/*
   	 * if there aren't any dots, it could be a user-level alias
   	 */
   	if (!dots && (cp = __hostalias(name)) != NULL)
   		return (res_query(cp, class, type, answer, anslen));
 + #endif

   	/*
   	 * If there are dots in the name already, let's just give it a try
 ***************
 *** 351,357 ****
   		h_errno = NETDB_INTERNAL;
   		return (-1);
   	}
 ! #ifdef DEBUG
   	if (_res.options & RES_DEBUG)
   		printf(";; res_querydomain(%s, %s, %d, %d)\n",
   			name, domain?domain:"<Nil>", class, type);
 --- 353,359 ----
   		h_errno = NETDB_INTERNAL;
   		return (-1);
   	}
 ! #ifdef RESOLVDEBUG
   	if (_res.options & RES_DEBUG)
   		printf(";; res_querydomain(%s, %s, %d, %d)\n",
   			name, domain?domain:"<Nil>", class, type);
 ***************
 *** 383,388 ****
 --- 385,391 ----
   	return (res_query(longname, class, type, answer, anslen));
   }

 + #ifdef ALLOW_HOSTALIASES
   const char *
   __hostalias(name)
   	const char *name;
 ***************
 *** 440,442 ****
 --- 443,446 ----
   	(void)fclose(fp);
   	return (NULL);
   }
 + #endif
 Index: res_send.c
 ===================================================================
 RCS file: /cvs/NetBSD/src/lib/libc/net/res_send.c,v
 retrieving revision 1.1.1.5
 diff -c -r1.1.1.5 res_send.c
 *** res_send.c	25 Mar 2001 06:24:44 -0000	1.1.1.5
 --- res_send.c	7 May 2001 21:02:20 -0000
 ***************
 *** 117,123 ****

   #define CAN_RECONNECT 1

 ! #ifndef DEBUG
   #   define Dprint(cond, args) /*empty*/
   #   define DprintQ(cond, args, query, size) /*empty*/
   #   define Aerror(file, string, error, address) /*empty*/
 --- 117,123 ----

   #define CAN_RECONNECT 1

 ! #ifndef RESOLVDEBUG
   #   define Dprint(cond, args) /*empty*/
   #   define DprintQ(cond, args, query, size) /*empty*/
   #   define Aerror(file, string, error, address) /*empty*/


 -- 
 							Greg A. Woods

 +1 416 218-0098      VE3TCP      <gwoods@acm.org>     <woods@robohack.ca>
 Planix, Inc. <woods@planix.com>;   Secrets of the Weird <woods@weird.com>

From: John Hawkinson <jhawk@MIT.EDU>
To: woods@weird.com (Greg A. Woods)
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: lib/13794: RES_OPTIONS=debug is broken due to res_init.o build issue
Date: Tue, 28 Aug 2001 00:07:08 -0400 (EDT)

 I see you chose not to reply to me personally in your message.
 Kindly don't do that. It impedes rapid dialogue and convenience.

 I drop netbsd-bugs from the cc list but leave it in the envelope.

 | (This patch also includes my "ALLOW_HOSTALIASES" patch which allows you
 | to permanently disable support for the HOSTALIASES env var; as well as a
 | few minor documentation tweaks.)

 That pertty much guarantees that it won't be applied, because no one is
 likely to do the work of seperating out your changes, and they should
 be committed seperately.

 In principal, the person handling your patch could do that work, but
 I certainly don't want to. You make more work for me, and that bothers
 me philosophically. Make less work for me, please.


 In any case, you provide no compelling argument for why
 DEBUG should be wholesale replaced with RESOLVDEBUG. I will
 accept that such arguments exist, but really, they should
 be made, not presumed.

 --jhawk

From: itojun@iijlab.net
To: jhawk@mit.edu
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: lib/13794: RES_OPTIONS=debug is broken due to res_init.o build issue 
Date: Tue, 28 Aug 2001 15:04:16 +0900

 >>Synopsis:       RES_OPTIONS=debug is broken due to res_init.o build issue

 	i'm still not sure if the debugging code fragment should be put
 	into libc or not.  printf()s from libc may be useful, maybe not.

 itojun

From: woods@weird.com (Greg A. Woods)
To: John Hawkinson <jhawk@MIT.EDU>
Cc: gnats-bugs@gnats.netbsd.org (NetBSD GNATS submissions and followups),
	netbsd-bugs@NetBSD.ORG (NetBSD Bugs and PR posting List)
Subject: Re: lib/13794: RES_OPTIONS=debug is broken due to res_init.o build issue
Date: Tue, 28 Aug 2001 04:09:01 -0400 (EDT)

 [ On Tuesday, August 28, 2001 at 00:07:08 (-0400), John Hawkinson wrote: ]
 > Subject: Re: lib/13794: RES_OPTIONS=debug is broken due to res_init.o build issue
 >
 > I see you chose not to reply to me personally in your message.
 > Kindly don't do that. It impedes rapid dialogue and convenience.

 So sorry -- I usually prefer to correspond with list postings only via
 the list (and in this case through GNATS too).....

 I'm not so much interested in rapid dialogue (especially in a case like
 this where I'm simply reporting an example of something I did months
 ago).  I'm more interested in public discourse and as such I prefer to
 have all related postings explicitly forwarded only through the public
 forum(s).

 > I drop netbsd-bugs from the cc list but leave it in the envelope.

 Please don't ever override my reply-to: header though (unless maybe it's
 just to change the forum from being public to private) -- I set it
 explicitly to the list (and GNATS in this case) on purpose.  I do not
 want to get duplicates (as I did in this case).

 Dropping netbsd-bugs in this case drops the public forum through which
 people commonly monitor the progress of GNATS PRs.  It's a convenience,
 to be sure, but a very valuable one.  Had I configured GNATS for NetBSD
 I'd have made netbsd-bugs a moderated list and forwarded all replies
 sent to GNATS back out to netbsd-bugs (and perhaps even made all change
 notices go there too) (i.e. made netbsd-bugs a write-only distribution
 list for PR postings and updates).  The moderator could be /dev/null too
 (though that might be a bit harsh).

 > | (This patch also includes my "ALLOW_HOSTALIASES" patch which allows you
 > | to permanently disable support for the HOSTALIASES env var; as well as a
 > | few minor documentation tweaks.)
 > 
 > That pertty much guarantees that it won't be applied, because no one is
 > likely to do the work of seperating out your changes, and they should
 > be committed seperately.

 Oh well.  I don't really care either way and I don't have time to
 separate out diffs.  I'll run the "cvs diff" to show what I've done to
 my release -- you can take what you want from that.  If I'd have
 committed and tagged the changes separately in my repository then I
 could provide separate diffs, but unfortunately that's not the way I've
 been doing things so all I've got are amassed diffs of all my changes.
 In this case I was able to simply show the changes to the files from
 just the one directory since as far as I remember they're all contained
 in that one place.  Pretend it's the good old days pre-CVS, pre-Patch,
 and I'm just some random user who submits a big hunk of diffs and be
 happy if I offer at least some documentation and rationale for my
 changes.  It's "your" job as the maintainer to select from my changes
 those which "you" feel are applicable for the general release and to
 rewrite them as necessary.

 > In any case, you provide no compelling argument for why
 > DEBUG should be wholesale replaced with RESOLVDEBUG. I will
 > accept that such arguments exist, but really, they should
 > be made, not presumed.

 I thought your original PR made it abundantly clear that DEBUG has a
 different meaning in the general NetBSD source tree from whatever
 #define might be used to enable support for run-time user-level
 debugging in the resolver library.  However you expressed some confusion
 over which way you thought would be best to fix the disparity.

 My reply was to simply point out that using the same flag/#define for
 different purposes, especially if it's magically renamed in the
 alternative you proposed, is very misleading and prone to error, and
 that contrary to your claim a change of the "#ifdef DEBUG" lines will
 not overly complicate the merging (importing) of future resolver source
 releases.  I provided my diffs as simply a reference to where I'd found
 lines which needed changing.

 Note also that the resolver debug code should probably always be
 available by default (it's more or less documented as being always
 available in several places).  However 'DEBUG' is, as I understand it,
 not really supposed to be on by default in the NetBSD tree.  The best
 way to accomplish this in a lucid way is to use a separate manifest
 constant to enable (or conversely disable) the ressolver runtime
 user-level debug code.

 Indeed the only reason for being able to turn off the resolver
 user-level debugging seems to be for the relatively rare scenarios where
 the resolver library is being built for some embedded or similar
 application with extremely limited system resources available to it.

 The fact that the vendor sources used the lame naming convention of a
 simple un-qualified "DEBUG" flag for a special purpose configuration
 item is unfortunate, but not terribly unexpected in general.

 The only potential problem I forsee in the proposal as I made it is that
 if future vendor updates add new "#ifdef DEBUG" code whomever does the
 import will have to check that these are also caught and converted if
 necessary.  To this end a helper script to do the import preparation (is
 there a bind2netbsd.sh or libresolv2netbsd.sh anywhwere?) could allert
 the developer doing the import if any new unconverted "#ifdef DEBUG"s
 appear anywhere.

 -- 
 							Greg A. Woods

 +1 416 218-0098      VE3TCP      <gwoods@acm.org>     <woods@robohack.ca>
 Planix, Inc. <woods@planix.com>;   Secrets of the Weird <woods@weird.com>
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.