From nobody@FreeBSD.org  Wed Jun  7 16:36:32 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 09E3E16C048
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  7 Jun 2006 16:32:14 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 1E41943D4C
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  7 Jun 2006 16:32:13 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k57GWCEW065191
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 7 Jun 2006 16:32:12 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k57GWCHw065190;
	Wed, 7 Jun 2006 16:32:12 GMT
	(envelope-from nobody)
Message-Id: <200606071632.k57GWCHw065190@www.freebsd.org>
Date: Wed, 7 Jun 2006 16:32:12 GMT
From: Paul Markfort <paulfm@me.umn.edu>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ypserv ignores the -n option (it always acts like -n has been specified)
X-Send-Pr-Version: www-2.3

>Number:         98625
>Category:       bin
>Synopsis:       ypserv ignores the -n option (it always acts like -n has been specified)
>Confidential:   no
>Severity:       non-critical
>Priority:       high
>Responsible:    maxim
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun 07 16:40:16 GMT 2006
>Closed-Date:    Sat Jul 08 07:54:24 GMT 2006
>Last-Modified:  Sat Jul 08 07:54:24 GMT 2006
>Originator:     Paul Markfort
>Release:        5.4-RELEASE, 6.0-RELEASE
>Organization:
University of Minnesota
>Environment:
FreeBSD {name}.enet.umn.edu 6.0-RELEASE FreeBSD 6.0-RELEASE #0: Fri Jan 20 12:01:
56 CST 2006     root@{name}.enet.umn.edu:/usr/src/sys/i386/compile/{name}  i386
+
FreeBSD {name}.enet.umn.edu 5.4-RELEASE FreeBSD 5.4-RELEASE #1: Tue May 24
13:16:29 CDT 2005     root@{name}.enet.umn.edu:/usr/src/sys/i386/compile/{name}  i386

>Description:
ypserv does DNS lookups for clients all the time and there is no way to turn it off (it is supposed to be off by default).

This is a performance issue (dns lookups add to the load on the server).
It fails to work as the man page says it does.

>How-To-Repeat:
start ypserv (no options)
On client run:

ypmatch junk.jnk hosts

ypmatch microsoft.com hosts

Note the output.
>Fix:
None.
>Release-Note:
>Audit-Trail:

From: PaulFM <paulfm@me.umn.edu>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/98625: ypserv ignores the -n option (it always acts like
 -n has been specified)
