[To Lecture Notes Index]
San Diego State University -- This page last updated March 8, 1995
Starts servers on demand
Started from /etc/rc
Configuration file in /etc/inetd.conf
Other information from /etc/services
service-name port/protocol aliases
example (from sciences.sdsu.edu):
service-name socket-type protocol wait-status uid server-program server-arguments
example entry for fortune server on sciences.sdsu.edu:
fortune stream tcp nowait nobody\ /usr/local/bin/fortune.real \ fortune
ofortune stream tcp nowait \ nobody /usr/local/bin/fortune.real\ fortune -o
% telnet sciences 6665
Connected to sciences.
Escape character is '^]'.
Just because your doctor has a name for your condition doesn't mean he knows what it is.
Connection closed by foreign host.
The /usr/etc/mconnect command is similar to telnet, but I/O can be redirected from it.
#!/bin/sh if [ X$1 = X ]; then /usr/etc/mconnect -p 6665 sciences | /usr/ucb/tail + 3 else /usr/etc/mconnect -p 6666 sciences | /usr/ucb/tail + 3 fi
% fortune foo
The connected socket is assigned to both stdin, stdout, and stderr.
Use the getpeername() call on fd 0 to find the peer's name.
Normally a server has an option which allows it to be started from inetd.
Is there a way to automatically tell if a server is started from inetd or not?
inetd itself provides a number of simple TCP services:
Server security without modification to the server.
Sample /etc/inetd.conf entry:
telnet stream tcp nowait root \ /usr/etc/tcpd telnetd
inetd runs tcpd instead of telnetd
/usr/etc/tcpd uses the following Files:
Format of /etc/hosts.allow and /etc/hosts.deny:
daemon-list : client-list : [: shell-command ]
For example if we want to block all incoming telnet sessions from off-campus we do the following in /etc/hosts.allow:
telnetd : 130.191. :
telnetd : ALL :
tcpwrappers can use the IDENT protocol to check for
Most servers need lots of information to work properly:
This information doesn't change from server start to server start
Assignment of values for parameters:
Helpful guidelines for configuration file design:
Examples of good configuration file formats
Apple Macintosh Resources.
You have to use either Apple's 'resedit' or the application has to have its own interface.
Prime example of bad use of this is Mac Eudora (old)
The modem dialup script is entered using Resedit.
Allow for comments:
Use name/value pairs to set options:
Consistency is important!
database = /usr/local/lib/database
Configuration file location is only one option
Server needs a standard interface to the configuration once it has read it.
If using consistent name/value pairs, a Dictionary or symbol table is a good interface.
The server can preload the dictionary with its own compiled defaults and then overwrite these with the configuration file.
This code should be reusable.