/*      $Slackware: inetd.c 1.79s 2001/02/06 13:18:00 volkerdi Exp $    */
/*      $OpenBSD: inetd.c,v 1.79 2001/01/30 08:30:57 deraadt Exp $      */
/*      $NetBSD: inetd.c,v 1.11 1996/02/22 11:14:41 mycroft Exp $       */
/* Busybox port by Vladimir Oleynik (C) 2001-2005 <dzo@simtreas.ru>     */
/*
 * Copyright (c) 1983,1991 The Regents of the University of California.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *      This product includes software developed by the University of
 *      California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

/*
 * Inetd - Internet super-server
 *
 * This program invokes all internet services as needed.
 * connection-oriented services are invoked each time a
 * connection is made, by creating a process.  This process
 * is passed the connection as file descriptor 0 and is
 * expected to do a getpeername to find out the source host
 * and port.
 *
 * Datagram oriented services are invoked when a datagram
 * arrives; a process is created and passed a pending message
 * on file descriptor 0.  Datagram servers may either connect
 * to their peer, freeing up the original socket for inetd
 * to receive further messages on, or ``take over the socket'',
 * processing all arriving datagrams and, eventually, timing
 * out.  The first type of server is said to be ``multi-threaded'';
 * the second type of server ``single-threaded''.
 *
 * Inetd uses a configuration file which is read at startup
 * and, possibly, at some later time in response to a hangup signal.
 * The configuration file is ``free format'' with fields given in the
 * order shown below.  Continuation lines for an entry must begin with
 * a space or tab.  All fields must be present in each entry.
 *
 *      service name                    must be in /etc/services
 *      socket type                     stream/dgram/raw/rdm/seqpacket
 *      protocol                        must be in /etc/protocols
 *      wait/nowait[.max]               single-threaded/multi-threaded, max #
 *      user[.group] or user[:group]    user/group to run daemon as
 *      server program                  full path name
 *      server program arguments        maximum of MAXARGS (20)
 *
 * For RPC services
 *      service name/version            must be in /etc/rpc
 *      socket type                     stream/dgram/raw/rdm/seqpacket
 *      protocol                        must be in /etc/protocols
 *      wait/nowait[.max]               single-threaded/multi-threaded
 *      user[.group] or user[:group]    user to run daemon as
 *      server program                  full path name
 *      server program arguments        maximum of MAXARGS (20)
 *
 * For non-RPC services, the "service name" can be of the form
 * hostaddress:servicename, in which case the hostaddress is used
 * as the host portion of the address to listen on.  If hostaddress
 * consists of a single `*' character, INADDR_ANY is used.
 *
 * A line can also consist of just
 *      hostaddress:
 * where hostaddress is as in the preceding paragraph.  Such a line must
 * have no further fields; the specified hostaddress is remembered and
 * used for all further lines that have no hostaddress specified,
 * until the next such line (or EOF).  (This is why * is provided to
 * allow explicit specification of INADDR_ANY.)  A line
 *      *:
 * is implicitly in effect at the beginning of the file.
 *
 * The hostaddress specifier may (and often will) contain dots;
 * the service name must not.
 *
 * For RPC services, host-address specifiers are accepted and will
 * work to some extent; however, because of limitations in the
 * portmapper interface, it will not work to try to give more than
 * one line for any given RPC service, even if the host-address
 * specifiers are different.
 *
 * Comment lines are indicated by a `#' in column 1.
 */

/*
 * Here's the scoop concerning the user[.:]group feature:
 *
 * 1) set-group-option off.
 *
 *      a) user = root: NO setuid() or setgid() is done
 *
 *      b) other:       setgid(primary group as found in passwd)
 *                      initgroups(name, primary group)
 *                      setuid()
 *
 * 2) set-group-option on.
 *
 *      a) user = root: setgid(specified group)
 *                      NO initgroups()
 *                      NO setuid()
 *
 *      b) other:       setgid(specified group)
 *                      initgroups(name, specified group)
 *                      setuid()
 *
 */

#include <sys/param.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/file.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>


#include <netinet/in.h>
#include <arpa/inet.h>

#include <errno.h>
#include <signal.h>
#include <netdb.h>
#include <syslog.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <time.h>

#include "busybox.h"

//#define CONFIG_FEATURE_INETD_RPC
//#define CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO
//#define CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DISCARD
//#define CONFIG_FEATURE_INETD_SUPPORT_BILTIN_TIME
//#define CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DAYTIME
//#define CONFIG_FEATURE_INETD_SUPPORT_BILTIN_CHARGEN
//#define CONFIG_FEATURE_IPV6

#ifdef CONFIG_FEATURE_INETD_RPC
#include <rpc/rpc.h>
#include <rpc/pmap_clnt.h>
#endif

#define _PATH_INETDCONF "/etc/inetd.conf"
#define _PATH_INETDPID  "/var/run/inetd.pid"


#define TOOMANY         0               /* 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 */

#ifndef RLIMIT_NOFILE
#define RLIMIT_NOFILE   RLIMIT_OFILE
#endif

#ifndef OPEN_MAX
#define OPEN_MAX        64
#endif

/* Reserve some descriptors, 3 stdio + at least: 1 log, 1 conf. file */
#define FD_MARGIN       (8)
static rlim_t rlim_ofile_cur = OPEN_MAX;
static struct rlimit rlim_ofile;


/* Check unsupporting builtin */
#if defined CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO || \
	defined CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DISCARD || \
	defined CONFIG_FEATURE_INETD_SUPPORT_BILTIN_TIME || \
	defined CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DAYTIME || \
	defined CONFIG_FEATURE_INETD_SUPPORT_BILTIN_CHARGEN
# define INETD_FEATURE_ENABLED
#endif

#if defined CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO || \
	defined CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DISCARD || \
	defined CONFIG_FEATURE_INETD_SUPPORT_BILTIN_CHARGEN
# define INETD_SETPROCTITLE
#endif

typedef struct servtab
{
  char *se_hostaddr;                    /* host address to listen on */
  char *se_service;                     /* name of service */
  int se_socktype;                      /* type of socket to use */
  int se_family;                        /* address family */
  char *se_proto;                       /* protocol used */
#ifdef CONFIG_FEATURE_INETD_RPC
  int se_rpcprog;                       /* rpc program number */
  int se_rpcversl;                      /* rpc program lowest version */
  int se_rpcversh;                      /* rpc program highest version */
#define isrpcservice(sep)       ((sep)->se_rpcversl != 0)
#else
#define isrpcservice(sep)       0
#endif
  pid_t se_wait;                        /* single threaded server */
  short se_checked;                     /* looked at during merge */
  char *se_user;                        /* user name to run as */
  char *se_group;                       /* group name to run as */
#ifdef INETD_FEATURE_ENABLED
  const struct biltin *se_bi;                 /* if built-in, description */
#endif
  char *se_server;                      /* server program */
#define MAXARGV 20
  char *se_argv[MAXARGV + 1];           /* program arguments */
  int se_fd;                            /* open descriptor */
  union
  {
	struct sockaddr se_un_ctrladdr;
	struct sockaddr_in se_un_ctrladdr_in;
#ifdef CONFIG_FEATURE_IPV6
	struct sockaddr_in6 se_un_ctrladdr_in6;
#endif
	struct sockaddr_un se_un_ctrladdr_un;
  } se_un;                              /* bound address */
#define se_ctrladdr     se_un.se_un_ctrladdr
#define se_ctrladdr_in  se_un.se_un_ctrladdr_in
#define se_ctrladdr_in6 se_un.se_un_ctrladdr_in6
#define se_ctrladdr_un  se_un.se_un_ctrladdr_un
  int se_ctrladdr_size;
  int se_max;                           /* max # of instances of this service */
  int se_count;                         /* number started since se_time */
  struct timeval se_time;               /* start of se_count */
  struct servtab *se_next;
} servtab_t;

