12. Inetd, RPC/Portmapper, NFS Table of Contents 12
Total Page:16
File Type:pdf, Size:1020Kb
12. Inetd, RPC/Portmapper, NFS Table of Contents 12. INETD, RPC/PORTMAPPER, NFS......................................... 1 This is a miscellaneous topic section which will briefly 12.1 INETD -THE SUPER DAEMON.................................................. 3 survey some of the application-support functionality needed 12.1.1 Configuring inetd ............................................................ 4 in network operating systems. We will concentrate on Unix, 12.1.2 When Not To Use Inetd.................................................... 5 but you should be aware that some of these features (e.g. 12.1.3 Programming Servers for inetd ....................................... 6 NFS) are available on personal computer operating systems 12.2 RPC ........................................................................................ 7 so that they can interact with Unix systems. 12.2.1 The Portmapper............................................................... 9 Readings: 12.2.2 Configuring the Portmapper ......................................... 10 12.2.3 Other RPC Issues .......................................................... 11 Sections 9.1 - 9.3 of [Carl-Mitchell93]. These three 12.3 NFS ...................................................................................... 14 subsections provide a nice, brief introduction to these three 12.3.1 NFS Daemons................................................................ 15 topics. Optionally, you may additionally want to read the 12.3.2 Exporting....................................................................... 16 later subsections of this same chapter which cover print 12.3.3 Mounting ....................................................................... 17 spooling, netnews, anonymous FTP, rlogin/rshell/rcp, and 12.3.4 NFS Security.................................................................. 20 syslog. 12.4 REFERENCES ......................................................................... 21 Optionally, you may be interested in: • A whole book published by O’Reilly on managing NFS and NIS mentioned in this section’s reference subsection. • [Stevens94] has a section on managing NFS, as does [Nemeth95] • More information about NFS is also presented in Cmpt 401. See for instance, the web page mentioned in [Atikins]. • Finally, Sun has lots of online NFS information at http://www.sun.com/software/white-papers/wp-nfs Copyright 1997 by Russ Tront Page 12-1 Copyright 1997 by Russ Tront Page 12-2 12.1 Inetd - The Super Daemon 12.1.1 Configuring inetd If a server is started at boot time, it constantly takes up Before inetd will listen on behalf of a server, you must RAM and other resources in a computer. This is terribly inform it that it should do so. This is set by a line in the file wasteful if the server will never once be called that day! /etc/inetd.conf. e.g. In addition, because the start up code for most servers are ftp stream tcp nowait nobody /bin/in.ftpd in.ftpd similar, it is wasteful to have the same (open socket and comsat dgram udp wait root /bin/in.comsat in.comsat bind) code for each different running server in RAM all the The first column indicates the name of the port. Service time. names to port mappings are stored in the file /etc/services. Unix has adopted the concept of a super server which sits This file is really just the port numbers well known to the waiting with sockets open on all ports for which servers machine. The next two columns indicate the protocol type have been specified in the inetd.conf file. If a packet comes and name. The wait column indicates whether inetd should in for, say, ftp (which is supposed to be listening on port 21), accept another connection or packet before the last has been the packet is actually detected by inetd using select(). completely handled (i.e. concurrency or serialization). ‘Wait’ Inetd, in turn, brings in ftpd from disk and starts it up. mode is generally necessary for UDP servers. If the packet was for a TCP port, it performs an accept() on The nobody/root column indicates the uid or uid name that the appropriate socket which creates a second socket which the spawned process and server should run as. Ftp is not inetd can give to ftpd to handle the connection. very safe, so it should not run as root. I’m not sure why the full path to the server and the server name have to both be Inetd forks and the I/O descriptor of the socket is copied then stated. over to the child’s I/O descriptor 0 (stdin), 1 (stdout), and 2 (stderr). The child process transfers control using exec() to the actual server. This allows an actual server to be run which don’t know about sockets but instead uses read() and write() to stdin and stdout. When the server completes, a SIGCLD signal is generated which the child inetd has been wait()’ing for. Note that UDP servers must run slightly differently, using ‘wait’ mode, in order to avoid a race condition that could wrongly repeatedly fork children into existence. Copyright 1997 by Russ Tront Page 12-3 Copyright 1997 by Russ Tront Page 12-4 12.1.2 When Not To Use Inetd 12.1.3 Programming Servers for inetd inetd is not very suitable in the following cases: Generally, servers started by inetd must be non-standard, as they needn’t perform a call to socket(), bind(), and if • When fast server response is needed. In real time and connection-oriented, to listen(). This is an advantage other applications, you often cannot wait for the server to though as this code need only be in RAM in one place, inside be loaded from disk. inetd. Interestingly, it also allows even OS command line • When a server must maintain state in RAM between commands to be turned into a inetd-parented server. executions. DNS, for instance, maintains data in a RAM One of the few references I have found which contain cache which would be lost if the ‘named’ daemon was information on actually programming a server to work with halted after it had finished servicing a request. inetd is [Stevens98]. I suspect that some of the big OS • When a service is frequently used and has high (or slow) manufacturers would also have manuals that cover this start up overhead. For instance a server that not only topic. must be read in from disk, but once running itself must read in some configuration data of its own from disk. • When Unix rather than Internet domain sockets are used. I.e. The server must use a transport layer, even if it is just communicating with itself using the loopback/localhost address. Copyright 1997 by Russ Tront Page 12-5 Copyright 1997 by Russ Tront Page 12-6 procedure into a packet, and sends them to port 111 on the 12.2 RPC destination computer. Programmers are very used to the procedure call paradigm. On the remote computer, a process must be started which But procedures calls are usually to functions that are in acts as a proxy for the calling function. It is sometimes RAM on the same computer as is the caller. More correctly, called a driver. It’s job is to de-marshal the arriving are in the same address space (vs. a different process’s VM parameters, get the function to be called into RAM, and address space). make the actual call. Because of the familiar and convenient paradigm, the concept of ‘remote procedure call’ was created. This concept Client will become extremely important in the future because of the deployment of distributed systems using Sun RPC standard, and more recently of component software (where the component often runs in its own process/DLL), and Stub Driver distributed components (e.g. Microsoft DCOM, and Java Remote Method Invocation). For information on Sun RPC standard (which us used on personal computers too) see: Called Function http://www.internic.net/rfc/rfc1057.txt Comm. Medium For information on Microsoft DCOM see: http://www.microsoft.com/com/dcom.htm Note that in some brands of RPC technology the driver is And for information on Java RMI, see called a ‘proxy’ as it is standing in for the client/caller, while http://java.sun.com/marketing/collateral/javarmi.html in other brands the stub that is called a proxy (because it is The basic concept is that you call a remote procedure standing in for the called function). exactly as you would a local procedure (with some restrictions to be discussed later). In order to implement such a procedure call, the caller actually links to a local stub function. The stub function has the same name, parameter list, and return type as the remote procedure. The stub ‘marshals’ the parameters headed toward the remote Copyright 1997 by Russ Tront Page 12-7 Copyright 1997 by Russ Tront Page 12-8 12.2.1 The Portmapper 12.2.2 Configuring the Portmapper For standard Unix function calls, there is a kind of ‘super The portmapper must be started before any RPC driver driver’ that monitors port 111. It is called the Portmapper. daemons. Since there are zillions of possible functions that could be The portmapper can be configured to support indirect calls, called, the concept of a well know port for each of them does where the client is not returned the port number of where to not make sense. Instead, all initial calls are typically sent call for the actual function’s daemon, but the call is actually to port 111 where the portmapper is waiting. Each actual forwarded by the portmapper to the correct function at the driver process has typically pre-registered the port number correct port, and somehow the function return gets back to that it got randomly bound to with the portmapper. The the caller in such a way that it realizes the actual port that portmapper thus responds to callers with the actual (poorly function is available through for future calls. known) port number where the actual driver process for that function can be reached. To broadcast a message to find out which machines in a network support a particular service, you can use: You can see what driver processes the portmapper is able to handle by issuing the rpcinfo -p command.