inetd looping detection too short & dummy environ set wrong

Andrew Partan asp at uunet.UU.NET
Sat Dec 9 05:13:56 AEST 1989


Subject: inetd looping detection too short & dummy environ set wrong
Index:	etc/inetd/inetd.c

Description:
	1) inetd has some loop detection code to see if some service is
	being invoked 'too often', and, if so, stops servicing requests
	for the service for a while.  It detects a loop by keeping
	track of the number of servers it starts for each service.  It
	does not start more than TOOMANY (40) servers in CNTY_INTVL
	(60) seconds.  If it detects a loop, it logs "server failing
	(looping), service terminated".  The problem is that machines
	are now fast enough that you may want to run more than 40
	servers a minute (we did, anyhow).

	2) inetd sets a dummy environment variable 'inetd_dummy' so
	that daemons have some space to overwrite their environment for
	ps.  It tries to initialiaze this variable to all x's, but
	calculates the length of the variable wrong, so that only the
	1st few bytes get set to x's.

Repeat-By:
	1) Try to run more than 40 services a second (like "rsh
	compress" of news batches to a fast machine).

	2) Inspection of the source.

Fix:
	1) Increase the loop count from 40 to 400 (should hold us for a
	while - really need better loop detection code here).

	2) Use the proper size of the dummy environment variable when
	initializing it.

*** inetd.c.ORIG	Fri Jan 27 12:33:18 1989
--- inetd.c	Fri Dec  8 13:00:20 1989
***************
*** 79,87 ****
  #include <pwd.h>
  #include <stdio.h>
  #include <strings.h>
  
! #define	TOOMANY		40		/* don't start more than TOOMANY */
  #define	CNT_INTVL	60		/* servers in CNT_INTVL sec. */
  #define	RETRYTIME	(60*10)		/* retry after bind or server fail */
  
  #define	SIGBLOCK	(sigmask(SIGCHLD)|sigmask(SIGHUP)|sigmask(SIGALRM))
--- 79,87 ----
  #include <pwd.h>
  #include <stdio.h>
  #include <strings.h>
  
! #define	TOOMANY		400		/* don't start more than TOOMANY */
  #define	CNT_INTVL	60		/* servers in CNT_INTVL sec. */
  #define	RETRYTIME	(60*10)		/* retry after bind or server fail */
  
  #define	SIGBLOCK	(sigmask(SIGCHLD)|sigmask(SIGHUP)|sigmask(SIGALRM))
***************
*** 224,232 ****
  		/* space for daemons to overwrite environment for ps */
  #define	DUMMYSIZE	100
  		char dummy[DUMMYSIZE];
  
! 		(void)memset(dummy, 'x', sizeof(DUMMYSIZE) - 1);
  		dummy[DUMMYSIZE - 1] = '\0';
  		(void)setenv("inetd_dummy", dummy, 1);
  	}
  
--- 224,232 ----
  		/* space for daemons to overwrite environment for ps */
  #define	DUMMYSIZE	100
  		char dummy[DUMMYSIZE];
  
! 		(void)memset(dummy, 'x', DUMMYSIZE - 1);
  		dummy[DUMMYSIZE - 1] = '\0';
  		(void)setenv("inetd_dummy", dummy, 1);
  	}
  

	--asp at uunet.uu.net (Andrew Partan)
	ASN.1 Object Identifier: "{joint-iso-ccitt mhs(6) group(6) 157}"



More information about the Comp.bugs.4bsd.ucb-fixes mailing list