static servtab_t *servtab;

#ifdef INETD_FEATURE_ENABLED
struct biltin
{
  const char *bi_service;               /* internally provided service name */
  int bi_socktype;                      /* type of socket supported */
  short bi_fork;                        /* 1 if should fork before call */
  short bi_wait;                        /* 1 if should wait for child */
  void (*bi_fn) (int, servtab_t *);
};

	/* Echo received data */
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO
static void echo_stream (int, servtab_t *);
static void echo_dg (int, servtab_t *);
#endif
	/* Internet /dev/null */
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DISCARD
static void discard_stream (int, servtab_t *);
static void discard_dg (int, servtab_t *);
#endif
	/* Return 32 bit time since 1900 */
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_TIME
static void machtime_stream (int, servtab_t *);
static void machtime_dg (int, servtab_t *);
#endif
	/* Return human-readable time */
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DAYTIME
static void daytime_stream (int, servtab_t *);
static void daytime_dg (int, servtab_t *);
#endif
	/* Familiar character generator */
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_CHARGEN
static void chargen_stream (int, servtab_t *);
static void chargen_dg (int, servtab_t *);
#endif

static const struct biltin biltins[] = {
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO
  /* Echo received data */
  {"echo", SOCK_STREAM, 1, 0, echo_stream,},
  {"echo", SOCK_DGRAM, 0, 0, echo_dg,},
#endif
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DISCARD
  /* Internet /dev/null */
  {"discard", SOCK_STREAM, 1, 0, discard_stream,},
  {"discard", SOCK_DGRAM, 0, 0, discard_dg,},
#endif
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_TIME
  /* Return 32 bit time since 1900 */
  {"time", SOCK_STREAM, 0, 0, machtime_stream,},
  {"time", SOCK_DGRAM, 0, 0, machtime_dg,},
#endif
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DAYTIME
  /* Return human-readable time */
  {"daytime", SOCK_STREAM, 0, 0, daytime_stream,},
  {"daytime", SOCK_DGRAM, 0, 0, daytime_dg,},
#endif
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_CHARGEN
  /* Familiar character generator */
  {"chargen", SOCK_STREAM, 1, 0, chargen_stream,},
  {"chargen", SOCK_DGRAM, 0, 0, chargen_dg,},
#endif
  {NULL, 0, 0, 0, NULL}
};
#endif /* INETD_FEATURE_ENABLED */

static int global_queuelen = 128;
static int nsock, maxsock;
static fd_set allsock;
static int toomany = TOOMANY;
static int timingout;
static struct servent *sp;
static uid_t uid;

static char *CONFIG = _PATH_INETDCONF;

static FILE *fconfig;
static char line[1024];
static char *defhost;

static char *newstr (char *cp)
{
  if ((cp = strdup (cp ? cp : "")))
	return (cp);
  syslog (LOG_ERR, "strdup: %m");
  exit (1);
}

static int setconfig (void)
{
  free (defhost);
  defhost = newstr ("*");
  if (fconfig != NULL) {
	fseek (fconfig, 0L, SEEK_SET);
	return (1);
  }
  fconfig = fopen (CONFIG, "r");
  return (fconfig != NULL);
}

static void endconfig (void)
{
  if (fconfig) {
	(void) fclose (fconfig);
	fconfig = NULL;
  }
  free (defhost);
  defhost = 0;
}

#ifdef CONFIG_FEATURE_INETD_RPC
static void register_rpc (servtab_t *sep)
{
  int n;
  struct sockaddr_in ir_sin;
  struct protoent *pp;
  socklen_t size;

  if ((pp = getprotobyname (sep->se_proto + 4)) == NULL) {
	syslog (LOG_ERR, "%s: getproto: %m", sep->se_proto);
	return;
  }
  size = sizeof ir_sin;
  if (getsockname (sep->se_fd, (struct sockaddr *) &ir_sin, &size) < 0) {
	syslog (LOG_ERR, "%s/%s: getsockname: %m",
			sep->se_service, sep->se_proto);
	return;
  }

  for (n = sep->se_rpcversl; n <= sep->se_rpcversh; n++) {
	(void) pmap_unset (sep->se_rpcprog, n);
	if (!pmap_set (sep->se_rpcprog, n, pp->p_proto, ntohs (ir_sin.sin_port)))
	  syslog (LOG_ERR, "%s %s: pmap_set: %u %u %u %u: %m",
			  sep->se_service, sep->se_proto,
			  sep->se_rpcprog, n, pp->p_proto, ntohs (ir_sin.sin_port));
  }
}

static void unregister_rpc (servtab_t *sep)
{
  int n;

  for (n = sep->se_rpcversl; n <= sep->se_rpcversh; n++) {
	if (!pmap_unset (sep->se_rpcprog, n))
	  syslog (LOG_ERR, "pmap_unset(%u, %u)", sep->se_rpcprog, n);
  }
}
#endif /* CONFIG_FEATURE_INETD_RPC */

static void freeconfig (servtab_t *cp)
{
  int i;

  free (cp->se_hostaddr);
  free (cp->se_service);
  free (cp->se_proto);
  free (cp->se_user);
  free (cp->se_group);
  free (cp->se_server);
  for (i = 0; i < MAXARGV; i++)
	if (cp->se_argv[i])
	  free (cp->se_argv[i]);
}

static int bump_nofile (void)
{
#define FD_CHUNK        32

  struct rlimit rl;

  if (getrlimit (RLIMIT_NOFILE, &rl) < 0) {
	syslog (LOG_ERR, "getrlimit: %m");
	return -1;
  }
  rl.rlim_cur = MIN (rl.rlim_max, rl.rlim_cur + FD_CHUNK);
  rl.rlim_cur = MIN (FD_SETSIZE, rl.rlim_cur + FD_CHUNK);
  if (rl.rlim_cur <= rlim_ofile_cur) {
	syslog (LOG_ERR, "bump_nofile: cannot extend file limit, max = %d",
			(int) rl.rlim_cur);
	return -1;
  }

  if (setrlimit (RLIMIT_NOFILE, &rl) < 0) {
	syslog (LOG_ERR, "setrlimit: %m");
	return -1;
  }

  rlim_ofile_cur = rl.rlim_cur;
  return 0;
}

static void setup (servtab_t *sep)
{
  int on = 1;
  int r;

  if ((sep->se_fd = socket (sep->se_family, sep->se_socktype, 0)) < 0) {
	syslog (LOG_ERR, "%s/%s: socket: %m", sep->se_service, sep->se_proto);
	return;
  }
#define turnon(fd, opt) \
setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (on))
  if (turnon (sep->se_fd, SO_REUSEADDR) < 0)
	syslog (LOG_ERR, "setsockopt (SO_REUSEADDR): %m");
