A Server Run Under Inetd
Tom Kelliher, CS 318
Apr. 14, 2000
We'll begin working with the PCs Monday.
For Monday: From the material not discussed thus far, Chapters 23 and
onwards, e-mail me one topic you'd like to discuss in class.
Hacker's IP list.
- Well-known services.
- notelnet: a server run from inetd.
- For clients to contact servers, servers must listen on specific
Or, there must be a broker.
- Who decides what port?
- Is there a list? Yes, /etc/services database. Note:
- Service name, port protocol.
- Some services support multiple protocols.
- System calls to do the mappings: getservbyport(),
- A system need not provide all services.
- Internet ``Super Server.''
- Configured to listen on a set of ports, as a server. When connection
received, fork appropriate server and hand-off connection.
- Configuration file: /etc/inetd.conf.
Specifies ports to listen on by service name. Also specifies:
- Type of connection (stream or datagram).
- Iterative (wait) or concurrent (nowait).
- What user to run server as.
- How to run server. What's tcpd? What's internal?
- The big picture of interaction with a service server:
- inetd uses inetd.conf to determine listen ports, begins
- On connection, fork a child to handle connection. Parent returns
- Child closes all descriptors, save for connection socket.
- Problem: How does the server know the socket name?
Solution: child dups the socket to STDIN, STDOUT, and STDERR.
The Unix model of process I/O: the three descriptors. How they're
usually set up: keyboard and console. Pipes and how the
shell sets them up:
ps gauxw | grep kelliher | less.
- Child execs the server.
- Purpose: monitor telnet port and well-known ssh port. Neither should
be in use.
Logs connection attempts by e-mailing client IP and FQDN to me. In case of
telnet connection, send client a diagnostic message. Otherwise, quietly
exit, closing the socket.
- Changing UID. Why not run as root? Principle of least privilege.
- That's strange: calling socket functions on STDIN. Or is it?
Observe: we do all I/O through the standard descriptors, which are sockets
- Getting client IP and FQDN.
- Getting server port. Why?
- Opening a pipe to send e-mail, via mail client.
Hint: Pipe from to run a CGI program.
Thomas P. Kelliher
Fri Apr 14 12:50:07 EDT 2000