6 smrsh - restricted shell for sendmail
9 \e[1msmrsh -c
\e[22mcommand
12 The
\e[4msmrsh
\e[24m program is intended as a replacement for
\e[4msh
\e[24m for use in the
13 ``prog'' mailer in
\e[4msendmail
\e[24m(8) configuration files. It sharply limits
14 the commands that can be run using the ``|program'' syntax of
\e[4msendmail
\e[0m
15 in order to improve the over all security of your system. Briefly,
16 even if a ``bad guy'' can get sendmail to run a program without going
17 through an alias or forward file,
\e[4msmrsh
\e[24m limits the set of programs that
18 he or she can execute.
20 Briefly,
\e[4msmrsh
\e[24m limits programs to be in a single directory, by default
21 /usr/adm/sm.bin, allowing the system administrator to choose the set of
22 acceptable commands, and to the shell builtin commands ``exec'',
23 ``exit'', and ``echo''. It also rejects any commands with the charac-
24 ters ``', `<', `>', `;', `$', `(', `)', `\r' (carriage return), or `\n'
25 (newline) on the command line to prevent ``end run'' attacks. It
26 allows ``||'' and ``&&'' to enable commands like: ``"|exec
27 /usr/local/bin/filter || exit 75"''
29 Initial pathnames on programs are stripped, so forwarding to
30 ``/usr/ucb/vacation'', ``/usr/bin/vacation'',
31 ``/home/server/mydir/bin/vacation'', and ``vacation'' all actually for-
32 ward to ``/usr/adm/sm.bin/vacation''.
34 System administrators should be conservative about populating the
35 sm.bin directory. For example, a reasonable additions is
\e[4mvacation
\e[24m(1),
36 and the like. No matter how brow-beaten you may be, never include any
37 shell or shell-like program (such as
\e[4mperl
\e[24m(1)) in the sm.bin directory.
38 Note that this does not restrict the use of shell or perl scripts in
39 the sm.bin directory (using the ``#!'' syntax); it simply disallows
40 execution of arbitrary programs. Also, including mail filtering pro-
41 grams such as
\e[4mprocmail
\e[24m(1) is a very bad idea.
\e[4mprocmail
\e[24m(1) allows users
42 to run arbitrary programs in their
\e[4mprocmailrc
\e[24m(5).
45 Compilation should be trivial on most systems. You may need to use
46 -DSMRSH_PATH=\"
\e[4mpath
\e[24m\" to adjust the default search path (defaults to
47 ``/bin:/usr/bin:/usr/ucb'') and/or -DSMRSH_CMDDIR=\"
\e[4mdir
\e[24m\" to change the
48 default program directory (defaults to ``/usr/adm/sm.bin'').
51 /usr/adm/sm.bin - default directory for restricted programs on most OSs
53 /var/adm/sm.bin - directory for restricted programs on HP UX and
56 /usr/libexec/sm.bin - directory for restricted programs on FreeBSD (>=
57 3.3) and DragonFly BSD
65 $Date: 2013-11-22 20:52:00 $ SMRSH(8)