#undef turnon

#ifdef CONFIG_FEATURE_INETD_RPC
  if (isrpcservice (sep)) {
	struct passwd *pwd;

	/*
	 * for RPC services, attempt to use a reserved port
	 * if they are going to be running as root.
	 *
	 * Also, zero out the port for all RPC services; let bind()
	 * find one.
	 */
	sep->se_ctrladdr_in.sin_port = 0;
	if (sep->se_user && (pwd = getpwnam (sep->se_user)) &&
		pwd->pw_uid == 0 && uid == 0)
	  r = bindresvport (sep->se_fd, &sep->se_ctrladdr_in);
	else {
	  r = bind (sep->se_fd, &sep->se_ctrladdr, sep->se_ctrladdr_size);
	  if (r == 0) {
		socklen_t len = sep->se_ctrladdr_size;
		int saveerrno = errno;

		/* update se_ctrladdr_in.sin_port */
		r = getsockname (sep->se_fd, &sep->se_ctrladdr, &len);
		if (r <= 0)
		  errno = saveerrno;
	  }
	}
  } else
#endif
	r = bind (sep->se_fd, &sep->se_ctrladdr, sep->se_ctrladdr_size);
  if (r < 0) {
	syslog (LOG_ERR, "%s/%s (%d): bind: %m",
			sep->se_service, sep->se_proto, sep->se_ctrladdr.sa_family);
	close (sep->se_fd);
	sep->se_fd = -1;
	if (!timingout) {
	  timingout = 1;
	  alarm (RETRYTIME);
	}
	return;
  }
  if (sep->se_socktype == SOCK_STREAM)
	listen (sep->se_fd, global_queuelen);

  FD_SET (sep->se_fd, &allsock);
  nsock++;
  if (sep->se_fd > maxsock) {
	maxsock = sep->se_fd;
	if ((rlim_t)maxsock > rlim_ofile_cur - FD_MARGIN)
	  bump_nofile ();
  }
}

static char *nextline (void)
{
  char *cp;
  FILE *fd = fconfig;

  if (fgets (line, sizeof (line), fd) == NULL)
	return (NULL);
  cp = strchr (line, '\n');
  if (cp)
	*cp = '\0';
  return (line);
}

static char *skip (char **cpp) /* int report; */
{
  char *cp = *cpp;
  char *start;

/* erp: */
  if (*cpp == NULL) {
	/* if (report) */
	/* syslog(LOG_ERR, "syntax error in inetd config file"); */
	return (NULL);
  }

again:
  while (*cp == ' ' || *cp == '\t')
	cp++;
  if (*cp == '\0') {
	int c;

	c = getc (fconfig);
	(void) ungetc (c, fconfig);
	if (c == ' ' || c == '\t')
	  if ((cp = nextline ()))
		goto again;
	*cpp = NULL;
	/* goto erp; */
	return (NULL);
  }
  start = cp;
  while (*cp && *cp != ' ' && *cp != '\t')
	cp++;
  if (*cp != '\0')
	*cp++ = '\0';
  /* if ((*cpp = cp) == NULL) */
  /* goto erp; */

  *cpp = cp;
  return (start);
}

static servtab_t *new_servtab(void)
{
  servtab_t *sep;

  sep = (servtab_t *) malloc (sizeof (servtab_t));
  if (sep == NULL) {
	syslog (LOG_ERR, bb_msg_memory_exhausted);
	exit (1);
  }
  return sep;
}

static servtab_t *dupconfig (servtab_t *sep)
{
  servtab_t *newtab;
  int argc;

  newtab = new_servtab();
  memset (newtab, 0, sizeof (servtab_t));
  newtab->se_service = sep->se_service ? newstr (sep->se_service) : NULL;
  newtab->se_socktype = sep->se_socktype;
  newtab->se_family = sep->se_family;
  newtab->se_proto = sep->se_proto ? newstr (sep->se_proto) : NULL;
#ifdef CONFIG_FEATURE_INETD_RPC
  newtab->se_rpcprog = sep->se_rpcprog;
  newtab->se_rpcversl = sep->se_rpcversl;
  newtab->se_rpcversh = sep->se_rpcversh;
#endif
  newtab->se_wait = sep->se_wait;
  newtab->se_user = sep->se_user ? newstr (sep->se_user) : NULL;
  newtab->se_group = sep->se_group ? newstr (sep->se_group) : NULL;
#ifdef INETD_FEATURE_ENABLED
  newtab->se_bi = sep->se_bi;
#endif
  newtab->se_server = sep->se_server ? newstr (sep->se_server) : 0;

  for (argc = 0; argc <= MAXARGV; argc++)
	newtab->se_argv[argc] = sep->se_argv[argc] ?
	  newstr (sep->se_argv[argc]) : NULL;
  newtab->se_max = sep->se_max;

  return (newtab);
}

