xref: /csrg-svn/usr.sbin/sendmail/smrsh/README (revision 67908)
1*67908Seric
2*67908Seric
3*67908Seric
4*67908SericREADME  smrsh - sendmail restricted shell.
5*67908Seric
6*67908Seric	@(#)README	8.1	11/13/94
7*67908Seric
8*67908Seric
9*67908SericThis README file is provided as a courtesy of the CERT Coordination Center,
10*67908SericSoftware Engineering Institute, Carnegie Mellon University.  This file is
11*67908Sericintended as a supplement to the CERT advisory CA-93:16.sendmail.vulnerability,
12*67908Sericand to the software, smrsh.c, written by Eric Allman.
13*67908Seric
14*67908Seric
15*67908Seric
16*67908SericThe smrsh(8) program is intended as a replacement for /bin/sh in the
17*67908Sericprogram mailer definition of sendmail(8).  This README file describes
18*67908Sericthe steps needed to compile and install smrsh.
19*67908Seric
20*67908Sericsmrsh is a restricted shell utility that provides the ability to
21*67908Sericspecify, through a configuration, an explicit list of executable
22*67908Sericprograms.  When used in conjunction with sendmail, smrsh effectively
23*67908Sericlimits sendmail's scope of program execution to only those programs
24*67908Sericspecified in smrsh's configuration.
25*67908Seric
26*67908Sericsmrsh has been written with portability in mind, and uses traditional
27*67908SericUnix library utilities.  As such, smrsh should compile on most
28*67908SericUnix C compilers.
29*67908Seric
30*67908Seric
31*67908Seric
32*67908SericTo compile smrsh.c, use the following command:
33*67908Seric
34*67908Serichost.domain% cc -o smrsh smrsh.c
35*67908Seric
36*67908SericFor machines that provide dynamic linking, it is advisable to compile
37*67908Sericsmrsh without dynamic linking.  As an example with the Sun Microsystems
38*67908Sericcompiler, you should compile with the -Bstatic option.
39*67908Seric
40*67908Serichost.domain% cc -Bstatic -o smrsh smrsh.c
41*67908Seric
42*67908Seric
43*67908SericChoose a directory that smrsh will reside in.  We will use the traditional
44*67908Seric/usr/etc directory for the remainder of this document.
45*67908Seric
46*67908SericAs root, install smrsh in /usr/etc directory, with mode 511.
47*67908Seric
48*67908Serichost.domain# mv smrsh /usr/etc
49*67908Serichost.domain# chmod 511 /usr/etc/smrsh
50*67908Seric
51*67908Seric
52*67908Seric
53*67908SericNext, determine the list of commands that smrsh should allow sendmail
54*67908Sericto run.  This list of allowable commands can be determined by:
55*67908Seric
56*67908Seric   1.  examining your /etc/aliases file, to indicate what commands
57*67908Seric       are being used by the system.
58*67908Seric
59*67908Seric   2.  surveying your host's .forward files, to determine what
60*67908Seric       commands users have specified.
61*67908Seric
62*67908SericSee the man page for aliases(5) if you are unfamiliar with the format of
63*67908Sericthese specifications. Additionally, you should include in the list,
64*67908Sericpopular commands such as /usr/ucb/vacation.
65*67908Seric
66*67908SericYou should NOT include interpreter programs such as sh(1), csh(1),
67*67908Sericperl(1), uudecode(1) or the stream editor sed(1) in your list of
68*67908Sericacceptable commands.
69*67908Seric
70*67908Seric
71*67908SericYou will next need to create the directory /usr/adm/sm.bin and populate
72*67908Sericit with the programs that your site feels are allowable for sendmail
73*67908Sericto execute.   This directory is explicitly specified in the source
74*67908Sericcode for smrsh, so changing this directory must be accompanied with
75*67908Serica change in smrsh.c.
76*67908Seric
77*67908Seric
78*67908SericYou will have to be root to make these modifications.
79*67908Seric
80*67908SericAfter creating the /usr/adm/sm.bin directory, either copy the programs
81*67908Sericto the directory, or establish links to the allowable programs from
82*67908Seric/usr/adm/sm.bin.  Change the file permissions, so that these programs
83*67908Sericcan not be modified.  If you use links, you should ensure that the target
84*67908Sericprograms are not modifiable.
85*67908Seric
86*67908SericTo allow the popular vacation(1) program by creating a link in the
87*67908Seric/usr/adm/sm.bin directory, you should:
88*67908Seric
89*67908Serichost.domain# cd /usr/adm/sm.bin
90*67908Serichost.domain# ln -s /usr/ucb/vacation vacation
91*67908Seric
92*67908Seric
93*67908Seric
94*67908Seric
95*67908SericAfter populating the /usr/adm/sm.bin directory, you can now configure
96*67908Sericsendmail to use the restricted shell.  Save the current sendmail.cf
97*67908Sericfile prior to modifying it, as a prudent precaution.
98*67908Seric
99*67908SericTypically, the program mailer is defined by a single line in the
100*67908Sericsendmail configuration file, sendmail.cf.  This file is traditionally
101*67908Sericfound in the /etc, /usr/lib or /etc/mail directories, depending on
102*67908Sericthe UNIX vendor.
103*67908Seric
104*67908SericIf you are unsure of the location of the actual sendmail configuration
105*67908Sericfile, a search of the strings(1) output of the sendmail binary, will
106*67908Serichelp to locate it.
107*67908Seric
108*67908SericIn order to configure sendmail to use smrsh, you must modify the Mprog
109*67908Sericdefinition in the sendmail.cf file, by replacing the /bin/sh specification
110*67908Sericwith /usr/etc/smrsh.
111*67908Seric
112*67908SericAs an example:
113*67908Seric
114*67908SericIn most Sun Microsystems' sendmail.cf files, the line is:
115*67908SericMprog,	P=/bin/sh,   F=lsDFMeuP,  S=10, R=20, A=sh -c $u
116*67908Seric
117*67908Sericwhich should be changed to:
118*67908SericMprog,	P=/usr/etc/smrsh,   F=lsDFMeuP,  S=10, R=20, A=sh -c $u
119*67908Seric          ^^^^^^^^^^^^^^
120*67908Seric
121*67908SericA more generic line may be:
122*67908SericMprog,		P=/bin/sh, F=lsDFM, A=sh -c $u
123*67908Seric
124*67908Sericand should be changed to;
125*67908SericMprog,		P=/usr/etc/smrsh, F=lsDFM, A=sh -c $u
126*67908Seric
127*67908Seric
128*67908SericAfter modifying the Mprog definition in the sendmail.cf file, if a frozen
129*67908Sericconfiguration file is being used, it is essential to create a new one.
130*67908SericYou can determine if you need a frozen configuration by discovering
131*67908Sericif a sendmail.fc file currently exists in either the /etc/, /usr/lib,
132*67908Sericor /etc/mail directories.  The specific location can be determined using
133*67908Serica search of the strings(1) output of the sendmail binary.
134*67908Seric
135*67908SericIn order to create a new frozen configuration, if it is required:
136*67908Serichost.domain# /usr/lib/sendmail -bz
137*67908Seric
138*67908SericNow re-start the sendmail process.  An example of how to do this on
139*67908Serica typical system follows:
140*67908Seric
141*67908Serichost.domain# /usr/bin/ps aux | /usr/bin/grep sendmail
142*67908Sericroot 130  0.0  0.0  168    0 ?  IW   Oct  2  0:10 /usr/lib/sendmail -bd -q
143*67908Serichost.domain# /bin/kill -9 130
144*67908Serichost.domain# /usr/lib/sendmail -bd -q30m
145