1f36b4977Skarels.\" Copyright (c) 1985, 1991, 1993, 1994 2d2182bd8Sbostic.\" The Regents of the University of California. All rights reserved. 38397d955Smckusick.\" 46c8d65cbStrent.\" %sccs.include.redist.man% 592fb32c4Sbostic.\" 6*cdba42a1Sah.\" @(#)inetd.8 8.4 (Berkeley) 06/01/94 78397d955Smckusick.\" 813251ec2Scael.Dd 913251ec2Scael.Dt INETD 8 1015083ca3Sandrew.Os BSD 4.4 1113251ec2Scael.Sh NAME 1213251ec2Scael.Nm inetd 1313251ec2Scael.Nd internet 1413251ec2Scael.Dq super-server 1513251ec2Scael.Sh SYNOPSIS 1613251ec2Scael.Nm inetd 1713251ec2Scael.Op Fl d 1815083ca3Sandrew.Op Fl R Ar rate 1913251ec2Scael.Op Ar configuration file 2013251ec2Scael.Sh DESCRIPTION 21f36b4977SkarelsThe 22f36b4977Skarels.Nm inetd 23f36b4977Skarelsprogram 248397d955Smckusickshould be run at boot time by 25f36b4977Skarels.Pa /etc/rc 2613251ec2Scael(see 2713251ec2Scael.Xr rc 8 ) . 288397d955SmckusickIt then listens for connections on certain 298397d955Smckusickinternet sockets. When a connection is found on one 308397d955Smckusickof its sockets, it decides what service the socket 318397d955Smckusickcorresponds to, and invokes a program to service the request. 32f36b4977SkarelsThe server program is invoked with the service socket 33f36b4977Skarelsas its standard input, output and error descriptors. 348397d955SmckusickAfter the program is 35f36b4977Skarelsfinished, 36f36b4977Skarels.Nm inetd 37f36b4977Skarelscontinues to listen on the socket (except in some cases which 388397d955Smckusickwill be described below). Essentially, 3913251ec2Scael.Nm inetd 408397d955Smckusickallows running one daemon to invoke several others, 418397d955Smckusickreducing load on the system. 4213251ec2Scael.Pp 4315083ca3SandrewThe options available for 4413251ec2Scael.Nm inetd: 4513251ec2Scael.Bl -tag -width Ds 4613251ec2Scael.It Fl d 4713251ec2ScaelTurns on debugging. 4815083ca3Sandrew.It Fl R Ar rate 4915083ca3SandrewSpecifies the maximum number of times a service can be invoked 5015083ca3Sandrewin one minute; the default is 1000. 5113251ec2Scael.El 5213251ec2Scael.Pp 538397d955SmckusickUpon execution, 5413251ec2Scael.Nm inetd 558397d955Smckusickreads its configuration information from a configuration 568397d955Smckusickfile which, by default, is 5713251ec2Scael.Pa /etc/inetd.conf . 588397d955SmckusickThere must be an entry for each field of the configuration 598397d955Smckusickfile, with entries for each field separated by a tab or 608397d955Smckusicka space. Comments are denoted by a ``#'' at the beginning 618397d955Smckusickof a line. There must be an entry for each field. The 628397d955Smckusickfields of the configuration file are as follows: 6313251ec2Scael.Pp 6413251ec2Scael.Bd -unfilled -offset indent -compact 658397d955Smckusickservice name 668397d955Smckusicksocket type 678397d955Smckusickprotocol 688397d955Smckusickwait/nowait 698397d955Smckusickuser 708397d955Smckusickserver program 718397d955Smckusickserver program arguments 7213251ec2Scael.Ed 7313251ec2Scael.Pp 7415083ca3SandrewThere are two types of services that 7515083ca3Sandrew.Nm inetd 7615083ca3Sandrewcan start: standard and TCPMUX. 7715083ca3SandrewA standard service has a well-known port assigned to it; 7815083ca3Sandrewit may be a service that implements an official Internet standard or is a 7915083ca3SandrewBSD-specific service. 8015083ca3SandrewAs described in 8115083ca3Sandrew.Tn RFC 1078 , 8215083ca3SandrewTCPMUX services are nonstandard services that do not have a 8315083ca3Sandrewwell-known port assigned to them. 8415083ca3SandrewThey are invoked from 8515083ca3Sandrew.Nm inetd 8615083ca3Sandrewwhen a program connects to the 8715083ca3Sandrew.Dq tcpmux 8815083ca3Sandrewwell-known port and specifies 8915083ca3Sandrewthe service name. 9015083ca3SandrewThis feature is useful for adding locally-developed servers. 9115083ca3Sandrew.Pp 928397d955SmckusickThe 9313251ec2Scael.Em service-name 948397d955Smckusickentry is the name of a valid service in 958397d955Smckusickthe file 9613251ec2Scael.Pa /etc/services . 9713251ec2ScaelFor 9813251ec2Scael.Dq internal 9913251ec2Scaelservices (discussed below), the service 1008397d955Smckusickname 10113251ec2Scael.Em must 10252f899a2Skarelsbe the official name of the service (that is, the first entry in 10313251ec2Scael.Pa /etc/services ) . 10415083ca3SandrewFor TCPMUX services, the value of the 10515083ca3Sandrew.Em service-name 10615083ca3Sandrewfield consists of the string 10715083ca3Sandrew.Dq tcpmux 10815083ca3Sandrewfollowed by a slash and the 10915083ca3Sandrewlocally-chosen service name. 11015083ca3SandrewThe service names listed in 11115083ca3Sandrew.Pa /etc/services 11215083ca3Sandrewand the name 11315083ca3Sandrew.Dq help 11415083ca3Sandreware reserved. 11515083ca3SandrewTry to choose unique names for your TCPMUX services by prefixing them with 11615083ca3Sandrewyour organization's name and suffixing them with a version number. 11713251ec2Scael.Pp 1188397d955SmckusickThe 11913251ec2Scael.Em socket-type 12013251ec2Scaelshould be one of 12113251ec2Scael.Dq stream , 12213251ec2Scael.Dq dgram , 12313251ec2Scael.Dq raw , 12413251ec2Scael.Dq rdm , 12513251ec2Scaelor 12613251ec2Scael.Dq seqpacket , 1278397d955Smckusickdepending on whether the socket is a stream, datagram, raw, 1288397d955Smckusickreliably delivered message, or sequenced packet socket. 12915083ca3SandrewTCPMUX services must use 13015083ca3Sandrew.Dq stream . 13113251ec2Scael.Pp 1328397d955SmckusickThe 13313251ec2Scael.Em protocol 1348397d955Smckusickmust be a valid protocol as given in 13513251ec2Scael.Pa /etc/protocols . 13613251ec2ScaelExamples might be 13713251ec2Scael.Dq tcp 13813251ec2Scaelor 13913251ec2Scael.Dq udp . 14015083ca3SandrewTCPMUX services must use 14115083ca3Sandrew.Dq tcp . 14213251ec2Scael.Pp 1438397d955SmckusickThe 14413251ec2Scael.Em wait/nowait 145f36b4977Skarelsentry specifies whether the server that is invoked by inetd will take over 146f36b4977Skarelsthe socket associated with the service access point, and thus whether 147f36b4977Skarels.Nm inetd 148f36b4977Skarelsshould wait for the server to exit before listening for new service 149f36b4977Skarelsrequests. 150f36b4977SkarelsDatagram servers must use 151f36b4977Skarels.Dq wait , 152f36b4977Skarelsas they are always invoked with the original datagram socket bound 153f36b4977Skarelsto the specified service address. 154f36b4977SkarelsThese servers must read at least one datagram from the socket 155f36b4977Skarelsbefore exiting. 156f36b4977SkarelsIf a datagram server connects 1578397d955Smckusickto its peer, freeing the socket so 15813251ec2Scael.Nm inetd 1598397d955Smckusickcan received further messages on the socket, it is said to be 16013251ec2Scaela 16113251ec2Scael.Dq multi-threaded 162f36b4977Skarelsserver; 163f36b4977Skarelsit should read one datagram from the socket and create a new socket 164f36b4977Skarelsconnected to the peer. 165f36b4977SkarelsIt should fork, and the parent should then exit 166f36b4977Skarelsto allow 167f36b4977Skarels.Nm inetd 168f36b4977Skarelsto check for new service requests to spawn new servers. 169f36b4977SkarelsDatagram servers which process all incoming datagrams 170f36b4977Skarelson a socket and eventually time out are said to be 171f36b4977Skarels.Dq single-threaded . 172edc2ab72Smckusick.Xr Comsat 8 , 17313251ec2Scael.Pq Xr biff 1 17413251ec2Scaeland 17513251ec2Scael.Xr talkd 8 17613251ec2Scaelare both examples of the latter type of 1778397d955Smckusickdatagram server. 17813251ec2Scael.Xr Tftpd 8 179f36b4977Skarelsis an example of a multi-threaded datagram server. 180f36b4977Skarels.Pp 181f36b4977SkarelsServers using stream sockets generally are multi-threaded and 182f36b4977Skarelsuse the 183f36b4977Skarels.Dq nowait 184f36b4977Skarelsentry. 185f36b4977SkarelsConnection requests for these services are accepted by 186f36b4977Skarels.Nm inetd , 187f36b4977Skarelsand the server is given only the newly-accepted socket connected 188f36b4977Skarelsto a client of the service. 189f36b4977SkarelsMost stream-based services operate in this manner. 190f36b4977SkarelsStream-based servers that use 19113251ec2Scael.Dq wait 192f36b4977Skarelsare started with the listening service socket, and must accept 193f36b4977Skarelsat least one connection request before exiting. 194f36b4977SkarelsSuch a server would normally accept and process incoming connection 195f36b4977Skarelsrequests until a timeout. 19615083ca3SandrewTCPMUX services must use 19715083ca3Sandrew.Dq nowait . 19813251ec2Scael.Pp 1998397d955SmckusickThe 20013251ec2Scael.Em user 2018397d955Smckusickentry should contain the user name of the user as whom the server 2028397d955Smckusickshould run. This allows for servers to be given less permission 2038397d955Smckusickthan root. 20413251ec2Scael.Pp 2058397d955SmckusickThe 20613251ec2Scael.Em server-program 2078397d955Smckusickentry should contain the pathname of the program which is to be 2088397d955Smckusickexecuted by 20913251ec2Scael.Nm inetd 2108397d955Smckusickwhen a request is found on its socket. If 21113251ec2Scael.Nm inetd 2128397d955Smckusickprovides this service internally, this entry should 21313251ec2Scaelbe 21413251ec2Scael.Dq internal . 21513251ec2Scael.Pp 21613251ec2ScaelThe 21713251ec2Scael.Em server program arguments 21813251ec2Scaelshould be just as arguments 2198397d955Smckusicknormally are, starting with argv[0], which is the name of 2208397d955Smckusickthe program. If the service is provided internally, the 22113251ec2Scaelword 22213251ec2Scael.Dq internal 22313251ec2Scaelshould take the place of this entry. 22413251ec2Scael.Pp 225f36b4977SkarelsThe 226f36b4977Skarels.Nm inetd 227f36b4977Skarelsprogram 22813251ec2Scaelprovides several 22913251ec2Scael.Dq trivial 23013251ec2Scaelservices internally by use of 23113251ec2Scaelroutines within itself. These services are 23213251ec2Scael.Dq echo , 23313251ec2Scael.Dq discard , 23413251ec2Scael.Dq chargen 23513251ec2Scael(character generator), 23613251ec2Scael.Dq daytime 23713251ec2Scael(human readable time), and 23813251ec2Scael.Dq time 23913251ec2Scael(machine readable time, 2408397d955Smckusickin the form of the number of seconds since midnight, January 2418397d955Smckusick1, 1900). All of these services are tcp based. For 24213251ec2Scaeldetails of these services, consult the appropriate 24313251ec2Scael.Tn RFC 2448397d955Smckusickfrom the Network Information Center. 24513251ec2Scael.Pp 246f36b4977SkarelsThe 247f36b4977Skarels.Nm inetd 248f36b4977Skarelsprogram 24913251ec2Scaelrereads its configuration file when it receives a hangup signal, 25013251ec2Scael.Dv SIGHUP . 251b6e07f9cSkarelsServices may be added, deleted or modified when the configuration file 252b6e07f9cSkarelsis reread. 25315083ca3Sandrew.Sh TCPMUX 25415083ca3Sandrew.Pp 25515083ca3Sandrew.Tn RFC 1078 25615083ca3Sandrewdescribes the TCPMUX protocol: 25715083ca3Sandrew``A TCP client connects to a foreign host on TCP port 1. It sends the 25815083ca3Sandrewservice name followed by a carriage-return line-feed <CRLF>. The 25915083ca3Sandrewservice name is never case sensitive. The server replies with a 26015083ca3Sandrewsingle character indicating positive (+) or negative (\-) 26115083ca3Sandrewacknowledgment, immediately followed by an optional message of 26215083ca3Sandrewexplanation, terminated with a <CRLF>. If the reply was positive, 26315083ca3Sandrewthe selected protocol begins; otherwise the connection is closed.'' 26415083ca3SandrewThe program is passed the TCP connection as file descriptors 0 and 1. 26515083ca3Sandrew.Pp 26615083ca3SandrewIf the TCPMUX service name begins with a ``+'', 26715083ca3Sandrew.Nm inetd 26815083ca3Sandrewreturns the positive reply for the program. 26915083ca3SandrewThis allows you to invoke programs that use stdin/stdout 27015083ca3Sandrewwithout putting any special server code in them. 27115083ca3Sandrew.Pp 27215083ca3SandrewThe special service name 27315083ca3Sandrew.Dq help 27415083ca3Sandrewcauses 27515083ca3Sandrew.Nm inetd 27615083ca3Sandrewto list TCPMUX services in 27715083ca3Sandrew.Pa inetd.conf . 278*cdba42a1Sah.ne 1i 27915083ca3Sandrew.Sh "EXAMPLES" 28015083ca3Sandrew.Pp 28115083ca3SandrewHere are several example service entries for the various types of services: 28215083ca3Sandrew.Bd -literal 28315083ca3Sandrewftp stream tcp nowait root /usr/libexec/ftpd ftpd -l 28415083ca3Sandrewntalk dgram udp wait root /usr/libexec/ntalkd ntalkd 28515083ca3Sandrewtcpmux/+date stream tcp nowait guest /bin/date date 28615083ca3Sandrewtcpmux/phonebook stream tcp nowait guest /usr/local/bin/phonebook phonebook 28715083ca3Sandrew.Ed 28815083ca3Sandrew.Sh "ERROR MESSAGES" 289f36b4977SkarelsThe 290f36b4977Skarels.Nm inetd 291f36b4977Skarelsserver 29215083ca3Sandrewlogs error messages using 29315083ca3Sandrew.Xr syslog 3 . 29415083ca3SandrewImportant error messages and their explanations are: 29515083ca3Sandrew.Bd -literal 29615083ca3Sandrew\fIservice\fP/\fIprotocol\fP server failing (looping), service terminated. 29715083ca3Sandrew.Ed 29815083ca3SandrewThe number of requests for the specified service in the past minute 29915083ca3Sandrewexceeded the limit. The limit exists to prevent a broken program 30015083ca3Sandrewor a malicious user from swamping the system. 30115083ca3SandrewThis message may occur for several reasons: 30215083ca3Sandrew1) there are lots of hosts requesting the service within a short time period, 30315083ca3Sandrew2) a 'broken' client program is requesting the service too frequently, 30415083ca3Sandrew3) a malicious user is running a program to invoke the service in 30515083ca3Sandrewa 'denial of service' attack, or 30615083ca3Sandrew4) the invoked service program has an error that causes clients 30715083ca3Sandrewto retry quickly. 30815083ca3SandrewUse the 30915083ca3Sandrew.Op Fl R 31015083ca3Sandrewoption, 31115083ca3Sandrewas described above, to change the rate limit. 31215083ca3SandrewOnce the limit is reached, the service will be 31315083ca3Sandrewreenabled automatically in 10 minutes. 31415083ca3Sandrew.sp 31515083ca3Sandrew.Bd -literal 31615083ca3Sandrew\fIservice\fP/\fIprotocol\fP: No such user '\fIuser\fP', service ignored 31715083ca3Sandrew\fIservice\fP/\fIprotocol\fP: getpwnam: \fIuser\fP: No such user 31815083ca3Sandrew.Ed 31915083ca3SandrewNo entry for 32015083ca3Sandrew.Em user 32115083ca3Sandrewexists in the 32215083ca3Sandrew.Pa passwd 32315083ca3Sandrewfile. The first message 32415083ca3Sandrewoccurs when 32515083ca3Sandrew.Nm inetd 32615083ca3Sandrew(re)reads the configuration file. The second message occurs when the 32715083ca3Sandrewservice is invoked. 32815083ca3Sandrew.sp 32915083ca3Sandrew.Bd -literal 33015083ca3Sandrew\fIservice\fP: can't set uid \fInumber\fP 33115083ca3Sandrew\fIservice\fP: can't set gid \fInumber\fP 33215083ca3Sandrew.Ed 33315083ca3SandrewThe user or group ID for the entry's 33415083ca3Sandrew.Em user 33515083ca3Sandrewis invalid. 33613251ec2Scael.Sh SEE ALSO 33713251ec2Scael.Xr comsat 8 , 33813251ec2Scael.Xr fingerd 8 , 33913251ec2Scael.Xr ftpd 8 , 34013251ec2Scael.Xr rexecd 8 , 34113251ec2Scael.Xr rlogind 8 , 34213251ec2Scael.Xr rshd 8 , 34313251ec2Scael.Xr telnetd 8 , 34413251ec2Scael.Xr tftpd 8 34513251ec2Scael.Sh HISTORY 34613251ec2ScaelThe 34713251ec2Scael.Nm 34813251ec2Scaelcommand appeared in 34913251ec2Scael.Bx 4.3 . 35015083ca3SandrewTCPMUX is based on code and documentation by Mark Lottor. 351