static servtab_t *getconfigent (void)
{
  servtab_t *sep;
  int argc;
  char *cp, *arg;
  char *hostdelim;
  servtab_t *nsep;
  servtab_t *psep;

  sep = new_servtab();

  /* memset(sep, 0, sizeof *sep); */
more:
  /* freeconfig(sep); */

  while ((cp = nextline ()) && *cp == '#');
  if (cp == NULL) {
	/* free(sep); */
	return (NULL);
  }

  memset ((char *) sep, 0, sizeof *sep);
  arg = skip (&cp);
  if (arg == NULL) {
	/* A blank line. */
	goto more;
  }

  /* Check for a host name. */
  hostdelim = strrchr (arg, ':');
  if (hostdelim) {
	*hostdelim = '\0';
	sep->se_hostaddr = newstr (arg);
	arg = hostdelim + 1;
	/*
	 * If the line is of the form `host:', then just change the
	 * default host for the following lines.
	 */
	if (*arg == '\0') {
	  arg = skip (&cp);
	  if (cp == NULL) {
		free (defhost);
		defhost = sep->se_hostaddr;
		goto more;
	  }
	}
  } else
	sep->se_hostaddr = newstr (defhost);

  sep->se_service = newstr (arg);
  arg = skip (&cp);

  if (strcmp (arg, "stream") == 0)
	sep->se_socktype = SOCK_STREAM;
  else if (strcmp (arg, "dgram") == 0)
	sep->se_socktype = SOCK_DGRAM;
  else if (strcmp (arg, "rdm") == 0)
	sep->se_socktype = SOCK_RDM;
  else if (strcmp (arg, "seqpacket") == 0)
	sep->se_socktype = SOCK_SEQPACKET;
  else if (strcmp (arg, "raw") == 0)
	sep->se_socktype = SOCK_RAW;
  else
	sep->se_socktype = -1;

  sep->se_proto = newstr (skip (&cp));

  if (strcmp (sep->se_proto, "unix") == 0) {
	sep->se_family = AF_UNIX;
  } else {
	sep->se_family = AF_INET;
	if (sep->se_proto[strlen (sep->se_proto) - 1] == '6')
#ifdef CONFIG_FEATURE_IPV6
	  sep->se_family = AF_INET6;
#else
	  syslog (LOG_ERR, "%s: IPV6 not supported", sep->se_proto);
#endif
	if (strncmp (sep->se_proto, "rpc/", 4) == 0) {
#ifdef CONFIG_FEATURE_INETD_RPC
	  char *p, *ccp;
	  long l;

	  p = strchr (sep->se_service, '/');
	  if (p == 0) {
		syslog (LOG_ERR, "%s: no rpc version", sep->se_service);
		goto more;
	  }
	  *p++ = '\0';
	  l = strtol (p, &ccp, 0);
	  if (ccp == p || l < 0 || l > INT_MAX) {
	  badafterall:
		syslog (LOG_ERR, "%s/%s: bad rpc version", sep->se_service, p);
		goto more;
	  }
	  sep->se_rpcversl = sep->se_rpcversh = l;
	  if (*ccp == '-') {
		p = ccp + 1;
		l = strtol (p, &ccp, 0);
		if (ccp == p || l < 0 || l > INT_MAX || l < sep->se_rpcversl || *ccp)
		  goto badafterall;
		sep->se_rpcversh = l;
	  } else if (*ccp != '\0')
		goto badafterall;
#else
	syslog (LOG_ERR, "%s: rpc services not supported", sep->se_service);
#endif
	}
  }
  arg = skip (&cp);
  if (arg == NULL)
	goto more;

  {
	char *s = strchr (arg, '.');
	if (s) {
	  *s++ = '\0';
	  sep->se_max = atoi (s);
	} else
	  sep->se_max = toomany;
  }
  sep->se_wait = strcmp (arg, "wait") == 0;
  /* if ((arg = skip(&cp, 1)) == NULL) */
  /* goto more; */
  sep->se_user = newstr (skip (&cp));
  arg = strchr (sep->se_user, '.');
  if (arg == NULL)
	arg = strchr (sep->se_user, ':');
  if (arg) {
	*arg++ = '\0';
	sep->se_group = newstr (arg);
  }
  /* if ((arg = skip(&cp, 1)) == NULL) */
  /* goto more; */

  sep->se_server = newstr (skip (&cp));
  if (strcmp (sep->se_server, "internal") == 0) {
#ifdef INETD_FEATURE_ENABLED
	const struct biltin *bi;

	for (bi = biltins; bi->bi_service; bi++)
	  if (bi->bi_socktype == sep->se_socktype &&
		  strcmp (bi->bi_service, sep->se_service) == 0)
		break;
	if (bi->bi_service == 0) {
	  syslog (LOG_ERR, "internal service %s unknown", sep->se_service);
	  goto more;
	}
	sep->se_bi = bi;
	sep->se_wait = bi->bi_wait;
#else
	syslog (LOG_ERR, "internal service %s unknown", sep->se_service);
	goto more;
#endif
  }
#ifdef INETD_FEATURE_ENABLED
    else
	sep->se_bi = NULL;
#endif
  argc = 0;
  for (arg = skip (&cp); cp; arg = skip (&cp)) {
	if (argc < MAXARGV)
	  sep->se_argv[argc++] = newstr (arg);
  }
  while (argc <= MAXARGV)
	sep->se_argv[argc++] = NULL;

  /*
   * Now that we've processed the entire line, check if the hostname
   * specifier was a comma separated list of hostnames. If so
   * we'll make new entries for each address.
   */
  while ((hostdelim = strrchr (sep->se_hostaddr, ',')) != NULL) {
	nsep = dupconfig (sep);

	/*
	 * NULL terminate the hostname field of the existing entry,
	 * and make a dup for the new entry.
	 */
	*hostdelim++ = '\0';
	nsep->se_hostaddr = newstr (hostdelim);

	nsep->se_next = sep->se_next;
	sep->se_next = nsep;
  }

  nsep = sep;
  while (nsep != NULL) {
	nsep->se_checked = 1;
	if (nsep->se_family == AF_INET) {
	  if (!strcmp (nsep->se_hostaddr, "*"))
		nsep->se_ctrladdr_in.sin_addr.s_addr = INADDR_ANY;
	  else if (!inet_aton (nsep->se_hostaddr, &nsep->se_ctrladdr_in.sin_addr)) {
		struct hostent *hp;

		hp = gethostbyname (nsep->se_hostaddr);
		if (hp == 0) {
		  syslog (LOG_ERR, "%s: unknown host", nsep->se_hostaddr);
		  nsep->se_checked = 0;
		  goto skip;
		} else if (hp->h_addrtype != AF_INET) {
		  syslog (LOG_ERR,
				  "%s: address isn't an Internet "
				  "address", nsep->se_hostaddr);
		  nsep->se_checked = 0;
		  goto skip;
		} else {
		  int i = 1;

		  memmove (&nsep->se_ctrladdr_in.sin_addr,
				   hp->h_addr_list[0], sizeof (struct in_addr));
		  while (hp->h_addr_list[i] != NULL) {
			psep = dupconfig (nsep);
			psep->se_hostaddr = newstr (nsep->se_hostaddr);
			psep->se_checked = 1;
			memmove (&psep->se_ctrladdr_in.sin_addr,
					 hp->h_addr_list[i], sizeof (struct in_addr));
			psep->se_ctrladdr_size = sizeof (psep->se_ctrladdr_in);
			i++;
			/* Prepend to list, don't want to look up its */
			/* hostname again. */
			psep->se_next = sep;
			sep = psep;
		  }
		}
	  }
	}
/* XXX BUG?: is this skip: label supposed to remain? */
  skip:
	nsep = nsep->se_next;
  }

  /*
   * Finally, free any entries which failed the gethostbyname
   * check.
   */
  psep = NULL;
  nsep = sep;
  while (nsep != NULL) {
	servtab_t *tsep;

	if (nsep->se_checked == 0) {
	  tsep = nsep;
	  if (psep == NULL) {
		sep = nsep->se_next;
		nsep = sep;
	  } else {
		nsep = nsep->se_next;
		psep->se_next = nsep;
	  }
	  freeconfig (tsep);
	} else {
	  nsep->se_checked = 0;
	  psep = nsep;
	  nsep = nsep->se_next;
	}
  }

  return (sep);
}

#define Block_Using_Signals(m) do {     sigemptyset(&m); \
					sigaddset(&m, SIGCHLD); \
					sigaddset(&m, SIGHUP); \
					sigaddset(&m, SIGALRM); \
					sigprocmask(SIG_BLOCK, &m, NULL); \
				} while(0)


static servtab_t *enter (servtab_t *cp)
{
  servtab_t *sep;
  sigset_t omask;

  sep = new_servtab();
  *sep = *cp;
  sep->se_fd = -1;
#ifdef CONFIG_FEATURE_INETD_RPC
  sep->se_rpcprog = -1;
#endif
  Block_Using_Signals(omask);
  sep->se_next = servtab;
  servtab = sep;
  sigprocmask(SIG_UNBLOCK, &omask, NULL);
  return (sep);
}

