Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

Section 9.3 Network Logins 291


BSD Network Logins


In BSD, a single process waits for most network connections: theinetdprocess,
sometimes called theInternet superserver.Inthis section, we’ll look at the sequence of
processes involved in network logins for a BSD system. We are not interested in the
detailed network programming aspects of these processes; refer to Stevens, Fenner,and
Rudoff[ 2004 ]for all the details.
As part of the system start-up,initinvokes a shell that executes the shell script
/etc/rc.One of the daemons that is started by this shell script isinetd.Once the
shell script terminates, the parent process ofinetdbecomesinit;inetdwaits for
TCP/IP connection requests to arrive at the host. When a connection request arrives for
it to handle,inetddoes aforkandexecof the appropriate program.
Let’s assume that a TCP connection request arrives for the TELNET server.
TELNET is a remote login application that uses the TCP protocol. A user on another
host (that is connected to the server’s host through a network of some form) or on the
same host initiates the login by starting the TELNET client:

telnethostname

The client opens a TCP connection tohostname,and the program that’s started on
hostnameis called the TELNET server.The client and the server then exchange data
across the TCP connection using the TELNET application protocol. What has happened
is that the user who started the client program is now logged in to the server’s host.
(This assumes, of course, that the user has a valid account on the server’s host.)
Figure9.4 shows the sequence of processes involved in executing the TELNET server,
calledtelnetd.

init

inetd

inetd

telnetd

fork

exec

process ID 1

TCP connection request
from TELNET client

fork/execof/bin/sh,which
executes shell script/etc/rc
when system comes up multiuser

when connection request
arrives from TELNET client

Figure 9.4Sequence of processes involved in executing TELNET server
Free download pdf