.\" $NetBSD: inetd.8,v 1.68 2024/05/24 21:55:13 andvar Exp $
.\"
.\" Copyright (c) 1998 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
.\" NASA Ames Research Center.
.\"
.\" 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.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
.\"
.\" Copyright (c) 1985, 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. 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.
.\"
.\" from: @(#)inetd.8 8.4 (Berkeley) 6/1/94
.\"
.Dd October 12, 2021
.Dt INETD 8
.Os
.Sh NAME
.Nm inetd ,
.Nm inetd.conf
.Nd internet
.Dq super-server
.Sh SYNOPSIS
.Nm
.Op Fl d
.Op Fl l
.Op Ar configuration file
.Sh DESCRIPTION
.Nm
should be run at boot time by
.Pa /etc/rc
(see
.Xr rc 8 ) .
It then opens sockets according to its configuration and listens
for connections.
When a connection is found on one of its sockets, it decides what
service the socket corresponds to, and invokes a program to service
the request.
After the program is finished, it continues to listen on the socket
(except in some cases which will be described below).
Essentially,
.Nm
allows running one daemon to invoke several others,
reducing load on the system.
.Pp
The options available for
.Nm :
.Bl -tag -width Ds
.It Fl d
Turns on debugging and runs
.Nm
in the foreground.
.It Fl f
Runs
.Nm
in the foreground.
.It Fl l
Turns on libwrap connection logging.
.El
.Pp
Upon execution,
.Nm
reads its configuration information from a configuration
file which, by default, is
.Pa /etc/inetd.conf .
The path given for this configuration file must be absolute, unless
the
.Fl d
option is also given on the command line.
.Pp
Services can be specified using the legacy `positional' notation or the
`key-values' notation described in the sections
.Sx Positional Notation
and
.Sx Key-Values Notation
below.
.Ss Positional Notation
There must be an entry for each field of the configuration
file, with entries for each field separated by a tab or
a space.
Comments are denoted by a ``#'' at the beginning of a line (see subsection
.Sx Key-Values Notation
for defining comments in key-values definitions).
There must be an entry for each field (except for one
special case, described below).
A positional definition is terminated by a newline.
The fields of the configuration file are as follows:
.Pp
.Bd -unfilled -offset indent -compact
[listen-addr:]service-spec
socket-type[:accept-filter]
protocol[,sndbuf=size][,rcvbuf=size]
wait/nowait[:max]
user[:group]
server-program
server program arguments
.Ed
.Pp
The
.Em listen-addr
parameter specifies the local address
.Nm
should use when listening.
The single character
.Dq \&*
means
.Dv INADDR_ANY :
all local addresses.
The
.Em listen-addr
parameter may be a host name, which will be resolved once, when the service
definition is read from the config file.
.Pp
Note that restricted listen addresses are meaningless and ignored for
UNIX-domain services, and are not supported for
.Em Sun-RPC
services.
All
.Em Sun-RPC
services always listen on all interfaces.
.Pp
The form of the
.Em service-spec
parameter varies with the service type.
For Internet services, the
.Em service-spec
parameter can be either the name of a service from
.Pa /etc/services
or a decimal port number.
For
.Dq internal
services (discussed below), the service name
.Em must
be the official name of the service (that is, the first entry in
.Pa /etc/services )
and not an alias for it.
.Pp
For
.Em Sun-RPC
based services, the
.Em service-spec
parameter has the form
.Em service-name Ns Li / Ns Em version .
The service name must be a valid RPC service name from
the file
.Pa /etc/rpc .
The
.Em version
on the right of the
.Dq /
is the RPC version number.
This can simply be a single numeric argument or a range of versions.
A range is bounded by the low version to the high version, e.g.
.Dq rusers/1-3 .
.Pp
For UNIX-domain (local) services, the
.Em service-spec
parameter is the path name to listen on.
.Pp
The
.Em service-spec
parameter must not begin with a dot.
See
.Sx Directives .
.Pp
The
.Em socket-type
parameter should be one of
.Dq stream ,
.Dq dgram ,
.Dq raw ,
.Dq rdm ,
or
.Dq seqpacket ,
depending on whether the socket is a stream, datagram, raw,
reliably delivered message, or sequenced packet socket.
.Pp
Optionally, for Internet services, an accept filter
(see
.Xr accept_filter 9 )
can be specified by appending a colon to
.Em socket-type ,
followed by the name of the desired accept filter.
In this case
.Nm
will not see new connections for the specified service until the accept
filter decides they are ready to be handled.
.\" XXX: do accept filters work for AF_UNIX sockets? nobody probably
.\" cares, but...
.Pp
The
.Em protocol
parameter must be a valid protocol as given in
.Pa /etc/protocols
or (for UNIX-domain services) the string
.Dq unix .
The most common are
.Dq tcp
and
.Dq udp .
For TCP and UDP, the IP version (4 or 6) may be specified explicitly
by appending 4 or 6 to the protocol name.
Otherwise the default version (IPv4) is used.
For
.Em Sun-RPC
the string
.Dq rpc
and a slash should be prepended:
.Dq rpc/tcp
or
.Dq rpc/udp .
If you would like to enable special support for
.Xr faithd 8 ,
prepend the string
.Dq faith
and a slash:
.Dq faith/tcp6 .
.Pp
In addition to the protocol, the configuration file may specify the
send and receive socket buffer sizes for the listening socket.
This is especially useful for
.Tn TCP :
the window scale factor, which is based on the receive socket
buffer size, is advertised when the connection handshake occurs
and thus the socket buffer size must be set on the listen socket.
By increasing the socket buffer sizes, better
.Tn TCP
performance may be realized in some situations.
The socket buffer sizes are specified by appending their values to
the protocol specification as follows:
.Bd -literal -offset indent
tcp,rcvbuf=16384
tcp,sndbuf=64k
tcp,rcvbuf=64k,sndbuf=1m
.Ed
.Pp
A literal value may be specified, or modified using
.Sq k
to indicate kibibytes or
.Sq m
to indicate mebibytes.
Socket buffer sizes may be specified for all
services and protocols except for tcpmux services.
.Pp
The
.Em wait/nowait
entry is used to tell
.Nm
if it should wait for the server program to return,
or continue processing connections on the socket.
If a datagram server reads a single datagram and connects
to its peer through a different socket, freeing the service's socket so
.Nm
can receive further messages on the socket, it is said to be
a
.Dq multi-threaded
server, and should use the
.Dq nowait
entry.
For datagram servers which process all incoming datagrams
on a socket and eventually time out, the server is said to be
.Dq single-threaded
and should use a
.Dq wait
entry.
.Xr comsat 8
.Pq Xr biff 1
and
.Xr ntalkd 8
are both examples of the latter type of
datagram server.
.Xr tftpd 8
is an exception; it is a datagram server that establishes pseudo-connections.
It must be listed as
.Dq wait
in order to avoid a race;
the server reads the first packet, creates a new socket,
and then forks and exits to allow
.Nm
to check for new service requests to spawn new servers.
The optional
.Dq max
suffix (separated from
.Dq wait
or
.Dq nowait
by a dot or a colon) specifies the maximum number of server instances that may
be spawned from
.Nm
within an interval of 60 seconds.
When omitted,
.Dq max
defaults to 40.
If it reaches this maximum spawn rate,
.Nm
will log the problem (via the syslogger using the
.Dv LOG_DAEMON
facility and
.Dv LOG_ERR
level)
and stop handling the specific service for ten minutes.
.Pp
Stream servers are usually marked as
.Dq nowait
but if a single server process is to handle multiple connections, it may be
marked as
.Dq wait .
The master socket will then be passed as fd 0 to the server, which will then
need to accept the incoming connection.
The server should eventually time
out and exit when no more connections are active.
.Nm
will continue to
listen on the master socket for connections, so the server should not close
it when it exits.
.Xr identd 8
is usually the only stream server marked as wait.
.Pp
The
.Em user
entry should contain the user name of the user as whom the server should run.
This allows for servers to be given less permission than root.
Optionally, a group can be specified by appending a colon to the user name,
followed by the group name (it is possible to use a dot (``.'') in lieu of a
colon, however this feature is provided only for backward compatibility).
This allows for servers to run with a different (primary) group id than
specified in the password file.
If a group is specified and
.Em user
is not root, the supplementary groups associated with that user will still be
set.
.Pp
The
.Em server-program
entry should contain the pathname of the program which is to be
executed by
.Nm
when a request is found on its socket.
If
.Nm
provides this service internally, this entry should
be
.Dq internal .
.Pp
The
.Em server program arguments
should be just as arguments
normally are, starting with argv[0], which is the name of
the program.
If the service is provided internally, the
word
.Dq internal
should take the place of this entry.
It is possible to quote an argument using either single or double quotes.
This allows you to have, e.g., spaces in paths and parameters.
.Ss Key-Values Notation
In key-values notation, keys are separated from their associated values by `=',
values are separated by whitespace, and key-values options are separated by
commas.
A service definition is terminated by a semicolon.
Multiple definitions may exist on a single line (and a line may
end with a positional definition.
A key-values definition has the following form:
.Bd -filled -offset indent
[listen-addr:]service-spec {on|off}