static int matchconf (servtab_t *old, servtab_t *new)
{
  if (strcmp (old->se_service, new->se_service) != 0)
	return (0);

  if (strcmp (old->se_hostaddr, new->se_hostaddr) != 0)
	return (0);

  if (strcmp (old->se_proto, new->se_proto) != 0)
	return (0);

  /*
   * If the new servtab is bound to a specific address, check that the
   * old servtab is bound to the same entry. If the new service is not
   * bound to a specific address then the check of se_hostaddr above
   * is sufficient.
   */

  if (old->se_family == AF_INET && new->se_family == AF_INET &&
	  memcmp (&old->se_ctrladdr_in.sin_addr,
			  &new->se_ctrladdr_in.sin_addr,
			  sizeof (new->se_ctrladdr_in.sin_addr)) != 0)
	return (0);

#ifdef CONFIG_FEATURE_IPV6
  if (old->se_family == AF_INET6 && new->se_family == AF_INET6 &&
	  memcmp (&old->se_ctrladdr_in6.sin6_addr,
			  &new->se_ctrladdr_in6.sin6_addr,
			  sizeof (new->se_ctrladdr_in6.sin6_addr)) != 0)
	return (0);
#endif
  return (1);
}

static void config (int sig __attribute__((unused)))
{
  servtab_t *sep, *cp, **sepp;
  sigset_t omask;
  int add;
  size_t n;
  char protoname[10];

  if (!setconfig ()) {
	syslog (LOG_ERR, "%s: %m", CONFIG);
	return;
  }
  for (sep = servtab; sep; sep = sep->se_next)
	sep->se_checked = 0;
  cp = getconfigent ();
  while (cp != NULL) {
	for (sep = servtab; sep; sep = sep->se_next)
	  if (matchconf (sep, cp))
		break;
	add = 0;
	if (sep != 0) {
	  int i;

#define SWAP(type, a, b) do {type c=(type)a; a=(type)b; b=(type)c;} while (0)

	  Block_Using_Signals(omask);
	  /*
	   * sep->se_wait may be holding the pid of a daemon
	   * that we're waiting for.  If so, don't overwrite
	   * it unless the config file explicitly says don't
	   * wait.
	   */
	  if (
#ifdef INETD_FEATURE_ENABLED
		   cp->se_bi == 0 &&
#endif
		(sep->se_wait == 1 || cp->se_wait == 0))
		sep->se_wait = cp->se_wait;
	  SWAP (int, cp->se_max, sep->se_max);
	  SWAP (char *, sep->se_user, cp->se_user);
	  SWAP (char *, sep->se_group, cp->se_group);
	  SWAP (char *, sep->se_server, cp->se_server);
	  for (i = 0; i < MAXARGV; i++)
		SWAP (char *, sep->se_argv[i], cp->se_argv[i]);
#undef SWAP

#ifdef CONFIG_FEATURE_INETD_RPC
	  if (isrpcservice (sep))
		unregister_rpc (sep);
	  sep->se_rpcversl = cp->se_rpcversl;
	  sep->se_rpcversh = cp->se_rpcversh;
#endif
	  sigprocmask(SIG_UNBLOCK, &omask, NULL);
	  freeconfig (cp);
	  add = 1;
	} else {
	  sep = enter (cp);
	}
	sep->se_checked = 1;

	switch (sep->se_family) {
	case AF_UNIX:
	  if (sep->se_fd != -1)
		break;
	  (void) unlink (sep->se_service);
	  n = strlen (sep->se_service);
	  if (n > sizeof sep->se_ctrladdr_un.sun_path - 1)
		n = sizeof sep->se_ctrladdr_un.sun_path - 1;
	  safe_strncpy (sep->se_ctrladdr_un.sun_path, sep->se_service, n + 1);
	  sep->se_ctrladdr_un.sun_family = AF_UNIX;
	  sep->se_ctrladdr_size = n + sizeof sep->se_ctrladdr_un.sun_family;
	  setup (sep);
	  break;
	case AF_INET:
	  sep->se_ctrladdr_in.sin_family = AF_INET;
	  /* se_ctrladdr_in was set in getconfigent */
	  sep->se_ctrladdr_size = sizeof sep->se_ctrladdr_in;

#ifdef CONFIG_FEATURE_INETD_RPC
	  if (isrpcservice (sep)) {
		struct rpcent *rp;

		sep->se_rpcprog = atoi (sep->se_service);
		if (sep->se_rpcprog == 0) {
		  rp = getrpcbyname (sep->se_service);
		  if (rp == 0) {
			syslog (LOG_ERR, "%s: unknown rpc service", sep->se_service);
			goto serv_unknown;
		  }
		  sep->se_rpcprog = rp->r_number;
		}
		if (sep->se_fd == -1)
		  setup (sep);
		if (sep->se_fd != -1)
		  register_rpc (sep);
	  } else
#endif
	     {
		u_short port = htons (atoi (sep->se_service));

		if (!port) {
		   /*XXX*/ strncpy (protoname, sep->se_proto, sizeof (protoname));
		  if (isdigit (protoname[strlen (protoname) - 1]))
			protoname[strlen (protoname) - 1] = '\0';
		  sp = getservbyname (sep->se_service, protoname);
		  if (sp == 0) {
			syslog (LOG_ERR,
					"%s/%s: unknown service", sep->se_service, sep->se_proto);
			goto serv_unknown;
		  }
		  port = sp->s_port;
		}
		if (port != sep->se_ctrladdr_in.sin_port) {
		  sep->se_ctrladdr_in.sin_port = port;
		  if (sep->se_fd != -1) {
			FD_CLR (sep->se_fd, &allsock);
			nsock--;
			(void) close (sep->se_fd);
		  }
		  sep->se_fd = -1;
		}
		if (sep->se_fd == -1)
		  setup (sep);
	  }
	  break;
#ifdef CONFIG_FEATURE_IPV6
	case AF_INET6:
	  sep->se_ctrladdr_in6.sin6_family = AF_INET6;
	  /* se_ctrladdr_in was set in getconfigent */
	  sep->se_ctrladdr_size = sizeof sep->se_ctrladdr_in6;

#ifdef CONFIG_FEATURE_INETD_RPC
	  if (isrpcservice (sep)) {
		struct rpcent *rp;

		sep->se_rpcprog = atoi (sep->se_service);
		if (sep->se_rpcprog == 0) {
		  rp = getrpcbyname (sep->se_service);
		  if (rp == 0) {
			syslog (LOG_ERR, "%s: unknown rpc service", sep->se_service);
			goto serv_unknown;
		  }
		  sep->se_rpcprog = rp->r_number;
		}
		if (sep->se_fd == -1)
		  setup (sep);
		if (sep->se_fd != -1)
		  register_rpc (sep);
	  } else
#endif
		{
		u_short port = htons (atoi (sep->se_service));

		if (!port) {
		   /*XXX*/ strncpy (protoname, sep->se_proto, sizeof (protoname));
		  if (isdigit (protoname[strlen (protoname) - 1]))
			protoname[strlen (protoname) - 1] = '\0';
		  sp = getservbyname (sep->se_service, protoname);
		  if (sp == 0) {
			syslog (LOG_ERR,
					"%s/%s: unknown service", sep->se_service, sep->se_proto);
			goto serv_unknown;
		  }
		  port = sp->s_port;
		}
		if (port != sep->se_ctrladdr_in6.sin6_port) {
		  sep->se_ctrladdr_in6.sin6_port = port;
		  if (sep->se_fd != -1) {
			FD_CLR (sep->se_fd, &allsock);
			nsock--;
			(void) close (sep->se_fd);
		  }
		  sep->se_fd = -1;
		}
		if (sep->se_fd == -1)
		  setup (sep);
	  }
	  break;
#endif /* CONFIG_FEATURE_IPV6 */
	}
  serv_unknown:
	if (cp->se_next != NULL) {
	  servtab_t *tmp = cp;

	  cp = cp->se_next;
	  free (tmp);
	} else {
	  free (cp);
	  cp = getconfigent ();
	}
  }
  endconfig ();
  /*
   * Purge anything not looked at above.
   */
  Block_Using_Signals(omask);
  sepp = &servtab;
  while ((sep = *sepp)) {
	if (sep->se_checked) {
	  sepp = &sep->se_next;
	  continue;
	}
	*sepp = sep->se_next;
	if (sep->se_fd != -1) {
	  FD_CLR (sep->se_fd, &allsock);
	  nsock--;
	  (void) close (sep->se_fd);
	}
#ifdef CONFIG_FEATURE_INETD_RPC
	if (isrpcservice (sep))
	  unregister_rpc (sep);
#endif
	if (sep->se_family == AF_UNIX)
	  (void) unlink (sep->se_service);
	freeconfig (sep);
	free (sep);
  }
  sigprocmask(SIG_UNBLOCK, &omask, NULL);
}


