From steve@energistic.com  Fri Jul 19 07:15:55 2002
Return-Path: <steve@energistic.com>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id BD59537B400
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 19 Jul 2002 07:15:55 -0700 (PDT)
Received: from energistic.com (bdsl.66.12.217.106.gte.net [66.12.217.106])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 022D043E67
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 19 Jul 2002 07:15:55 -0700 (PDT)
	(envelope-from steve@energistic.com)
Received: from energistic.com (steve@localhost [127.0.0.1])
	by energistic.com (8.12.5/8.12.5) with ESMTP id g6JEFrHH025781
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 19 Jul 2002 09:15:54 -0500 (EST)
	(envelope-from steve@energistic.com)
Received: (from steve@localhost)
	by energistic.com (8.12.5/8.12.5/Submit) id g6JEFrPv024575;
	Fri, 19 Jul 2002 09:15:53 -0500 (EST)
Message-Id: <200207191415.g6JEFrPv024575@energistic.com>
Date: Fri, 19 Jul 2002 09:15:53 -0500 (EST)
From: Steve Ames <steve@virtual-voodoo.com>
Reply-To: Steve Ames <steve@virtual-voodoo.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: inetd.c 1.105 breaks inetd.conf parsing on non IPv6 systems
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         40771
>Category:       bin
>Synopsis:       inetd.c 1.105 breaks inetd.conf parsing on non IPv6 systems
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    dwmalone
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 19 07:20:01 PDT 2002
>Closed-Date:    Thu Sep 05 10:28:14 PDT 2002
>Last-Modified:  Thu Sep 05 10:28:14 PDT 2002
>Originator:     Steve Ames
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
i386
System: FreeBSD energistic.com 5.0-CURRENT FreeBSD 5.0-CURRENT #1: Wed Jul 17 13:53:51 EST 2002 steve@energistic.com:/usr/obj/usr/src/sys/SB i386


	i386: AMD Athlon 1.4Ghz, 512M DDR RAM, 5.0-CURRENT (7/17/02)
>Description:
	A recent change to src/usr.sbin/inetd/inetd.c causes inetd.conf
	lines to be ignored instead of processed. This, in turn, causes
	a lot of processes not to work properly. The version causing
	the problem is 1.105.

>How-To-Repeat:
	Upgrade to -CURRENT without IP6 enabled and leave tcp6 lines in
	your inetd.conf file. The lines are processed normally until the
	first tcp6 line which is, correctly, ignored. All further lines
	are ignored with a "IPv6 Ignored" comment (invoking inetd with
	'inetd -d').

>Fix:

	A workaround is just to comment out or remove all IPv6 related
	lines from your inetd.conf. However since inetd should process
	them correctly this is only a workaround. The following patch
	fixes the problem.

