1.\" $MirOS: src/usr.sbin/inetd/inetd.8,v 1.3 2006/03/18 19:55:08 tg Exp $ 2.\" $OpenBSD: inetd.8,v 1.29 2005/06/02 07:56:22 jmc Exp $ 3.\" Copyright (c) 1985, 1991 The Regents of the University of California. 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" from: @(#)inetd.8 6.7 (Berkeley) 3/16/91 31.\" 32.Dd March 16, 1991 33.Dt INETD 8 34.Os 35.Sh NAME 36.Nm inetd 37.Nd internet 38.Dq super-server 39.Sh SYNOPSIS 40.Nm inetd 41.Op Fl d 42.Op Fl R Ar rate 43.Op Ar configuration file 44.Sh DESCRIPTION 45.Nm inetd 46should be run at boot time by 47.Pa /etc/rc 48(see 49.Xr rc 8 ) . 50It then listens for connections on certain internet sockets. 51When a connection is found on one 52of its sockets, it decides what service the socket 53corresponds to, and invokes a program to service the request. 54After the program is 55finished, it continues to listen on the socket (except in some cases which 56will be described below). 57Essentially, 58.Nm inetd 59allows running one daemon to invoke several others, 60reducing load on the system. 61.Pp 62The options are as follows: 63.Bl -tag -width Ds 64.It Fl d 65Turns on debugging. 66.It Fl R Ar rate 67Specify the maximum number of times a service can be invoked 68in one minute; the default is 256. 69.El 70.Pp 71Upon execution, 72.Nm inetd 73reads its configuration information from a configuration 74file which, by default, is 75.Pa /etc/inetd.conf . 76There must be an entry for each field of the configuration 77file, with entries for each field separated by a tab or 78a space. 79Comments are denoted by a 80.Dq # 81at the beginning 82of a line. 83The fields of the configuration file are as follows: 84.Bd -unfilled -offset indent 85service name 86socket type 87protocol 88wait/nowait[.max] 89user[.group] or user[:group] 90server program 91server program arguments 92.Ed 93.Pp 94To specify a Sun-RPC 95based service, the entry would contain these fields. 96.Bd -unfilled -offset indent 97service name/version 98socket type 99rpc/protocol 100wait/nowait[.max] 101user[.group] or user[:group] 102server program 103server program arguments 104.Ed 105.Pp 106For internet services, the first field of the line may also have a host 107address specifier prefixed to it, separated from the service name by a 108colon. 109If this is done, the string before the colon in the first field 110indicates what local address 111.Nm 112should use when listening for that service. 113Multiple local addresses 114can be specified on the same line, separated by commas. 115Numeric IP 116addresses in dotted-quad notation can be used as well as symbolic 117hostnames. 118Symbolic hostnames are looked up using 119.Fn gethostbyname . 120If a hostname has multiple address mappings, inetd creates a socket 121to listen on each address. 122.Pp 123The single character 124.Dq \&* 125indicates 126.Dv INADDR_ANY , 127meaning 128.Dq all local addresses . 129To avoid repeating an address that occurs frequently, a line with a 130host address specifier and colon, but no further fields, causes the 131host address specifier to be remembered and used for all further lines 132with no explicit host specifier (until another such line or the end of 133the file). 134A line 135.Dl *: 136is implicitly provided at the top of the file; thus, traditional 137configuration files (which have no host address specifiers) will be 138interpreted in the traditional manner, with all services listened for 139on all local addresses. 140If the protocol is 141.Dq unix , 142this value is ignored. 143.Pp 144The 145.Em service name 146entry is the name of a valid service in 147the file 148.Pa /etc/services . 149For 150.Dq internal 151services (discussed below), the service 152name 153.Em must 154be the official name of the service (that is, the first entry in 155.Pa /etc/services ) . 156When used to specify a Sun-RPC 157based service, this field is a valid RPC service name in 158the file 159.Pa /etc/rpc . 160The part on the right of the 161.Dq / 162is the RPC version number. 163This can simply be a single numeric argument or a range of versions. 164A range is bounded by the low version to the high version - 165.Dq rusers/1-3 . 166For 167.Ux 168domain sockets this field specifies the path name of the socket. 169.Pp 170The 171.Em socket type 172should be one of 173.Dq stream , 174.Dq dgram , 175.Dq raw , 176.Dq rdm , 177or 178.Dq seqpacket , 179depending on whether the socket is a stream, datagram, raw, 180reliably delivered message, or sequenced packet socket. 181.Pp 182The 183.Em protocol 184must be a valid protocol as given in 185.Pa /etc/protocols . 186Examples might be 187.Dq tcp 188or 189.Dq udp . 190RPC based services are specified with the 191.Dq rpc/tcp 192or 193.Dq rpc/udp 194service type. 195.Dq tcp 196and 197.Dq udp 198will be recognized as 199.Dq TCP or UDP over default IP version . 200This is currently IPv4, but in the future it will be IPv6. 201If you need to specify IPv4 or IPv6 explicitly, use something like 202.Dq tcp4 203or 204.Dq udp6 . 205A 206.Em protocol 207of 208.Dq unix 209is used to specify a socket in the 210.Ux 211domain. 212.Pp 213The 214.Em wait/nowait 215entry is used to tell 216.Nm 217if it should wait for the server program to return, 218or continue processing connections on the socket. 219If a datagram server connects 220to its peer, freeing the socket so 221.Nm inetd 222can receive further messages on the socket, it is said to be 223a 224.Dq multi-threaded 225server, and should use the 226.Dq nowait 227entry. 228For datagram servers which process all incoming datagrams 229on a socket and eventually time out, the server is said to be 230.Dq single-threaded 231and should use a 232.Dq wait 233entry. 234.Xr comsat 8 235.Pq Xr biff 1 236and 237.Xr talkd 8 238are both examples of the latter type of 239datagram server. 240.Xr tftpd 8 241is an exception; it is a datagram server that establishes pseudo-connections. 242It must be listed as 243.Dq wait 244in order to avoid a race; 245the server reads the first packet, creates a new socket, 246and then forks and exits to allow 247.Nm inetd 248to check for new service requests to spawn new servers. 249The optional 250.Dq max 251suffix (separated from 252.Dq wait 253or 254.Dq nowait 255by a dot) specifies the maximum number of server instances that may be 256spawned from 257.Nm inetd 258within an interval of 60 seconds. 259When omitted, 260.Dq max 261defaults to 256. 262.Pp 263Stream servers are usually marked as 264.Dq nowait 265but if a single server process is to handle multiple connections, it may be 266marked as 267.Dq wait . 268The master socket will then be passed as fd 0 to the server, which will then 269need to accept the incoming connection. 270The server should eventually time 271out and exit when no more connections are active. 272.Nm 273will continue to 274listen on the master socket for connections, so the server should not close 275it when it exits. 276.Pp 277The 278.Em user 279entry should contain the user name of the user as whom the server 280should run. 281This allows for servers to be given less permission 282than root. 283An optional group name can be specified by appending a dot to 284the user name followed by the group name. 285This allows for servers to run with 286a different (primary) group ID than specified in the password file. 287If a group 288is specified and user is not root, the supplementary groups associated with 289that user will still be set. 290.Pp 291The 292.Em server program 293entry should contain the pathname of the program which is to be 294executed by 295.Nm inetd 296when a request is found on its socket. 297If 298.Nm inetd 299provides this service internally, this entry should 300be 301.Dq internal . 302.Pp 303The 304.Em server program arguments 305should be just as arguments 306normally are, starting with argv[0], which is the name of 307the program. 308If the service is provided internally, the word 309.Dq internal 310should take the place of this entry. 311.Pp 312.Nm inetd 313provides several 314.Dq trivial 315services internally by use of routines within itself. 316These services are 317.Dq echo , 318.Dq discard , 319.Dq chargen 320(character generator), 321.Dq daytime 322(human readable time), and 323.Dq time 324(machine readable time, 325in the form of the number of seconds since midnight, January 3261, 1900). 327All of these services are TCP based. 328For details of these services, consult the appropriate 329.Tn RFC 330from the Network Information Center. 331.Pp 332.Nm inetd 333rereads its configuration file when it receives a hangup signal, 334.Dv SIGHUP . 335Services may be added, deleted or modified when the configuration file 336is reread. 337.Nm inetd 338creates a file 339.Em /var/run/inetd.pid 340that contains its process identifier. 341.Ss IPv6 TCP/UDP behavior 342If you wish to run a server for IPv4 and IPv6 traffic, 343you'll need to run two separate processes for the same server program, 344specified as two separate lines in 345.Pa inetd.conf , 346for 347.Dq tcp4 348and 349.Dq tcp6 . 350.Pp 351Under various combinations of IPv4/v6 daemon settings, 352.Nm 353will behave as follows: 354.Bl -bullet -compact 355.It 356If you have only one server on 357.Dq tcp4 , 358IPv4 traffic will be routed to the server. 359IPv6 traffic will not be accepted. 360.It 361If you have two servers on 362.Dq tcp4 363and 364.Dq tcp6 , 365IPv4 traffic will be routed to the server on 366.Dq tcp4 , 367and IPv6 traffic will go to server on 368.Dq tcp6 . 369.It 370If you have only one server on 371.Dq tcp6 , 372only IPv6 traffic will be routed to the server. 373.El 374.Sh ENVIRONMENT 375.Nm 376tries to set the following DJB-compatible environment variables: 377.Bl -tag -width TCPREMOTEPORT 378.It TCPREMOTEIP 379Contains the IPv4 address of the peer in dotted-decimal format, 380or, as an extension to the DJB specification, the protocol address 381in the format returned by 382.Xr getnameinfo 3 383with the 384.Dv NI_NUMERICHOST 385option set. 386.It TCPREMOTEPORT 387Contains the port of the peer (in decimal). 388.El 389.Sh SEE ALSO 390.Xr comsat 8 , 391.Xr fingerd 8 , 392.Xr ftp-proxy 8 , 393.Xr ftpd 8 , 394.Xr identd 8 , 395.Xr rshd 8 , 396.Xr talkd 8 , 397.Xr tftpd 8 398.Sh HISTORY 399The 400.Nm 401command appeared in 402.Bx 4.3 . 403Support for Sun-RPC 404based services is modelled after that 405provided by SunOS 4.1. 406IPv6 support was added by the KAME project in 1999. 407DJB compatible environment variables were added in 408.Mx 9 . 409.Sh BUGS 410Host address specifiers, while they make conceptual sense for RPC 411services, do not work entirely correctly. 412This is largely because the 413portmapper interface does not provide a way to register different ports 414for the same service on different local addresses. 415Provided you never 416have more than one entry for a given RPC service, everything should 417work correctly. 418(Note that default host address specifiers do apply to 419RPC lines with no explicit specifier.) 420.Pp 421.Dq rpc 422or 423.Dq tcpmux 424on IPv6 is not tested enough. 425Kerberos support on IPv6 is not tested. 426