static void reapchild (int sig __attribute__((unused)))
{
  pid_t pid;
  int save_errno = errno, status;
  servtab_t *sep;

  for (;;) {
	pid = wait3 (&status, WNOHANG, NULL);
	if (pid <= 0)
	  break;
	for (sep = servtab; sep; sep = sep->se_next)
	  if (sep->se_wait == pid) {
		if (WIFEXITED (status) && WEXITSTATUS (status))
		  syslog (LOG_WARNING,
				  "%s: exit status 0x%x",
				  sep->se_server, WEXITSTATUS (status));
		else if (WIFSIGNALED (status))
		  syslog (LOG_WARNING,
				  "%s: exit signal 0x%x", sep->se_server, WTERMSIG (status));
		sep->se_wait = 1;
		FD_SET (sep->se_fd, &allsock);
		nsock++;
	  }
  }
  errno = save_errno;
}

static void retry (int sig __attribute__((unused)))
{
  servtab_t *sep;

  timingout = 0;
  for (sep = servtab; sep; sep = sep->se_next) {
	if (sep->se_fd == -1) {
	  switch (sep->se_family) {
	  case AF_UNIX:
	  case AF_INET:
#ifdef CONFIG_FEATURE_IPV6
	  case AF_INET6:
#endif
		setup (sep);
#ifdef CONFIG_FEATURE_INETD_RPC
		if (sep->se_fd != -1 && isrpcservice (sep))
		  register_rpc (sep);
#endif
		break;
	  }
	}
  }
}

static void goaway (int sig __attribute__((unused)))
{
  servtab_t *sep;

  /* XXX signal race walking sep list */
  for (sep = servtab; sep; sep = sep->se_next) {
	if (sep->se_fd == -1)
	  continue;

	switch (sep->se_family) {
	case AF_UNIX:
	  (void) unlink (sep->se_service);
	  break;
	case AF_INET:
#ifdef CONFIG_FEATURE_IPV6
	case AF_INET6:
#endif
#ifdef CONFIG_FEATURE_INETD_RPC
	  if (sep->se_wait == 1 && isrpcservice (sep))
		unregister_rpc (sep);   /* XXX signal race */
#endif
	  break;
	}
	(void) close (sep->se_fd);
  }
  (void) unlink (_PATH_INETDPID);
  exit (0);
}


#ifdef INETD_SETPROCTITLE
static char **Argv;
static char *LastArg;

static void
inetd_setproctitle (char *a, int s)
{
  socklen_t size;
  char *cp;
  struct sockaddr_in prt_sin;
  char buf[80];

  cp = Argv[0];
  size = sizeof (prt_sin);
  (void) snprintf (buf, sizeof buf, "-%s", a);
  if (getpeername (s, (struct sockaddr *) &prt_sin, &size) == 0) {
	char *sa = inet_ntoa (prt_sin.sin_addr);

	buf[sizeof (buf) - 1 - strlen (sa) - 3] = '\0';
	strcat (buf, " [");
	strcat (buf, sa);
	strcat (buf, "]");
  }
  strncpy (cp, buf, LastArg - cp);
  cp += strlen (cp);
  while (cp < LastArg)
	*cp++ = ' ';
}
#endif


