/*      $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>
#include <rpcsvc/nfs_prot.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;

#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);

  {
	/* 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)
		sigpause (0L);
	  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 */
