xref: /freebsd/contrib/sendmail/smrsh/README (revision 06f25ae9f1d6020a600a10f713046203d1a82570)
1c2aa98e2SPeter Wemm
2c2aa98e2SPeter WemmREADME  smrsh - sendmail restricted shell.
3c2aa98e2SPeter Wemm
4c2aa98e2SPeter WemmThis README file is provided as a courtesy of the CERT Coordination Center,
5c2aa98e2SPeter WemmSoftware Engineering Institute, Carnegie Mellon University.  This file is
6c2aa98e2SPeter Wemmintended as a supplement to the CERT advisory CA-93:16.sendmail.vulnerability,
7c2aa98e2SPeter Wemmand to the software, smrsh.c, written by Eric Allman.
8c2aa98e2SPeter Wemm
9c2aa98e2SPeter Wemm
10c2aa98e2SPeter Wemm
11c2aa98e2SPeter WemmThe smrsh(8) program is intended as a replacement for /bin/sh in the
12c2aa98e2SPeter Wemmprogram mailer definition of sendmail(8).  This README file describes
13c2aa98e2SPeter Wemmthe steps needed to compile and install smrsh.
14c2aa98e2SPeter Wemm
15c2aa98e2SPeter Wemmsmrsh is a restricted shell utility that provides the ability to
16c2aa98e2SPeter Wemmspecify, through a configuration, an explicit list of executable
17c2aa98e2SPeter Wemmprograms.  When used in conjunction with sendmail, smrsh effectively
18c2aa98e2SPeter Wemmlimits sendmail's scope of program execution to only those programs
19c2aa98e2SPeter Wemmspecified in smrsh's configuration.
20c2aa98e2SPeter Wemm
21c2aa98e2SPeter Wemmsmrsh has been written with portability in mind, and uses traditional
22c2aa98e2SPeter WemmUnix library utilities.  As such, smrsh should compile on most
23c2aa98e2SPeter WemmUnix C compilers.
24c2aa98e2SPeter Wemm
2506f25ae9SGregory Neil Shapirosmrsh should build on most systems with the enclosed Build script:
26c2aa98e2SPeter Wemm
2706f25ae9SGregory Neil Shapiro	host.domain% sh Build
28c2aa98e2SPeter Wemm
2906f25ae9SGregory Neil ShapiroTo compile smrsh.c by hand, use the following command:
30c2aa98e2SPeter Wemm
31c2aa98e2SPeter Wemm	host.domain% cc -o smrsh smrsh.c
32c2aa98e2SPeter Wemm
33c2aa98e2SPeter WemmFor machines that provide dynamic linking, it is advisable to compile
34c2aa98e2SPeter Wemmsmrsh without dynamic linking.  As an example with the Sun Microsystems
35c2aa98e2SPeter Wemmcompiler, you should compile with the -Bstatic option.
36c2aa98e2SPeter Wemm
37c2aa98e2SPeter Wemm	host.domain% cc -Bstatic -o smrsh smrsh.c
3806f25ae9SGregory Neil Shapiro		or
3906f25ae9SGregory Neil Shapiro	host.domain% sh Build LDOPTS=-Bstatic
4006f25ae9SGregory Neil Shapiro
4106f25ae9SGregory Neil ShapiroWith gcc, the GNU C compiler, use the -static option.
4206f25ae9SGregory Neil Shapiro
4306f25ae9SGregory Neil Shapiro	host.domain% cc -static -o smrsh smrsh.c
4406f25ae9SGregory Neil Shapiro		or
4506f25ae9SGregory Neil Shapiro	host.domain% sh Build LDOPTS=-static
46c2aa98e2SPeter Wemm
47c2aa98e2SPeter Wemm
48c2aa98e2SPeter Wemm
4906f25ae9SGregory Neil ShapiroAs root, install smrsh in /usr/libexec.  Using the Build script:
50c2aa98e2SPeter Wemm
5106f25ae9SGregory Neil Shapiro	host.domain# sh Build install
5206f25ae9SGregory Neil Shapiro
5306f25ae9SGregory Neil ShapiroFor manual installation: install smrsh in the /usr/libexec
5406f25ae9SGregory Neil Shapirodirectory, with mode 511.
5506f25ae9SGregory Neil Shapiro
5606f25ae9SGregory Neil Shapiro	host.domain# mv smrsh /usr/libexec
5706f25ae9SGregory Neil Shapiro	host.domain# chmod 511 /usr/libexec/smrsh
58c2aa98e2SPeter Wemm
59c2aa98e2SPeter Wemm
60c2aa98e2SPeter Wemm
61c2aa98e2SPeter WemmNext, determine the list of commands that smrsh should allow sendmail
62c2aa98e2SPeter Wemmto run.  This list of allowable commands can be determined by:
63c2aa98e2SPeter Wemm
6406f25ae9SGregory Neil Shapiro   1.  examining your /etc/mail/aliases file, to indicate what commands
65c2aa98e2SPeter Wemm       are being used by the system.
66c2aa98e2SPeter Wemm
67c2aa98e2SPeter Wemm   2.  surveying your host's .forward files, to determine what
68c2aa98e2SPeter Wemm       commands users have specified.
69c2aa98e2SPeter Wemm
70c2aa98e2SPeter WemmSee the man page for aliases(5) if you are unfamiliar with the format of
71c2aa98e2SPeter Wemmthese specifications. Additionally, you should include in the list,
72c2aa98e2SPeter Wemmpopular commands such as /usr/ucb/vacation.
73c2aa98e2SPeter Wemm
74c2aa98e2SPeter WemmYou should NOT include interpreter programs such as sh(1), csh(1),
75c2aa98e2SPeter Wemmperl(1), uudecode(1) or the stream editor sed(1) in your list of
76c2aa98e2SPeter Wemmacceptable commands.
77c2aa98e2SPeter Wemm
78c2aa98e2SPeter Wemm
79c2aa98e2SPeter WemmYou will next need to create the directory /usr/adm/sm.bin and populate
80c2aa98e2SPeter Wemmit with the programs that your site feels are allowable for sendmail
81c2aa98e2SPeter Wemmto execute.   This directory is explicitly specified in the source
82c2aa98e2SPeter Wemmcode for smrsh, so changing this directory must be accompanied with
83c2aa98e2SPeter Wemma change in smrsh.c.
84c2aa98e2SPeter Wemm
85c2aa98e2SPeter Wemm
86c2aa98e2SPeter WemmYou will have to be root to make these modifications.
87c2aa98e2SPeter Wemm
88c2aa98e2SPeter WemmAfter creating the /usr/adm/sm.bin directory, either copy the programs
89c2aa98e2SPeter Wemmto the directory, or establish links to the allowable programs from
90c2aa98e2SPeter Wemm/usr/adm/sm.bin.  Change the file permissions, so that these programs
91c2aa98e2SPeter Wemmcan not be modified by non-root users.  If you use links, you should
92c2aa98e2SPeter Wemmensure that the target programs are not modifiable.
93c2aa98e2SPeter Wemm
94c2aa98e2SPeter WemmTo allow the popular vacation(1) program by creating a link in the
95c2aa98e2SPeter Wemm/usr/adm/sm.bin directory, you should:
96c2aa98e2SPeter Wemm
97c2aa98e2SPeter Wemm	host.domain# cd /usr/adm/sm.bin
98c2aa98e2SPeter Wemm	host.domain# ln -s /usr/ucb/vacation vacation
99c2aa98e2SPeter Wemm
100c2aa98e2SPeter Wemm
101c2aa98e2SPeter Wemm
102c2aa98e2SPeter Wemm
103c2aa98e2SPeter WemmAfter populating the /usr/adm/sm.bin directory, you can now configure
104c2aa98e2SPeter Wemmsendmail to use the restricted shell.  Save the current sendmail.cf
105c2aa98e2SPeter Wemmfile prior to modifying it, as a prudent precaution.
106c2aa98e2SPeter Wemm
107c2aa98e2SPeter WemmTypically, the program mailer is defined by a single line in the
108c2aa98e2SPeter Wemmsendmail configuration file, sendmail.cf.  This file is traditionally
109c2aa98e2SPeter Wemmfound in the /etc, /usr/lib or /etc/mail directories, depending on
110c2aa98e2SPeter Wemmthe UNIX vendor.
111c2aa98e2SPeter Wemm
112c2aa98e2SPeter WemmIf you are unsure of the location of the actual sendmail configuration
113c2aa98e2SPeter Wemmfile, a search of the strings(1) output of the sendmail binary, will
114c2aa98e2SPeter Wemmhelp to locate it.
115c2aa98e2SPeter Wemm
116c2aa98e2SPeter WemmIn order to configure sendmail to use smrsh, you must modify the Mprog
117c2aa98e2SPeter Wemmdefinition in the sendmail.cf file, by replacing the /bin/sh specification
11806f25ae9SGregory Neil Shapirowith /usr/libexec/smrsh.
119c2aa98e2SPeter Wemm
120c2aa98e2SPeter WemmAs an example:
121c2aa98e2SPeter Wemm
122c2aa98e2SPeter WemmIn most Sun Microsystems' sendmail.cf files, the line is:
123c2aa98e2SPeter WemmMprog,	P=/bin/sh,   F=lsDFMeuP,  S=10, R=20, A=sh -c $u
124c2aa98e2SPeter Wemm
125c2aa98e2SPeter Wemmwhich should be changed to:
12606f25ae9SGregory Neil ShapiroMprog,	P=/usr/libexec/smrsh,   F=lsDFMeuP,  S=10, R=20, A=sh -c $u
12706f25ae9SGregory Neil Shapiro          ^^^^^^^^^^^^^^^^^^
128c2aa98e2SPeter Wemm
129c2aa98e2SPeter WemmA more generic line may be:
130c2aa98e2SPeter WemmMprog,		P=/bin/sh, F=lsDFM, A=sh -c $u
131c2aa98e2SPeter Wemm
132c2aa98e2SPeter Wemmand should be changed to;
13306f25ae9SGregory Neil ShapiroMprog,		P=/usr/libexec/smrsh, F=lsDFM, A=sh -c $u
134c2aa98e2SPeter Wemm
135c2aa98e2SPeter Wemm
136c2aa98e2SPeter WemmAfter modifying the Mprog definition in the sendmail.cf file, if a frozen
137c2aa98e2SPeter Wemmconfiguration file is being used, it is essential to create a new one.
138c2aa98e2SPeter WemmYou can determine if you need a frozen configuration by discovering
139c2aa98e2SPeter Wemmif a sendmail.fc file currently exists in either the /etc/, /usr/lib,
140c2aa98e2SPeter Wemmor /etc/mail directories.  The specific location can be determined using
141c2aa98e2SPeter Wemma search of the strings(1) output of the sendmail binary.
142c2aa98e2SPeter Wemm
143c2aa98e2SPeter WemmIn order to create a new frozen configuration, if it is required:
144c2aa98e2SPeter Wemm	host.domain# /usr/lib/sendmail -bz
145c2aa98e2SPeter Wemm
146c2aa98e2SPeter WemmNow re-start the sendmail process.  An example of how to do this on
147c2aa98e2SPeter Wemma typical system follows:
148c2aa98e2SPeter Wemm
14906f25ae9SGregory Neil Shapiro	host.domain# cat /var/run/sendmail.pid
15006f25ae9SGregory Neil Shapiro	130
15106f25ae9SGregory Neil Shapiro	/usr/sbin/sendmail -bd -q30m
15206f25ae9SGregory Neil Shapiro	host.domain# /bin/kill -15 130
15306f25ae9SGregory Neil Shapiro	host.domain# /usr/sbin/sendmail -bd -q30m
15406f25ae9SGregory Neil Shapiro
15506f25ae9SGregory Neil Shapiro
15606f25ae9SGregory Neil Shapiro$Revision: 8.6 $, Last updated $Date: 1999/04/28 01:09:51 $
157