int
inetd_main (int argc, char *argv[])
{
  servtab_t *sep;
  struct passwd *pwd;
  struct group *grp = NULL;
  int tmpint;
  struct sigaction sa, sapipe;
  int opt;
  pid_t pid;
  char buf[50];
  char *stoomany;
  sigset_t omask, wait_mask;

#ifdef INETD_SETPROCTITLE
  extern char **environ;
  char **envp = environ;

  Argv = argv;
  if (envp == 0 || *envp == 0)
	envp = argv;
  while (*envp)
	envp++;
  LastArg = envp[-1] + strlen (envp[-1]);
#endif

  openlog (bb_applet_name, LOG_PID | LOG_NOWAIT, LOG_DAEMON);

  opt = bb_getopt_ulflags (argc, argv, "R:f", &stoomany);
  if(opt & 1) {
	char *e;

	toomany = strtoul (stoomany, &e, 0);
	if (!(toomany >= 0 && *e == '\0')) {
		toomany = TOOMANY;
		syslog (LOG_ERR, "-R %s: bad value for service invocation rate", stoomany);
	}
  }
  argc -= optind;
  argv += optind;

  uid = getuid ();
  if (uid != 0)
	CONFIG = NULL;
  if (argc > 0)
	CONFIG = argv[0];
  if (CONFIG == NULL)
	bb_error_msg_and_die ("non-root must specify a config file");

  if (!(opt & 2)) {
#if defined(__uClinux__)
	/* reexec for vfork() do continue parent */
	vfork_daemon_rexec (0, 0, argc, argv, "-f");
#else
	daemon (0, 0);
#endif /* uClinux */
  } else {
	setsid ();
  }

  if (uid == 0) {
	gid_t gid = getgid ();

	/* If run by hand, ensure groups vector gets trashed */
	setgroups (1, &gid);
  }

  {
	FILE *fp;

	if ((fp = fopen (_PATH_INETDPID, "w")) != NULL) {
		fprintf (fp, "%u\n", getpid ());
		(void) fclose (fp);
	}
  }

  if (getrlimit (RLIMIT_NOFILE, &rlim_ofile) < 0) {
	syslog (LOG_ERR, "getrlimit: %m");
  } else {
	rlim_ofile_cur = rlim_ofile.rlim_cur;
	if (rlim_ofile_cur == RLIM_INFINITY)    /* ! */
	  rlim_ofile_cur = OPEN_MAX;
  }

  memset ((char *) &sa, 0, sizeof (sa));
  sigemptyset (&sa.sa_mask);
  sigaddset (&sa.sa_mask, SIGALRM);
  sigaddset (&sa.sa_mask, SIGCHLD);
  sigaddset (&sa.sa_mask, SIGHUP);
  sa.sa_handler = retry;
  sigaction (SIGALRM, &sa, NULL);
  /* doconfig(); */
  config (SIGHUP);
  sa.sa_handler = config;
  sigaction (SIGHUP, &sa, NULL);
  sa.sa_handler = reapchild;
  sigaction (SIGCHLD, &sa, NULL);
  sa.sa_handler = goaway;
  sigaction (SIGTERM, &sa, NULL);
  sa.sa_handler = goaway;
  sigaction (SIGINT, &sa, NULL);
  sa.sa_handler = SIG_IGN;
  sigaction (SIGPIPE, &sa, &sapipe);
  memset(&wait_mask, 0, sizeof(wait_mask)); 
  {
	/* 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);
  }

  for (;;) {
	int n, ctrl = -1;
	fd_set readable;

	if (nsock == 0) {
	  Block_Using_Signals(omask);
	  while (nsock == 0)
		sigsuspend (&wait_mask);
	  sigprocmask(SIG_UNBLOCK, &omask, NULL);
	}

	readable = allsock;
	if ((n = select (maxsock + 1, &readable, NULL, NULL, NULL)) <= 0) {
	  if (n < 0 && errno != EINTR) {
		syslog (LOG_WARNING, "select: %m");
		sleep (1);
	  }
	  continue;
	}
	for (sep = servtab; n && sep; sep = sep->se_next)
	  if (sep->se_fd != -1 && FD_ISSET (sep->se_fd, &readable)) {
		n--;
		if (!sep->se_wait && sep->se_socktype == SOCK_STREAM) {
		  ctrl = accept (sep->se_fd, NULL, NULL);
		  if (ctrl < 0) {
			if (errno == EINTR)
			  continue;
			syslog (LOG_WARNING, "accept (for %s): %m", sep->se_service);
			continue;
		  }
		  if (sep->se_family == AF_INET && sep->se_socktype == SOCK_STREAM) {
			struct sockaddr_in peer;
			socklen_t plen = sizeof (peer);

			if (getpeername (ctrl, (struct sockaddr *) &peer, &plen) < 0) {
			  syslog (LOG_WARNING, "could not getpeername");
			  close (ctrl);
			  continue;
			}
			if (ntohs (peer.sin_port) == 20) {
			  /* XXX ftp bounce */
			  close (ctrl);
			  continue;
			}
		  }
		} else
		  ctrl = sep->se_fd;
		Block_Using_Signals(omask);
		pid = 0;
#ifdef INETD_FEATURE_ENABLED
		if (sep->se_bi == 0 || sep->se_bi->bi_fork)
#endif
		{
		  if (sep->se_count++ == 0)
			(void) gettimeofday (&sep->se_time, NULL);
		  else if (toomany > 0 && sep->se_count >= sep->se_max) {
			struct timeval now;

			(void) gettimeofday (&now, NULL);
			if (now.tv_sec - sep->se_time.tv_sec > CNT_INTVL) {
			  sep->se_time = now;
			  sep->se_count = 1;
			} else {
			  if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
				close (ctrl);
			  if (sep->se_family == AF_INET &&
				  ntohs (sep->se_ctrladdr_in.sin_port) >= IPPORT_RESERVED) {
				/*
				 * Cannot close it -- there are
				 * thieves on the system.
				 * Simply ignore the connection.
				 */
				--sep->se_count;
				continue;
			  }
			  syslog (LOG_ERR,
					  "%s/%s server failing (looping), service terminated",
					  sep->se_service, sep->se_proto);
			  if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
				close (ctrl);
			  FD_CLR (sep->se_fd, &allsock);
			  (void) close (sep->se_fd);
			  sep->se_fd = -1;
			  sep->se_count = 0;
			  nsock--;
			  sigprocmask(SIG_UNBLOCK, &omask, NULL);
			  if (!timingout) {
				timingout = 1;
				alarm (RETRYTIME);
			  }
			  continue;
			}
		  }
		  pid = fork ();
		}
		if (pid < 0) {
		  syslog (LOG_ERR, "fork: %m");
		  if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
			close (ctrl);
		  sigprocmask(SIG_UNBLOCK, &omask, NULL);
		  sleep (1);
		  continue;
		}
		if (pid && sep->se_wait) {
		  sep->se_wait = pid;
		  FD_CLR (sep->se_fd, &allsock);
		  nsock--;
		}
		sigprocmask(SIG_UNBLOCK, &omask, NULL);
		if (pid == 0) {
#ifdef INETD_FEATURE_ENABLED
		  if (sep->se_bi) {
			(*sep->se_bi->bi_fn) (ctrl, sep);
		  } else
#endif
			{
			if ((pwd = getpwnam (sep->se_user)) == NULL) {
			  syslog (LOG_ERR, "getpwnam: %s: No such user", sep->se_user);
			  if (sep->se_socktype != SOCK_STREAM)
				recv (0, buf, sizeof (buf), 0);
			  _exit (1);
			}
			if (setsid () < 0)
			  syslog (LOG_ERR, "%s: setsid: %m", sep->se_service);
			if (sep->se_group && (grp = getgrnam (sep->se_group)) == NULL) {
			  syslog (LOG_ERR, "getgrnam: %s: No such group", sep->se_group);
			  if (sep->se_socktype != SOCK_STREAM)
				recv (0, buf, sizeof (buf), 0);
			  _exit (1);
			}
			if (uid != 0) {
			  /* a user running private inetd */
			  if (uid != pwd->pw_uid)
				_exit (1);
			} else if (pwd->pw_uid) {
			  if (sep->se_group) {
				pwd->pw_gid = grp->gr_gid;
			  }
			  setgid ((gid_t) pwd->pw_gid);
			  initgroups (pwd->pw_name, pwd->pw_gid);
			  setuid ((uid_t) pwd->pw_uid);
			} else if (sep->se_group) {
			  setgid (grp->gr_gid);
			  setgroups (1, &grp->gr_gid);
			}
			dup2 (ctrl, 0);
			close (ctrl);
			dup2 (0, 1);
			dup2 (0, 2);
			if (rlim_ofile.rlim_cur != rlim_ofile_cur)
			  if (setrlimit (RLIMIT_NOFILE, &rlim_ofile) < 0)
				syslog (LOG_ERR, "setrlimit: %m");
			closelog ();
			for (tmpint = rlim_ofile_cur - 1; --tmpint > 2;)
			  (void) close (tmpint);
			sigaction (SIGPIPE, &sapipe, NULL);
			execv (sep->se_server, sep->se_argv);
			if (sep->se_socktype != SOCK_STREAM)
			  recv (0, buf, sizeof (buf), 0);
			syslog (LOG_ERR, "execv %s: %m", sep->se_server);
			_exit (1);
		  }
		}
		if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
		  close (ctrl);
	  }
  }
}

/*
 * Internet services provided internally by inetd:
 */
#define BUFSIZE 4096

