5 kx /* $Slackware: inetd.c 1.79s 2001/02/06 13:18:00 volkerdi Exp $ */
5 kx /* $OpenBSD: inetd.c,v 1.79 2001/01/30 08:30:57 deraadt Exp $ */
5 kx /* $NetBSD: inetd.c,v 1.11 1996/02/22 11:14:41 mycroft Exp $ */
5 kx /*
5 kx * Copyright (c) 1983,1991 The Regents of the University of California.
5 kx * All rights reserved.
5 kx *
5 kx * Redistribution and use in source and binary forms, with or without
5 kx * modification, are permitted provided that the following conditions
5 kx * are met:
5 kx * 1. Redistributions of source code must retain the above copyright
5 kx * notice, this list of conditions and the following disclaimer.
5 kx * 2. Redistributions in binary form must reproduce the above copyright
5 kx * notice, this list of conditions and the following disclaimer in the
5 kx * documentation and/or other materials provided with the distribution.
5 kx * 3. All advertising materials mentioning features or use of this software
5 kx * must display the following acknowledgement:
5 kx * This product includes software developed by the University of
5 kx * California, Berkeley and its contributors.
5 kx * 4. Neither the name of the University nor the names of its contributors
5 kx * may be used to endorse or promote products derived from this software
5 kx * without specific prior written permission.
5 kx *
5 kx * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
5 kx * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5 kx * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5 kx * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
5 kx * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5 kx * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5 kx * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5 kx * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5 kx * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5 kx * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5 kx * SUCH DAMAGE.
5 kx */
5 kx
5 kx /*
5 kx * Inetd - Internet super-server
5 kx *
5 kx * This program invokes all internet services as needed.
5 kx * connection-oriented services are invoked each time a
5 kx * connection is made, by creating a process. This process
5 kx * is passed the connection as file descriptor 0 and is
5 kx * expected to do a getpeername to find out the source host
5 kx * and port.
5 kx *
5 kx * Datagram oriented services are invoked when a datagram
5 kx * arrives; a process is created and passed a pending message
5 kx * on file descriptor 0. Datagram servers may either connect
5 kx * to their peer, freeing up the original socket for inetd
5 kx * to receive further messages on, or ``take over the socket'',
5 kx * processing all arriving datagrams and, eventually, timing
5 kx * out. The first type of server is said to be ``multi-threaded'';
5 kx * the second type of server ``single-threaded''.
5 kx *
5 kx * Inetd uses a configuration file which is read at startup
5 kx * and, possibly, at some later time in response to a hangup signal.
5 kx * The configuration file is ``free format'' with fields given in the
5 kx * order shown below. Continuation lines for an entry must begin with
5 kx * a space or tab. All fields must be present in each entry.
5 kx *
5 kx * service name must be in /etc/services
5 kx * socket type stream/dgram/raw/rdm/seqpacket
5 kx * protocol must be in /etc/protocols
5 kx * wait/nowait[.max] single-threaded/multi-threaded, max #
5 kx * user[.group] or user[:group] user/group to run daemon as
5 kx * server program full path name
5 kx * server program arguments maximum of MAXARGS (20)
5 kx *
5 kx * For RPC services
5 kx * service name/version must be in /etc/rpc
5 kx * socket type stream/dgram/raw/rdm/seqpacket
5 kx * protocol must be in /etc/protocols
5 kx * wait/nowait[.max] single-threaded/multi-threaded
5 kx * user[.group] or user[:group] user to run daemon as
5 kx * server program full path name
5 kx * server program arguments maximum of MAXARGS (20)
5 kx *
5 kx * For non-RPC services, the "service name" can be of the form
5 kx * hostaddress:servicename, in which case the hostaddress is used
5 kx * as the host portion of the address to listen on. If hostaddress
5 kx * consists of a single `*' character, INADDR_ANY is used.
5 kx *
5 kx * A line can also consist of just
5 kx * hostaddress:
5 kx * where hostaddress is as in the preceding paragraph. Such a line must
5 kx * have no further fields; the specified hostaddress is remembered and
5 kx * used for all further lines that have no hostaddress specified,
5 kx * until the next such line (or EOF). (This is why * is provided to
5 kx * allow explicit specification of INADDR_ANY.) A line
5 kx * *:
5 kx * is implicitly in effect at the beginning of the file.
5 kx *
5 kx * The hostaddress specifier may (and often will) contain dots;
5 kx * the service name must not.
5 kx *
5 kx * For RPC services, host-address specifiers are accepted and will
5 kx * work to some extent; however, because of limitations in the
5 kx * portmapper interface, it will not work to try to give more than
5 kx * one line for any given RPC service, even if the host-address
5 kx * specifiers are different.
5 kx *
5 kx * Comment lines are indicated by a `#' in column 1.
5 kx */
5 kx
5 kx /*
5 kx * Here's the scoop concerning the user[.:]group feature:
5 kx *
5 kx * 1) set-group-option off.
5 kx *
5 kx * a) user = root: NO setuid() or setgid() is done
5 kx *
5 kx * b) other: setgid(primary group as found in passwd)
5 kx * initgroups(name, primary group)
5 kx * setuid()
5 kx *
5 kx * 2) set-group-option on.
5 kx *
5 kx * a) user = root: setgid(specified group)
5 kx * NO initgroups()
5 kx * NO setuid()
5 kx *
5 kx * b) other: setgid(specified group)
5 kx * initgroups(name, specified group)
5 kx * setuid()
5 kx *
5 kx */