home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume39 / chrootuid / part01 / README < prev   
Text File  |  1993-08-16  |  7KB  |  184 lines

  1. @(#) README 1.2 93/08/16 10:41:01
  2.  
  3. chrootuid - run command in restricted environment
  4.  
  5. Description
  6. ===========
  7.  
  8. This is the second release of the chrootuid utility.  Douglas Lee
  9. Schales (Doug.Schales@sc.tamu.edu) offered valuable suggestions to
  10. improve ease of use and of robustness -- thanks.
  11.  
  12. Chrootuid makes it easy to run a network service at low privilege level
  13. and with restricted file system access.  At Eindhoven University we use
  14. this program to run the gopher and www (world-wide web) network daemons
  15. in a restricted environment:  the daemons have access only to their own
  16. directory tree, and run under a low-privileged userid.  The arrangement
  17. greatly reduces the impact of possible loopholes in daemon software.
  18.  
  19. Changes
  20. =======
  21.  
  22. It is no longer necessary to have passwd or group files within the
  23. restricted directory tree. The sample tree at the end of the README
  24. file has been updated; I've added specific hints for Ultrix 4.x, and
  25. general hints for other environments.
  26.  
  27. Installation
  28. ============
  29.  
  30. The source of the chrootuid program is small and easy to verify.  In
  31. order to build the program, run "make". If it compiles OK, edit the
  32. destination pathnames in the Makefile and do a "make install".
  33.  
  34. Important: chrootuid should *not* be installed set-uid.
  35.  
  36. Using the chrootuid program
  37. ===========================
  38.  
  39. The use of the chrootuid program will be illustrated with the gopher
  40. service. The examples are easily adapted to www (world-wide web) or any
  41. other network service.
  42.  
  43. In the inetd.conf file, make a gopher entry like this:
  44.  
  45.     gopher  stream  tcp   nowait  root  /usr/local/lib/gopherd gopherd
  46.  
  47. If you like to run the daemon under control of my tcp/ip daemon
  48. wrapper, use the following entry:
  49.  
  50.     gopher  stream  tcp   nowait  root  /some/where/tcpd /usr/local/lib/gopherd
  51.  
  52. On some systems you will have to omit the "root" field, because all
  53. daemons are executed as root by default. 
  54.  
  55. The file /usr/local/lib/gopherd should be a shell script that is
  56. maintained by the superuser, because inetd runs the script with root
  57. privilege. It is this script that runs the real gopher daemon, as an
  58. unprivileged process, in a restricted environment. Of course you can
  59. specify any other pathname for the script, as long as it is fully
  60. controlled by the superuser.
  61.  
  62.     #!/bin/sh
  63.  
  64.     exec /usr/local/bin/chrootuid /some/where/gopher nobody \
  65.         /bin/gopherd -I -l /tmp/gopher.log \
  66.                         -o /bin/gopherd.conf \
  67.                      -c -C /gopherdata 70
  68.  
  69. I'll describe the contents of this script in some detail:
  70.  
  71. - Instead of /usr/local/bin/chrootuid, specify the absolute path to the
  72. installed chrootuid executable. The program is executed by root so the
  73. path should be fully controlled by the super user.
  74.  
  75. - Instead of /some/where/gopher, specify the absolute path to your
  76. gopher directory tree. The gopher daemon will have access only to files
  77. within this subtree. This arrangement is similar to anonymous FTP.
  78.  
  79. - The gopher daemon will be executed with the privileges of the "nobody"
  80. account.  You can specify any unprivileged account, as long as it does
  81. not own any files etc. within the gopher directory tree. The account
  82. info will be extracted from the regular password database, so there is
  83. no need for passwd or group files below the gopher directory tree.
  84.  
  85. - "/bin/gopherd -I -l ..." is the command that will be executed, after
  86. access to the file system has been restricted to the gopher directory
  87. tree, and after privileges have been reduced to those of "nobody" (or
  88. whatever account name you choose).  All path names should be absolute
  89. with respect to the root of the gopher directory tree. Thus,
  90. /bin/gopherd corresponds to /some/where/gopher/bin/gopherd.
  91.  
  92. On systems with shared libraries it will be necessary to set up the
  93. appropriate files in the gopher directory tree. The appendix below
  94. shows [a slightly edited version of] what we have. It is very similar
  95. to what one has to set up for anonymous FTP, except that no passwd or
  96. group files are needed.
  97.  
  98. Finally, chrootuid reports all problems to the syslog daemon.  Have a
  99. look at your syslog.conf file if you don't know where the errors are
  100. logged.
  101.  
  102.         Wietse Venema
  103.     wietse@wzv.win.tue.nl
  104.         Mathematics and Computing Science
  105.         Eindhoven University of Technology
  106.         The Netherlands
  107.  
  108. Appendix: sample restricted gopher subtree
  109. ==========================================
  110.  
  111. This example is a slightly edited version of own gopher subtree.  Some
  112. details (shared libs, DNS, and timezone stuff) are specific to SunOS;
  113. hints are given for Ultrix 4.x.
  114.  
  115. The restricted gopher subtree is very similar to the tree used for
  116. anonymous ftp, except that no passwd or group files are needed.  The
  117. example assumes that the tree is located at /some/where/gopher, which
  118. will sometimes be referred to as ~gopher for brevity.
  119.  
  120. SunOS notes:  the shared libraries in this example are specific to
  121. SunOS 4.1.1. What you will need depends on the OS release and on the
  122. compiler used to build the gopher executable (do `ldd gopherd' to find
  123. out; you'll always need the ld.so runtime linker, though). The example
  124. assumes that you are running DNS on top of NIS.  Otherwise, you will
  125. need a ~gopher/etc/resolv.conf file.
  126.  
  127. Ultrix notes: you will need the following files in ~gopher/etc:  hosts,
  128. resolv.conf, svc.conf, svcorder. Just copy them from a DNS client host.
  129.  
  130. Other systems: it may be necessary to install a ~gopher/etc/resolv.conf
  131. file so that gopherd can find the domain name server (DNS).
  132.  
  133. It is convenient to have a symlink ~gopher/some/where/gopher -> ../..
  134. so that old pathnames keep working after the installation of chrootuid.
  135.  
  136. Important: make sure that no files etc. are owned by the unprivileged
  137. account ("nobody" or whatever you chose). The only exception that we
  138. permit is the gopherd logfile, because no program depends on it.
  139.  
  140. ~gopher:
  141. drwxr-sr-x  2 exp           512 Aug 12 13:33 bin
  142. dr-xr-sr-x  2 exp           512 Oct 12  1992 dev
  143. drwxr-sr-x  9 exp           512 Aug  9 12:35 gopherdata
  144. dr-xr-sr-x  2 exp           512 Apr 22 14:24 some
  145. drwxrwsrwt  2 exp           512 Aug 12 13:48 tmp
  146. dr-xr-sr-x  4 exp           512 Jan 25  1993 usr
  147.  
  148. ~gopher/bin:
  149. -rwx--x--x  1 exp        409600 Aug 12 13:39 gopherd
  150. -rw-r--r--  1 exp          2299 Jun 15 10:12 gopherd.conf
  151.  
  152. ~gopher/dev:
  153. crw-rw-rw-  1 exp        3,  12 Oct 12  1992 zero
  154.  
  155. ~gopher/gopherdata:
  156. <our information data base omitted for brevity>
  157.  
  158. ~gopher/some:
  159. dr-xr-xr-x  2 exp           512 Apr 22 14:24 where
  160.  
  161. ~gopher/some/where:
  162. lrwxrwxrwx  1 exp             6 Apr 22 14:24 gopher -> ../../
  163.  
  164. ~gopher/tmp:
  165. -rw-r--r--  1 nobody     220563 Aug 12 14:46 gopher.log
  166.  
  167. ~gopher/usr:
  168. dr-xr-xr-x  2 exp           512 Oct 12  1992 lib
  169. dr-xr-xr-x  3 exp           512 Jan 21  1993 share
  170.  
  171. ~gopher/usr/lib:
  172. -r-xr-xr-x  1 exp         40960 Oct 11  1990 ld.so
  173. -r-xr-xr-x  1 exp        516096 Oct 12  1990 libc.so.1.6
  174.  
  175. ~gopher/usr/share:
  176. dr-xr-xr-x  3 exp           512 Jan 21  1993 lib
  177.  
  178. ~gopher/usr/share/lib:
  179. dr-xr-xr-x  2 exp           512 Jan 21  1993 zoneinfo
  180.  
  181. ~gopher/usr/share/lib/zoneinfo:
  182. -r--r--r--  1 exp           590 Oct 11  1990 MET
  183. -r--r--r--  1 exp           590 Oct 11  1990 localtime
  184.