#if defined(CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO) || \
    defined(CONFIG_FEATURE_INETD_SUPPORT_BILTIN_CHARGEN) || \
    defined(CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DAYTIME)
static int dg_badinput (struct sockaddr_in *dg_sin)
{
  if (ntohs (dg_sin->sin_port) < IPPORT_RESERVED)
	return (1);
  if (dg_sin->sin_addr.s_addr == htonl (INADDR_BROADCAST))
	return (1);
  /* XXX compare against broadcast addresses in SIOCGIFCONF list? */
  return (0);
}
#endif

#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO
/* Echo service -- echo data back */
/* ARGSUSED */
static void
echo_stream (int s, servtab_t *sep)
{
  char buffer[BUFSIZE];
  int i;

  inetd_setproctitle (sep->se_service, s);
  while ((i = read (s, buffer, sizeof (buffer))) > 0 &&
		 write (s, buffer, i) > 0);
  exit (0);
}

/* Echo service -- echo data back */
/* ARGSUSED */
static void
echo_dg (int s, servtab_t *sep __attribute__((unused)))
{
  char buffer[BUFSIZE];
  int i;
  socklen_t size;
  /* struct sockaddr_storage ss; */
  struct sockaddr sa;

  size = sizeof (sa);
  if ((i = recvfrom (s, buffer, sizeof (buffer), 0, &sa, &size)) < 0)
	return;
  if (dg_badinput ((struct sockaddr_in *) &sa))
	return;
  (void) sendto (s, buffer, i, 0, &sa, sizeof (sa));
}
#endif  /* CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO */

#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DISCARD
/* Discard service -- ignore data */
/* ARGSUSED */
static void
discard_stream (int s, servtab_t *sep)
{
  char buffer[BUFSIZE];

  inetd_setproctitle (sep->se_service, s);
  while ((errno = 0, read (s, buffer, sizeof (buffer)) > 0) ||
		 errno == EINTR);
  exit (0);
}

/* Discard service -- ignore data */
/* ARGSUSED */
static void
discard_dg (int s, servtab_t *sep __attribute__((unused)))
{
  char buffer[BUFSIZE];

  (void) read (s, buffer, sizeof (buffer));
}
#endif /* CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DISCARD */


#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_CHARGEN
#define LINESIZ 72
static char ring[128];
static char *endring;

static void
initring (void)
{
  int i;

  endring = ring;

  for (i = 0; i <= 128; ++i)
	if (isprint (i))
	  *endring++ = i;
}

/* Character generator */
/* ARGSUSED */
static void
chargen_stream (int s, servtab_t *sep)
{
  char *rs;
  int len;
  char text[LINESIZ + 2];

  inetd_setproctitle (sep->se_service, s);

  if (!endring) {
	initring ();
	rs = ring;
  }

  text[LINESIZ] = '\r';
  text[LINESIZ + 1] = '\n';
  for (rs = ring;;) {
	if ((len = endring - rs) >= LINESIZ)
	  memmove (text, rs, LINESIZ);
	else {
	  memmove (text, rs, len);
	  memmove (text + len, ring, LINESIZ - len);
	}
	if (++rs == endring)
	  rs = ring;
	if (write (s, text, sizeof (text)) != sizeof (text))
	  break;
  }
  exit (0);
}

/* Character generator */
/* ARGSUSED */
static void
chargen_dg (int s, servtab_t *sep __attribute__((unused)))
{
  /* struct sockaddr_storage ss; */
  struct sockaddr sa;
  static char *rs;
  int len;
  char text[LINESIZ + 2];
  socklen_t size;

  if (endring == 0) {
	initring ();
	rs = ring;
  }

  size = sizeof (sa);
  if (recvfrom (s, text, sizeof (text), 0, &sa, &size) < 0)
	return;
  if (dg_badinput ((struct sockaddr_in *) &sa))
	return;

  if ((len = endring - rs) >= LINESIZ)
	memmove (text, rs, LINESIZ);
  else {
	memmove (text, rs, len);
	memmove (text + len, ring, LINESIZ - len);
  }
  if (++rs == endring)
	rs = ring;
  text[LINESIZ] = '\r';
  text[LINESIZ + 1] = '\n';
  (void) sendto (s, text, sizeof (text), 0, &sa, sizeof (sa));
}
#endif /* CONFIG_FEATURE_INETD_SUPPORT_BILTIN_CHARGEN */


#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_TIME
/*
 * Return a machine readable date and time, in the form of the
 * number of seconds since midnight, Jan 1, 1900.  Since gettimeofday
 * returns the number of seconds since midnight, Jan 1, 1970,
 * we must add 2208988800 seconds to this figure to make up for
 * some seventy years Bell Labs was asleep.
 */

static u_int machtime (void)
{
  struct timeval tv;

  if (gettimeofday (&tv, NULL) < 0) {
	fprintf (stderr, "Unable to get time of day\n");
	return (0L);
  }
  return (htonl ((u_int) tv.tv_sec + 2208988800UL));
}

/* ARGSUSED */
static void
machtime_stream (int s, servtab_t *sep __attribute__((unused)))
{
  u_int result;

  result = machtime ();
  (void) write (s, (char *) &result, sizeof (result));
}

/* ARGSUSED */
static void
machtime_dg (int s, servtab_t *sep __attribute__((unused)))
{
  u_int result;
  /* struct sockaddr_storage ss; */
  struct sockaddr sa;
  struct sockaddr_in *dg_sin;
  socklen_t size;

  size = sizeof (sa);
  if (recvfrom (s, (char *) &result, sizeof (result), 0, &sa, &size) < 0)
	return;
  /* if (dg_badinput((struct sockaddr *)&ss)) */
  dg_sin = (struct sockaddr_in *) &sa;
  if (dg_sin->sin_addr.s_addr == htonl (INADDR_BROADCAST) ||
	  ntohs (dg_sin->sin_port) < IPPORT_RESERVED / 2)
	return;
  result = machtime ();
  (void) sendto (s, (char *) &result, sizeof (result), 0, &sa, sizeof (sa));
}
#endif /* CONFIG_FEATURE_INETD_SUPPORT_BILTIN_TIME */


#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DAYTIME
/* Return human-readable time of day */
/* ARGSUSED */
static void daytime_stream (int s, servtab_t *sep __attribute__((unused)))
{
  char buffer[256];
  time_t t;

  t = time (NULL);

  (void) sprintf (buffer, "%.24s\r\n", ctime (&t));
  (void) write (s, buffer, strlen (buffer));
}

/* Return human-readable time of day */
/* ARGSUSED */
void
daytime_dg (int s, servtab_t *sep __attribute__((unused)))
{
  char buffer[256];
  time_t t;
  /* struct sockaddr_storage ss; */
  struct sockaddr sa;
  socklen_t size;

  t = time ((time_t *) 0);

  size = sizeof (sa);
  if (recvfrom (s, buffer, sizeof (buffer), 0, &sa, &size) < 0)
	return;
  if (dg_badinput ((struct sockaddr_in *) &sa))
	return;
  (void) sprintf (buffer, "%.24s\r\n", ctime (&t));
  (void) sendto (s, buffer, strlen (buffer), 0, &sa, sizeof (sa));
}
#endif /* CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DAYTIME */
