Explain "-c" option more exactly and state the default in the man

page.

Add ability to run "inetd -R 0" to disable the default connection
per minute limit of 256 connections. Document this in man page.

Don't use maxchild as a boolean - instead check if it is greater
than zero.

Reviewed by:	sheldonh
Based on a patch by:	Alexander Langer <alex@big.endian.de>
This commit is contained in:
dwmalone 2000-08-03 15:45:38 +00:00
parent 66d22fe285
commit f36f8d5bae
2 changed files with 13 additions and 8 deletions

View File

@ -89,7 +89,9 @@ section for more information on TCP Wrappers support.
Turn on TCP Wrapping for internal services which are built in to Turn on TCP Wrapping for internal services which are built in to
.Nm inetd . .Nm inetd .
.It Fl c Ar maximum .It Fl c Ar maximum
Specify the default maximum number of services that can be invoked. Specify the default maximum number of
simultaneous invocations of each service;
the default is unlimited.
May be overridden on a per-service basis with the "max-child" May be overridden on a per-service basis with the "max-child"
parameter. parameter.
.It Fl C Ar rate .It Fl C Ar rate
@ -100,6 +102,7 @@ May be overridden on a per-service basis with the
.It Fl R Ar rate .It Fl R Ar rate
Specify the maximum number of times a service can be invoked Specify the maximum number of times a service can be invoked
in one minute; the default is 256. in one minute; the default is 256.
A rate of 0 allows an unlimited number of invocations.
.It Fl a .It Fl a
Specify a specific IP address to bind to. Specify a specific IP address to bind to.
Alternatively, a hostname can be specified, Alternatively, a hostname can be specified,

View File

@ -191,7 +191,9 @@ static const char rcsid[] =
< 0 = no limit */ < 0 = no limit */
#endif #endif
#ifndef TOOMANY
#define TOOMANY 256 /* don't start more than TOOMANY */ #define TOOMANY 256 /* don't start more than TOOMANY */
#endif
#define CNT_INTVL 60 /* servers in CNT_INTVL sec. */ #define CNT_INTVL 60 /* servers in CNT_INTVL sec. */
#define RETRYTIME (60*10) /* retry after bind or server fail */ #define RETRYTIME (60*10) /* retry after bind or server fail */
#define MAX_MAXCHLD 32767 /* max allowable max children */ #define MAX_MAXCHLD 32767 /* max allowable max children */
@ -247,7 +249,7 @@ getvalue(arg, value, whine)
char *p; char *p;
tmp = strtol(arg, &p, 0); tmp = strtol(arg, &p, 0);
if (tmp < 1 || *p) { if (tmp < 0 || *p) {
syslog(LOG_ERR, whine, arg); syslog(LOG_ERR, whine, arg);
return 1; /* failure */ return 1; /* failure */
} }
@ -590,7 +592,7 @@ main(argc, argv, envp)
if (dofork) { if (dofork) {
if (sep->se_count++ == 0) if (sep->se_count++ == 0)
(void)gettimeofday(&sep->se_time, (struct timezone *)NULL); (void)gettimeofday(&sep->se_time, (struct timezone *)NULL);
else if (sep->se_count >= toomany) { else if (toomany > 0 && sep->se_count >= toomany) {
struct timeval now; struct timeval now;
(void)gettimeofday(&now, (struct timezone *)NULL); (void)gettimeofday(&now, (struct timezone *)NULL);
@ -795,6 +797,8 @@ void flag_signal(c)
void void
addchild(struct servtab *sep, pid_t pid) addchild(struct servtab *sep, pid_t pid)
{ {
if (sep->se_maxchild <= 0)
return;
#ifdef SANITY_CHECK #ifdef SANITY_CHECK
if (sep->se_numchild >= sep->se_maxchild) { if (sep->se_numchild >= sep->se_maxchild) {
syslog(LOG_ERR, "%s: %d >= %d", syslog(LOG_ERR, "%s: %d >= %d",
@ -802,8 +806,6 @@ addchild(struct servtab *sep, pid_t pid)
exit(EX_SOFTWARE); exit(EX_SOFTWARE);
} }
#endif #endif
if (sep->se_maxchild == 0)
return;
sep->se_pids[sep->se_numchild++] = pid; sep->se_pids[sep->se_numchild++] = pid;
if (sep->se_numchild == sep->se_maxchild) if (sep->se_numchild == sep->se_maxchild)
disable(sep); disable(sep);
@ -906,7 +908,7 @@ void config()
sep->se_reset = 1; sep->se_reset = 1;
} }
/* copy over outstanding child pids */ /* copy over outstanding child pids */
if (sep->se_maxchild && new->se_maxchild) { if (sep->se_maxchild > 0 && new->se_maxchild > 0) {
new->se_numchild = sep->se_numchild; new->se_numchild = sep->se_numchild;
if (new->se_numchild > new->se_maxchild) if (new->se_numchild > new->se_maxchild)
new->se_numchild = new->se_maxchild; new->se_numchild = new->se_maxchild;
@ -919,7 +921,7 @@ void config()
sep->se_maxcpm = new->se_maxcpm; sep->se_maxcpm = new->se_maxcpm;
/* might need to turn on or off service now */ /* might need to turn on or off service now */
if (sep->se_fd >= 0) { if (sep->se_fd >= 0) {
if (sep->se_maxchild if (sep->se_maxchild > 0
&& sep->se_numchild == sep->se_maxchild) { && sep->se_numchild == sep->se_maxchild) {
if (FD_ISSET(sep->se_fd, &allsock)) if (FD_ISSET(sep->se_fd, &allsock))
disable(sep); disable(sep);
@ -1718,7 +1720,7 @@ more:
else else
sep->se_maxchild = 1; sep->se_maxchild = 1;
} }
if (sep->se_maxchild) { if (sep->se_maxchild > 0) {
sep->se_pids = malloc(sep->se_maxchild * sizeof(*sep->se_pids)); sep->se_pids = malloc(sep->se_maxchild * sizeof(*sep->se_pids));
if (sep->se_pids == NULL) { if (sep->se_pids == NULL) {
syslog(LOG_ERR, "malloc: %m"); syslog(LOG_ERR, "malloc: %m");