166779Skarels.\" Copyright (c) 1985, 1991, 1993, 1994 261828Sbostic.\" The Regents of the University of California. All rights reserved. 319031Smckusick.\" 443827Strent.\" %sccs.include.redist.man% 519031Smckusick.\" 6*67323Sah.\" @(#)inetd.8 8.4 (Berkeley) 06/01/94 735565Sbostic.\" 847469Scael.Dd 947469Scael.Dt INETD 8 1057768Sandrew.Os BSD 4.4 1147469Scael.Sh NAME 1247469Scael.Nm inetd 1347469Scael.Nd internet 1447469Scael.Dq super-server 1547469Scael.Sh SYNOPSIS 1647469Scael.Nm inetd 1747469Scael.Op Fl d 1857768Sandrew.Op Fl R Ar rate 1947469Scael.Op Ar configuration file 2047469Scael.Sh DESCRIPTION 2166779SkarelsThe 2266779Skarels.Nm inetd 2366779Skarelsprogram 2419031Smckusickshould be run at boot time by 2566779Skarels.Pa /etc/rc 2647469Scael(see 2747469Scael.Xr rc 8 ) . 2819031SmckusickIt then listens for connections on certain 2919031Smckusickinternet sockets. When a connection is found on one 3019031Smckusickof its sockets, it decides what service the socket 3119031Smckusickcorresponds to, and invokes a program to service the request. 3266779SkarelsThe server program is invoked with the service socket 3366779Skarelsas its standard input, output and error descriptors. 3419031SmckusickAfter the program is 3566779Skarelsfinished, 3666779Skarels.Nm inetd 3766779Skarelscontinues to listen on the socket (except in some cases which 3819031Smckusickwill be described below). Essentially, 3947469Scael.Nm inetd 4019031Smckusickallows running one daemon to invoke several others, 4119031Smckusickreducing load on the system. 4247469Scael.Pp 4357768SandrewThe options available for 4447469Scael.Nm inetd: 4547469Scael.Bl -tag -width Ds 4647469Scael.It Fl d 4747469ScaelTurns on debugging. 4857768Sandrew.It Fl R Ar rate 4957768SandrewSpecifies the maximum number of times a service can be invoked 5057768Sandrewin one minute; the default is 1000. 5147469Scael.El 5247469Scael.Pp 5319031SmckusickUpon execution, 5447469Scael.Nm inetd 5519031Smckusickreads its configuration information from a configuration 5619031Smckusickfile which, by default, is 5747469Scael.Pa /etc/inetd.conf . 5819031SmckusickThere must be an entry for each field of the configuration 5919031Smckusickfile, with entries for each field separated by a tab or 6019031Smckusicka space. Comments are denoted by a ``#'' at the beginning 6119031Smckusickof a line. There must be an entry for each field. The 6219031Smckusickfields of the configuration file are as follows: 6347469Scael.Pp 6447469Scael.Bd -unfilled -offset indent -compact 6547469Scaelservice name 6647469Scaelsocket type 6747469Scaelprotocol 6847469Scaelwait/nowait 6947469Scaeluser 7047469Scaelserver program 7147469Scaelserver program arguments 7247469Scael.Ed 7347469Scael.Pp 7457768SandrewThere are two types of services that 7557768Sandrew.Nm inetd 7657768Sandrewcan start: standard and TCPMUX. 7757768SandrewA standard service has a well-known port assigned to it; 7857768Sandrewit may be a service that implements an official Internet standard or is a 7957768SandrewBSD-specific service. 8057768SandrewAs described in 8157768Sandrew.Tn RFC 1078 , 8257768SandrewTCPMUX services are nonstandard services that do not have a 8357768Sandrewwell-known port assigned to them. 8457768SandrewThey are invoked from 8557768Sandrew.Nm inetd 8657768Sandrewwhen a program connects to the 8757768Sandrew.Dq tcpmux 8857768Sandrewwell-known port and specifies 8957768Sandrewthe service name. 9057768SandrewThis feature is useful for adding locally-developed servers. 9157768Sandrew.Pp 9219031SmckusickThe 9347469Scael.Em service-name 9419031Smckusickentry is the name of a valid service in 9519031Smckusickthe file 9647469Scael.Pa /etc/services . 9747469ScaelFor 9847469Scael.Dq internal 9947469Scaelservices (discussed below), the service 10019031Smckusickname 10147469Scael.Em must 10228560Skarelsbe the official name of the service (that is, the first entry in 10347469Scael.Pa /etc/services ) . 10457768SandrewFor TCPMUX services, the value of the 10557768Sandrew.Em service-name 10657768Sandrewfield consists of the string 10757768Sandrew.Dq tcpmux 10857768Sandrewfollowed by a slash and the 10957768Sandrewlocally-chosen service name. 11057768SandrewThe service names listed in 11157768Sandrew.Pa /etc/services 11257768Sandrewand the name 11357768Sandrew.Dq help 11457768Sandreware reserved. 11557768SandrewTry to choose unique names for your TCPMUX services by prefixing them with 11657768Sandrewyour organization's name and suffixing them with a version number. 11747469Scael.Pp 11819031SmckusickThe 11947469Scael.Em socket-type 12047469Scaelshould be one of 12147469Scael.Dq stream , 12247469Scael.Dq dgram , 12347469Scael.Dq raw , 12447469Scael.Dq rdm , 12547469Scaelor 12647469Scael.Dq seqpacket , 12719031Smckusickdepending on whether the socket is a stream, datagram, raw, 12819031Smckusickreliably delivered message, or sequenced packet socket. 12957768SandrewTCPMUX services must use 13057768Sandrew.Dq stream . 13147469Scael.Pp 13219031SmckusickThe 13347469Scael.Em protocol 13419031Smckusickmust be a valid protocol as given in 13547469Scael.Pa /etc/protocols . 13647469ScaelExamples might be 13747469Scael.Dq tcp 13847469Scaelor 13947469Scael.Dq udp . 14057768SandrewTCPMUX services must use 14157768Sandrew.Dq tcp . 14247469Scael.Pp 14319031SmckusickThe 14447469Scael.Em wait/nowait 14566779Skarelsentry specifies whether the server that is invoked by inetd will take over 14666779Skarelsthe socket associated with the service access point, and thus whether 14766779Skarels.Nm inetd 14866779Skarelsshould wait for the server to exit before listening for new service 14966779Skarelsrequests. 15066779SkarelsDatagram servers must use 15166779Skarels.Dq wait , 15266779Skarelsas they are always invoked with the original datagram socket bound 15366779Skarelsto the specified service address. 15466779SkarelsThese servers must read at least one datagram from the socket 15566779Skarelsbefore exiting. 15666779SkarelsIf a datagram server connects 15719031Smckusickto its peer, freeing the socket so 15847469Scael.Nm inetd 15919031Smckusickcan received further messages on the socket, it is said to be 16047469Scaela 16147469Scael.Dq multi-threaded 16266779Skarelsserver; 16366779Skarelsit should read one datagram from the socket and create a new socket 16466779Skarelsconnected to the peer. 16566779SkarelsIt should fork, and the parent should then exit 16666779Skarelsto allow 16766779Skarels.Nm inetd 16866779Skarelsto check for new service requests to spawn new servers. 16966779SkarelsDatagram servers which process all incoming datagrams 17066779Skarelson a socket and eventually time out are said to be 17166779Skarels.Dq single-threaded . 17265104Smckusick.Xr Comsat 8 , 17347469Scael.Pq Xr biff 1 17447469Scaeland 17547469Scael.Xr talkd 8 17647469Scaelare both examples of the latter type of 17719031Smckusickdatagram server. 17847469Scael.Xr Tftpd 8 17966779Skarelsis an example of a multi-threaded datagram server. 18066779Skarels.Pp 18166779SkarelsServers using stream sockets generally are multi-threaded and 18266779Skarelsuse the 18366779Skarels.Dq nowait 18466779Skarelsentry. 18566779SkarelsConnection requests for these services are accepted by 18666779Skarels.Nm inetd , 18766779Skarelsand the server is given only the newly-accepted socket connected 18866779Skarelsto a client of the service. 18966779SkarelsMost stream-based services operate in this manner. 19066779SkarelsStream-based servers that use 19147469Scael.Dq wait 19266779Skarelsare started with the listening service socket, and must accept 19366779Skarelsat least one connection request before exiting. 19466779SkarelsSuch a server would normally accept and process incoming connection 19566779Skarelsrequests until a timeout. 19657768SandrewTCPMUX services must use 19757768Sandrew.Dq nowait . 19847469Scael.Pp 19919031SmckusickThe 20047469Scael.Em user 20119031Smckusickentry should contain the user name of the user as whom the server 20219031Smckusickshould run. This allows for servers to be given less permission 20319031Smckusickthan root. 20447469Scael.Pp 20519031SmckusickThe 20647469Scael.Em server-program 20719031Smckusickentry should contain the pathname of the program which is to be 20819031Smckusickexecuted by 20947469Scael.Nm inetd 21019031Smckusickwhen a request is found on its socket. If 21147469Scael.Nm inetd 21219031Smckusickprovides this service internally, this entry should 21347469Scaelbe 21447469Scael.Dq internal . 21547469Scael.Pp 21647469ScaelThe 21747469Scael.Em server program arguments 21847469Scaelshould be just as arguments 21919031Smckusicknormally are, starting with argv[0], which is the name of 22019031Smckusickthe program. If the service is provided internally, the 22147469Scaelword 22247469Scael.Dq internal 22347469Scaelshould take the place of this entry. 22447469Scael.Pp 22566779SkarelsThe 22666779Skarels.Nm inetd 22766779Skarelsprogram 22847469Scaelprovides several 22947469Scael.Dq trivial 23047469Scaelservices internally by use of 23147469Scaelroutines within itself. These services are 23247469Scael.Dq echo , 23347469Scael.Dq discard , 23447469Scael.Dq chargen 23547469Scael(character generator), 23647469Scael.Dq daytime 23747469Scael(human readable time), and 23847469Scael.Dq time 23947469Scael(machine readable time, 24019031Smckusickin the form of the number of seconds since midnight, January 24119031Smckusick1, 1900). All of these services are tcp based. For 24247469Scaeldetails of these services, consult the appropriate 24347469Scael.Tn RFC 24419031Smckusickfrom the Network Information Center. 24547469Scael.Pp 24666779SkarelsThe 24766779Skarels.Nm inetd 24866779Skarelsprogram 24947469Scaelrereads its configuration file when it receives a hangup signal, 25047469Scael.Dv SIGHUP . 25128753SkarelsServices may be added, deleted or modified when the configuration file 25228753Skarelsis reread. 25357768Sandrew.Sh TCPMUX 25457768Sandrew.Pp 25557768Sandrew.Tn RFC 1078 25657768Sandrewdescribes the TCPMUX protocol: 25757768Sandrew``A TCP client connects to a foreign host on TCP port 1. It sends the 25857768Sandrewservice name followed by a carriage-return line-feed <CRLF>. The 25957768Sandrewservice name is never case sensitive. The server replies with a 26057768Sandrewsingle character indicating positive (+) or negative (\-) 26157768Sandrewacknowledgment, immediately followed by an optional message of 26257768Sandrewexplanation, terminated with a <CRLF>. If the reply was positive, 26357768Sandrewthe selected protocol begins; otherwise the connection is closed.'' 26457768SandrewThe program is passed the TCP connection as file descriptors 0 and 1. 26557768Sandrew.Pp 26657768SandrewIf the TCPMUX service name begins with a ``+'', 26757768Sandrew.Nm inetd 26857768Sandrewreturns the positive reply for the program. 26957768SandrewThis allows you to invoke programs that use stdin/stdout 27057768Sandrewwithout putting any special server code in them. 27157768Sandrew.Pp 27257768SandrewThe special service name 27357768Sandrew.Dq help 27457768Sandrewcauses 27557768Sandrew.Nm inetd 27657768Sandrewto list TCPMUX services in 27757768Sandrew.Pa inetd.conf . 278*67323Sah.ne 1i 27957768Sandrew.Sh "EXAMPLES" 28057768Sandrew.Pp 28157768SandrewHere are several example service entries for the various types of services: 28257768Sandrew.Bd -literal 28357768Sandrewftp stream tcp nowait root /usr/libexec/ftpd ftpd -l 28457768Sandrewntalk dgram udp wait root /usr/libexec/ntalkd ntalkd 28557768Sandrewtcpmux/+date stream tcp nowait guest /bin/date date 28657768Sandrewtcpmux/phonebook stream tcp nowait guest /usr/local/bin/phonebook phonebook 28757768Sandrew.Ed 28857768Sandrew.Sh "ERROR MESSAGES" 28966779SkarelsThe 29066779Skarels.Nm inetd 29166779Skarelsserver 29257768Sandrewlogs error messages using 29357768Sandrew.Xr syslog 3 . 29457768SandrewImportant error messages and their explanations are: 29557768Sandrew.Bd -literal 29657768Sandrew\fIservice\fP/\fIprotocol\fP server failing (looping), service terminated. 29757768Sandrew.Ed 29857768SandrewThe number of requests for the specified service in the past minute 29957768Sandrewexceeded the limit. The limit exists to prevent a broken program 30057768Sandrewor a malicious user from swamping the system. 30157768SandrewThis message may occur for several reasons: 30257768Sandrew1) there are lots of hosts requesting the service within a short time period, 30357768Sandrew2) a 'broken' client program is requesting the service too frequently, 30457768Sandrew3) a malicious user is running a program to invoke the service in 30557768Sandrewa 'denial of service' attack, or 30657768Sandrew4) the invoked service program has an error that causes clients 30757768Sandrewto retry quickly. 30857768SandrewUse the 30957768Sandrew.Op Fl R 31057768Sandrewoption, 31157768Sandrewas described above, to change the rate limit. 31257768SandrewOnce the limit is reached, the service will be 31357768Sandrewreenabled automatically in 10 minutes. 31457768Sandrew.sp 31557768Sandrew.Bd -literal 31657768Sandrew\fIservice\fP/\fIprotocol\fP: No such user '\fIuser\fP', service ignored 31757768Sandrew\fIservice\fP/\fIprotocol\fP: getpwnam: \fIuser\fP: No such user 31857768Sandrew.Ed 31957768SandrewNo entry for 32057768Sandrew.Em user 32157768Sandrewexists in the 32257768Sandrew.Pa passwd 32357768Sandrewfile. The first message 32457768Sandrewoccurs when 32557768Sandrew.Nm inetd 32657768Sandrew(re)reads the configuration file. The second message occurs when the 32757768Sandrewservice is invoked. 32857768Sandrew.sp 32957768Sandrew.Bd -literal 33057768Sandrew\fIservice\fP: can't set uid \fInumber\fP 33157768Sandrew\fIservice\fP: can't set gid \fInumber\fP 33257768Sandrew.Ed 33357768SandrewThe user or group ID for the entry's 33457768Sandrew.Em user 33557768Sandrewis invalid. 33647469Scael.Sh SEE ALSO 33747469Scael.Xr comsat 8 , 33847469Scael.Xr fingerd 8 , 33947469Scael.Xr ftpd 8 , 34047469Scael.Xr rexecd 8 , 34147469Scael.Xr rlogind 8 , 34247469Scael.Xr rshd 8 , 34347469Scael.Xr telnetd 8 , 34447469Scael.Xr tftpd 8 34547469Scael.Sh HISTORY 34647469ScaelThe 34747469Scael.Nm 34847469Scaelcommand appeared in 34947469Scael.Bx 4.3 . 35057768SandrewTCPMUX is based on code and documentation by Mark Lottor. 351