---------------------------------------------------------
--- inetd.c.old Mon Jul 15 14:09:33 2002
+++ inetd.c     Thu Jul 18 11:53:55 2002
@@ -1726,12 +1726,9 @@
        if (v6bind != 0 && no_v6bind != 0) {
                syslog(LOG_INFO, "IPv6 bind is ignored for %s",
                       sep->se_service);
-               if (v4bind && no_v4bind == 0)
-                       v6bind = 0;
-               else {
-                       freeconfig(sep);
-                       goto more;
-               }
+               v6bind = 0;
+               freeconfig(sep);
+               goto more;
        }
        if (v6bind != 0) {
                sep->se_family = AF_INET6;
---------------------------------------------------------

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->dwmalone 
Responsible-Changed-By: dwmalone 
Responsible-Changed-When: Fri Jul 19 07:28:15 PDT 2002 
Responsible-Changed-Why:  
I'll have a look at this, unless Alfred gets there before me. 

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

From: Jean-Luc Richier <Jean-Luc.Richier@imag.fr>
To: freebsd-gnats-submit@FreeBSD.org, steve@virtual-voodoo.com
Cc:  
Subject: Re: bin/40771: inetd.c 1.105 breaks inetd.conf parsing on non IPv6 
 systems
Date: Thu, 22 Aug 2002 18:31:44 +0200

 This is a multi-part message in MIME format.
 --------------5BD50F45EB0B35D5F552C600
 Content-Type: text/plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 Sorry, I am the author of the bug, and I was in holidays. So I answer
 only now.
 
 The proposed fix is too strong for on a IPv4 only machine it forbid
 tcp46 entries.
 The correction is much simpler : when ignoring a line and going back to
 a label at  to the beginning to start back, it is better to initialize
 variables AFTER the loopback label :-)
 Also there are 3 other problems in my inetd patch
 2 are minor :  mispelling (tpc for tcp) and allowing unix4, unix6,
 the third is more impotant : a statement breaking if/then/else sequence
 and therfore all unix entries
 
 So here is the suggested solution.
 It is long, but most is the inversion of the tests for unix and for 4/6
 suffix,, which cause a lot of modifications in indentation
 
 
 --
 Jean-Luc RICHIER (Jean-Luc.Richier@Imag.Fr  richier@imag.fr)
 Laboratoire Logiciels, Systemes et Reseaux (LSR-IMAG)
 IMAG-CAMPUS, BP 72, F-38402 St Martin d'Heres Cedex
 Tel : +33 4 76 82 72 32 Fax : +33 4 76 82 72 87
 
 
 
 --------------5BD50F45EB0B35D5F552C600
 Content-Type: text/plain; charset=us-ascii;
  name="inetd.c.DIFF"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="inetd.c.DIFF"
 
 --- inetd.c-1.107	Thu Aug  8 00:56:41 2002
 +++ inetd.c	Thu Aug 22 17:59:58 2002
 @@ -485,7 +485,7 @@
  		udpconf = getnetconfigent("udp");
  		tcpconf = getnetconfigent("tcp");
  		if (udpconf == NULL || tcpconf == NULL) {	
 -			syslog(LOG_ERR, "unknown rpc/udp or rpc/tpc");
 +			syslog(LOG_ERR, "unknown rpc/udp or rpc/tcp");
  			exit(EX_USAGE);
  		}
  	}
 @@ -494,7 +494,7 @@
  		udp6conf = getnetconfigent("udp6");
  		tcp6conf = getnetconfigent("tcp6");
  		if (udp6conf == NULL || tcp6conf == NULL) {	
 -			syslog(LOG_ERR, "unknown rpc/udp6 or rpc/tpc6");
 +			syslog(LOG_ERR, "unknown rpc/udp6 or rpc/tcp6");
  			exit(EX_USAGE);
  		}
  	}
 @@ -1584,13 +1584,17 @@
  #ifdef IPSEC
  	char *policy = NULL;
  #endif
 -	int v4bind = 0;
 +	int v4bind;
  #ifdef INET6
 -	int v6bind = 0;
 +	int v6bind;
  #endif
  	int i;
  
  more:
 +	v4bind = 0;
 +#ifdef INET6
 +	v6bind = 0;
 +#endif
  	while ((cp = nextline(fconfig)) != NULL) {
  #ifdef IPSEC
  		/* lines starting with #@ is not a comment, but the policy */
 @@ -1742,52 +1746,55 @@
                  }
          }
  	sep->se_nomapped = 0;
 -	while (isdigit(sep->se_proto[strlen(sep->se_proto) - 1])) {
 -#ifdef INET6
 -		if (sep->se_proto[strlen(sep->se_proto) - 1] == '6') {
 -			sep->se_proto[strlen(sep->se_proto) - 1] = '\0';
 -			v6bind = 1;
 -			continue;
 -		}
 -#endif
 -		if (sep->se_proto[strlen(sep->se_proto) - 1] == '4') {
 -			sep->se_proto[strlen(sep->se_proto) - 1] = '\0';
 -			v4bind = 1;
 -			continue;
 -		}
 -		/* illegal version num */
 -		syslog(LOG_ERR,	"bad IP version for %s", sep->se_proto);
 -		freeconfig(sep);
 -		goto more;
 -	}
  	if (strcmp(sep->se_proto, "unix") == 0) {
  	        sep->se_family = AF_UNIX;
 -	} else
 +	} else {
 +		while (isdigit(sep->se_proto[strlen(sep->se_proto) - 1])) {
  #ifdef INET6
 -	if (v6bind != 0 && no_v6bind != 0) {
 -		syslog(LOG_INFO, "IPv6 bind is ignored for %s",
 -		       sep->se_service);
 -		if (v4bind && no_v4bind == 0)
 -			v6bind = 0;
 -		else {
 +			if (sep->se_proto[strlen(sep->se_proto) - 1] == '6') {
 +				sep->se_proto[strlen(sep->se_proto) - 1] = '\0';
 +				v6bind = 1;
 +				continue;
 +			}
 +#endif
 +			if (sep->se_proto[strlen(sep->se_proto) - 1] == '4') {
 +				sep->se_proto[strlen(sep->se_proto) - 1] = '\0';
 +				v4bind = 1;
 +				continue;
 +			}
 +			/* illegal version num */
 +			syslog(LOG_ERR,	"bad IP version for %s", sep->se_proto);
  			freeconfig(sep);
  			goto more;
  		}
 -	}
 -	if (v6bind != 0) {
 -		sep->se_family = AF_INET6;
 -		if (v4bind == 0 || no_v4bind != 0)
 -			sep->se_nomapped = 1;
 -	} else
 -#endif
 -	{ /* default to v4 bind if not v6 bind */
 -		if (no_v4bind != 0) {
 -			syslog(LOG_NOTICE, "IPv4 bind is ignored for %s",
 -			       sep->se_service);
 -			freeconfig(sep);
 -			goto more;
 +#ifdef INET6
 +		if (v6bind != 0 && no_v6bind != 0) {
 +			if (v4bind && no_v4bind == 0)	/* 46: keep 4 */
 +				v6bind = 0;
 +			else {
 +				syslog(LOG_NOTICE,
 +				       "IPv6 bind is ignored for %s",
 +				       sep->se_service);
 +				freeconfig(sep);
 +				goto more;
 +			}
 +		}
 +		if (v6bind != 0) {
 +			sep->se_family = AF_INET6;
 +			if (v4bind == 0 || no_v4bind != 0)
 +				sep->se_nomapped = 1;
 +		} else
 +#endif
 +		{ /* default to v4 bind if not v6 bind */
 +			if (no_v4bind != 0) {
 +				syslog(LOG_NOTICE,
 +				       "IPv4 bind is ignored for %s",
 +				       sep->se_service);
 +				freeconfig(sep);
 +				goto more;
 +			}
 +			sep->se_family = AF_INET;
  		}
 -		sep->se_family = AF_INET;
  	}
  	/* init ctladdr */
  	switch(sep->se_family) {
 
 --------------5BD50F45EB0B35D5F552C600--
 

From: "Steven Ames" <steve@virtual-voodoo.com>
To: "Jean-Luc Richier" <Jean-Luc.Richier@imag.fr>,
	<freebsd-gnats-submit@FreeBSD.org>
Cc:  
Subject: Re: bin/40771: inetd.c 1.105 breaks inetd.conf parsing on non IPv6  systems
Date: Thu, 22 Aug 2002 14:04:17 -0500

 This patch fixes my problem. Thank you.
 
 ----- Original Message -----
 From: "Jean-Luc Richier" <Jean-Luc.Richier@imag.fr>
 To: <freebsd-gnats-submit@FreeBSD.org>; <steve@virtual-voodoo.com>
 Sent: Thursday, August 22, 2002 11:31 AM
 Subject: Re: bin/40771: inetd.c 1.105 breaks inetd.conf parsing on non IPv6
 systems
 
 
 > Sorry, I am the author of the bug, and I was in holidays. So I answer
 > only now.
 >
 > The proposed fix is too strong for on a IPv4 only machine it forbid
 > tcp46 entries.
 > The correction is much simpler : when ignoring a line and going back to
 > a label at  to the beginning to start back, it is better to initialize
 > variables AFTER the loopback label :-)
 > Also there are 3 other problems in my inetd patch
 > 2 are minor :  mispelling (tpc for tcp) and allowing unix4, unix6,
 > the third is more impotant : a statement breaking if/then/else sequence
 > and therfore all unix entries
 >
 > So here is the suggested solution.
 > It is long, but most is the inversion of the tests for unix and for 4/6
 > suffix,, which cause a lot of modifications in indentation
 >
 >
 > --
 > Jean-Luc RICHIER (Jean-Luc.Richier@Imag.Fr  richier@imag.fr)
 > Laboratoire Logiciels, Systemes et Reseaux (LSR-IMAG)
 > IMAG-CAMPUS, BP 72, F-38402 St Martin d'Heres Cedex
 > Tel : +33 4 76 82 72 32 Fax : +33 4 76 82 72 87
 >
 >
 >
 
 
 ----------------------------------------------------------------------------
 ----
 
 
 > --- inetd.c-1.107 Thu Aug  8 00:56:41 2002
 > +++ inetd.c Thu Aug 22 17:59:58 2002
 > @@ -485,7 +485,7 @@
 >   udpconf = getnetconfigent("udp");
 >   tcpconf = getnetconfigent("tcp");
 >   if (udpconf == NULL || tcpconf == NULL) {
 > - syslog(LOG_ERR, "unknown rpc/udp or rpc/tpc");
 > + syslog(LOG_ERR, "unknown rpc/udp or rpc/tcp");
 >   exit(EX_USAGE);
 >   }
 >   }
 > @@ -494,7 +494,7 @@
 >   udp6conf = getnetconfigent("udp6");
 >   tcp6conf = getnetconfigent("tcp6");
 >   if (udp6conf == NULL || tcp6conf == NULL) {
 > - syslog(LOG_ERR, "unknown rpc/udp6 or rpc/tpc6");
 > + syslog(LOG_ERR, "unknown rpc/udp6 or rpc/tcp6");
 >   exit(EX_USAGE);
 >   }
 >   }
 > @@ -1584,13 +1584,17 @@
 >  #ifdef IPSEC
 >   char *policy = NULL;
 >  #endif
 > - int v4bind = 0;
 > + int v4bind;
 >  #ifdef INET6
 > - int v6bind = 0;
 > + int v6bind;
 >  #endif
 >   int i;
 >
 >  more:
 > + v4bind = 0;
 > +#ifdef INET6
 > + v6bind = 0;
 > +#endif
 >   while ((cp = nextline(fconfig)) != NULL) {
 >  #ifdef IPSEC
 >   /* lines starting with #@ is not a comment, but the policy */
 > @@ -1742,52 +1746,55 @@
 >                  }
 >          }
 >   sep->se_nomapped = 0;
 > - while (isdigit(sep->se_proto[strlen(sep->se_proto) - 1])) {
 > -#ifdef INET6
 > - if (sep->se_proto[strlen(sep->se_proto) - 1] == '6') {
 > - sep->se_proto[strlen(sep->se_proto) - 1] = '\0';
 > - v6bind = 1;
 > - continue;
 > - }
 > -#endif
 > - if (sep->se_proto[strlen(sep->se_proto) - 1] == '4') {
 > - sep->se_proto[strlen(sep->se_proto) - 1] = '\0';
 > - v4bind = 1;
 > - continue;
 > - }
 > - /* illegal version num */
 > - syslog(LOG_ERR, "bad IP version for %s", sep->se_proto);
 > - freeconfig(sep);
 > - goto more;
 > - }
 >   if (strcmp(sep->se_proto, "unix") == 0) {
 >           sep->se_family = AF_UNIX;
 > - } else
 > + } else {
 > + while (isdigit(sep->se_proto[strlen(sep->se_proto) - 1])) {
 >  #ifdef INET6
 > - if (v6bind != 0 && no_v6bind != 0) {
 > - syslog(LOG_INFO, "IPv6 bind is ignored for %s",
 > -        sep->se_service);
 > - if (v4bind && no_v4bind == 0)
 > - v6bind = 0;
 > - else {
 > + if (sep->se_proto[strlen(sep->se_proto) - 1] == '6') {
 > + sep->se_proto[strlen(sep->se_proto) - 1] = '\0';
 > + v6bind = 1;
 > + continue;
 > + }
 > +#endif
 > + if (sep->se_proto[strlen(sep->se_proto) - 1] == '4') {
 > + sep->se_proto[strlen(sep->se_proto) - 1] = '\0';
 > + v4bind = 1;
 > + continue;
 > + }
 > + /* illegal version num */
 > + syslog(LOG_ERR, "bad IP version for %s", sep->se_proto);
 >   freeconfig(sep);
 >   goto more;
 >   }
 > - }
 > - if (v6bind != 0) {
 > - sep->se_family = AF_INET6;
 > - if (v4bind == 0 || no_v4bind != 0)
 > - sep->se_nomapped = 1;
 > - } else
 > -#endif
 > - { /* default to v4 bind if not v6 bind */
 > - if (no_v4bind != 0) {
 > - syslog(LOG_NOTICE, "IPv4 bind is ignored for %s",
 > -        sep->se_service);
 > - freeconfig(sep);
 > - goto more;
 > +#ifdef INET6
 > + if (v6bind != 0 && no_v6bind != 0) {
 > + if (v4bind && no_v4bind == 0) /* 46: keep 4 */
 > + v6bind = 0;
 > + else {
 > + syslog(LOG_NOTICE,
 > +        "IPv6 bind is ignored for %s",
 > +        sep->se_service);
 > + freeconfig(sep);
 > + goto more;
 > + }
 > + }
 > + if (v6bind != 0) {
 > + sep->se_family = AF_INET6;
 > + if (v4bind == 0 || no_v4bind != 0)
 > + sep->se_nomapped = 1;
 > + } else
 > +#endif
 > + { /* default to v4 bind if not v6 bind */
 > + if (no_v4bind != 0) {
 > + syslog(LOG_NOTICE,
 > +        "IPv4 bind is ignored for %s",
 > +        sep->se_service);
 > + freeconfig(sep);
 > + goto more;
 > + }
 > + sep->se_family = AF_INET;
 >   }
 > - sep->se_family = AF_INET;
 >   }
 >   /* init ctladdr */
 >   switch(sep->se_family) {
 >
 
State-Changed-From-To: open->closed 
State-Changed-By: dwmalone 
State-Changed-When: Thu Sep 5 10:27:50 PDT 2002 
State-Changed-Why:  
Issues now addressed in -current - they don't apply to stable. 

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