Date: Wed, 07 Jun 2006 12:46:37 -0500

 Looks like a problem with parenthesis (precedence) - or it could be a bug in 
 the FREEBSD C compiler.  I added 2 sets of parenthesis and now it works!
 
 
 diff -u yp_server.c ORIG/yp_server.c
 ------------------------------------------------------------------------
 
 --- yp_server.c Wed Jun  7 12:30:42 2006
 +++ ORIG/yp_server.c    Wed Jun  7 12:29:48 2006
 @@ -164,11 +164,11 @@
           */
 
   #ifdef DB_CACHE
 -       if ((result.stat != YP_TRUE) &&
 +       if (result.stat != YP_TRUE &&
              (yp_testflag(argp->map, argp->domain, YP_INTERDOMAIN) ||
               ((strstr(argp->map, "hosts") || strstr(argp->map, "ipnodes")) && do
 _dns))) {
   #else
 -       if (do_dns && (result.stat != YP_TRUE) &&
 +       if (do_dns && result.stat != YP_TRUE &&
              (strstr(argp->map, "hosts") || strstr(argp->map, "ipnodes"))) {
   #endif
                  char                    nbuf[YPMAXRECORD];
 
 ------------------------------------------------------------------------
 
 
 -- 
 ---------------------------------------------------------------------
 The views and opinions expressed above are strictly
 those of the author(s).  The content of this message has
 not been reviewed nor approved by any entity whatsoever.
 ---------------------------------------------------------------------
 Paul F. Markfort   Info/Web: http://www.menet.umn.edu/~paulfm
 ---------------------------------------------------------------------

From: Maxim Konovalov <maxim@macomnet.ru>
To: PaulFM <paulfm@me.umn.edu>
Cc: bug-followup@freebsd.org
Subject: Re: bin/98625: ypserv ignores the -n option (it always acts like -n
 has been specified)
Date: Thu, 8 Jun 2006 12:21:47 +0400 (MSD)

 Hi,
 
 >  Looks like a problem with parenthesis (precedence) - or it could be
 >  a bug in the FREEBSD C compiler.  I added 2 sets of parenthesis and
 >  now it works!
 
 I'm sure our compiler is not that broken :-)
 
 >  diff -u yp_server.c ORIG/yp_server.c
 >  ------------------------------------------------------------------------
 >
 >  --- yp_server.c Wed Jun  7 12:30:42 2006
 >  +++ ORIG/yp_server.c    Wed Jun  7 12:29:48 2006
 >  @@ -164,11 +164,11 @@
 >            */
 >
 >    #ifdef DB_CACHE
 >  -       if ((result.stat != YP_TRUE) &&
 >  +       if (result.stat != YP_TRUE &&
 >               (yp_testflag(argp->map, argp->domain, YP_INTERDOMAIN) ||
 >                ((strstr(argp->map, "hosts") || strstr(argp->map, "ipnodes")) && do
 >  _dns))) {
 >    #else
 >  -       if (do_dns && (result.stat != YP_TRUE) &&
 >  +       if (do_dns && result.stat != YP_TRUE &&
 >               (strstr(argp->map, "hosts") || strstr(argp->map, "ipnodes"))) {
 >    #endif
 >                   char                    nbuf[YPMAXRECORD];
 >
 
 Try my instead:
 
 Index: yp_server.c
 ===================================================================
 RCS file: /home/ncvs/src/usr.sbin/ypserv/yp_server.c,v
 retrieving revision 1.39
 diff -u -p -r1.39 yp_server.c
 --- yp_server.c	2 May 2005 09:42:59 -0000	1.39
 +++ yp_server.c	8 Jun 2006 08:18:46 -0000
 @@ -164,9 +164,9 @@ ypproc_match_2_svc(ypreq_key *argp, stru
  	 */
 
  #ifdef DB_CACHE
 -	if (result.stat != YP_TRUE &&
 +	if (do_dns && result.stat != YP_TRUE &&
  	    (yp_testflag(argp->map, argp->domain, YP_INTERDOMAIN) ||
 -	     ((strstr(argp->map, "hosts") || strstr(argp->map, "ipnodes")) && do_dns))) {
 +	    (strstr(argp->map, "hosts") || strstr(argp->map, "ipnodes")))) {
  #else
  	if (do_dns && result.stat != YP_TRUE &&
  	    (strstr(argp->map, "hosts") || strstr(argp->map, "ipnodes"))) {
 %%%
 
 -- 
 Maxim Konovalov

From: PaulFM <paulfm@me.umn.edu>
To: Maxim Konovalov <maxim@macomnet.ru>
Cc: bug-followup@freebsd.org
Subject: Re: bin/98625: ypserv ignores the -n option (it always acts like
 -n has been specified)
Date: Thu, 08 Jun 2006 13:06:34 -0500

 Further tests have found something very interesting.
 
 1.  The real issue is - ypserv seems to ALWAYS do dns lookups IF the hosts 
 map is empty.
 Adding one entry (localhost) causes all versions to work as expected 
 (un-patched, new and old).
 
 2.  My previous "FIX" is not a fix, but was accompanied by a change in 
 another input to the problem (the hosts map on the test setup had entries in 
 it - I didn't set-up the test maps).  A back check found that the original 
 version of ypserv on that machine did not do dns lookups.
 
 
 So the workaround is to make sure you have at least one entry in your hosts map.
 
 
 
 -- 
 ---------------------------------------------------------------------
 The views and opinions expressed above are strictly
 those of the author(s).  The content of this message has
 not been reviewed nor approved by any entity whatsoever.
 ---------------------------------------------------------------------
 Paul F. Markfort   Info/Web: http://www.menet.umn.edu/~paulfm
 ---------------------------------------------------------------------

From: Maxim Konovalov <maxim@macomnet.ru>
To: PaulFM <paulfm@me.umn.edu>
Cc: bug-followup@freebsd.org
Subject: Re: bin/98625: ypserv ignores the -n option (it always acts like -n
 has been specified)
Date: Thu, 8 Jun 2006 22:08:22 +0400 (MSD)

 On Thu, 8 Jun 2006, 13:06-0500, PaulFM wrote:
 
 > Further tests have found something very interesting.
 >
 > 1.  The real issue is - ypserv seems to ALWAYS do dns lookups IF the
 >    hosts map is empty.  Adding one entry (localhost) causes all
 >    versions to work as expected (un-patched, new and old).
 >
 > 2.  My previous "FIX" is not a fix, but was accompanied by a change
 >    in another input to the problem (the hosts map on the test setup
 >    had entries in it - I didn't set-up the test maps).  A back check
 >    found that the original version of ypserv on that machine did not
 >    do dns lookups.
 >
 >
 > So the workaround is to make sure you have at least one entry in
 > your hosts map.
 
 Have you tried my patch?
 
 -- 
 Maxim Konovalov
State-Changed-From-To: open->patched 
State-Changed-By: maxim 
State-Changed-When: Fri Jun 9 14:03:16 UTC 2006 
State-Changed-Why:  
Paul, I've committed my version of the patch to HEAD and will 
merge it to RELENG_6 in one month.  Please let me know if you 
still have problems with ypserv(8) -n flag behaviour.  Thanks! 


Responsible-Changed-From-To: freebsd-bugs->maxim 
Responsible-Changed-By: maxim 
Responsible-Changed-When: Fri Jun 9 14:03:16 UTC 2006 
Responsible-Changed-Why:  
Feedbacks trap. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=98625 

From: Maxim Konovalov <maxim@macomnet.ru>
To: Paul FM <paulfm@me.umn.edu>
Cc: bug-followup@freebsd.org
Subject: Re: bin/98625: ypserv ignores the -n option (it always acts like -n
 has been specified)
Date: Thu, 6 Jul 2006 20:57:07 +0400 (MSD)

 Paul,
 
 Thanks for your tests, I'll merge the patch to RELENG_6 in one month.
 
 -- 
 Maxim Konovalov
State-Changed-From-To: patched->closed 
State-Changed-By: maxim 
State-Changed-When: Sat Jul 8 07:54:08 UTC 2006 
State-Changed-Why:  
Merged to RELENG_6. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=98625 
>Unformatted:
