| 1 |
.\" Copyright (c) 1998-2004 Proofpoint, Inc. and its suppliers. |
| 2 |
.\" All rights reserved. |
| 3 |
.\" Copyright (c) 1993 Eric P. Allman. All rights reserved. |
| 4 |
.\" Copyright (c) 1993 |
| 5 |
.\" The Regents of the University of California. All rights reserved. |
| 6 |
.\" |
| 7 |
.\" By using this file, you agree to the terms and conditions set |
| 8 |
.\" forth in the LICENSE file which can be found at the top level of |
| 9 |
.\" the sendmail distribution. |
| 10 |
.\" |
| 11 |
.\" |
| 12 |
.\" $Id: smrsh.8,v 8.23 2013-11-22 20:52:00 ca Exp $ |
| 13 |
.\" |
| 14 |
.TH SMRSH 8 "$Date: 2013-11-22 20:52:00 $" |
| 15 |
.SH NAME |
| 16 |
smrsh \- restricted shell for sendmail |
| 17 |
.SH SYNOPSIS |
| 18 |
.B smrsh |
| 19 |
.B \-c |
| 20 |
command |
| 21 |
.SH DESCRIPTION |
| 22 |
The |
| 23 |
.I smrsh |
| 24 |
program is intended as a replacement for |
| 25 |
.I sh |
| 26 |
for use in the ``prog'' mailer in |
| 27 |
.IR sendmail (8) |
| 28 |
configuration files. |
| 29 |
It sharply limits the commands that can be run using the |
| 30 |
``|program'' syntax of |
| 31 |
.I sendmail |
| 32 |
in order to improve the over all security of your system. |
| 33 |
Briefly, even if a ``bad guy'' can get sendmail to run a program |
| 34 |
without going through an alias or forward file, |
| 35 |
.I smrsh |
| 36 |
limits the set of programs that he or she can execute. |
| 37 |
.PP |
| 38 |
Briefly, |
| 39 |
.I smrsh |
| 40 |
limits programs to be in a single directory, |
| 41 |
by default |
| 42 |
/etc/mail/smrsh, |
| 43 |
allowing the system administrator to choose the set of acceptable commands, |
| 44 |
and to the shell builtin commands ``exec'', ``exit'', and ``echo''. |
| 45 |
It also rejects any commands with the characters |
| 46 |
`\`', `<', `>', `;', `$', `(', `)', `\er' (carriage return), |
| 47 |
or `\en' (newline) |
| 48 |
on the command line to prevent ``end run'' attacks. |
| 49 |
It allows ``||'' and ``&&'' to enable commands like: |
| 50 |
``"|exec /usr/local/bin/filter || exit 75"'' |
| 51 |
.PP |
| 52 |
Initial pathnames on programs are stripped, |
| 53 |
so forwarding to ``/usr/ucb/vacation'', |
| 54 |
``/usr/bin/vacation'', |
| 55 |
``/home/server/mydir/bin/vacation'', |
| 56 |
and |
| 57 |
``vacation'' |
| 58 |
all actually forward to |
| 59 |
``/etc/mail/smrsh/vacation''. |
| 60 |
.PP |
| 61 |
System administrators should be conservative about populating |
| 62 |
the sm.bin directory. |
| 63 |
For example, a reasonable additions is |
| 64 |
.IR vacation (1), |
| 65 |
and the like. |
| 66 |
No matter how brow-beaten you may be, |
| 67 |
never include any shell or shell-like program |
| 68 |
(such as |
| 69 |
.IR perl (1)) |
| 70 |
in the |
| 71 |
sm.bin |
| 72 |
directory. |
| 73 |
Note that this does not restrict the use of shell or perl scripts |
| 74 |
in the sm.bin directory (using the ``#!'' syntax); |
| 75 |
it simply disallows execution of arbitrary programs. |
| 76 |
Also, including mail filtering programs such as |
| 77 |
.IR procmail (1) |
| 78 |
is a very bad idea. |
| 79 |
.IR procmail (1) |
| 80 |
allows users to run arbitrary programs in their |
| 81 |
.IR procmailrc (5). |
| 82 |
.SH COMPILATION |
| 83 |
Compilation should be trivial on most systems. |
| 84 |
You may need to use \-DSMRSH_PATH=\e"\fIpath\fP\e" |
| 85 |
to adjust the default search path |
| 86 |
(defaults to ``/bin:/usr/bin:/usr/ucb'') |
| 87 |
and/or \-DSMRSH_CMDDIR=\e"\fIdir\fP\e" |
| 88 |
to change the default program directory |
| 89 |
(defaults to ``/etc/mail/smrsh''). |
| 90 |
.SH FILES |
| 91 |
/etc/mail/smrsh \- default directory for restricted programs on most OSs |
| 92 |
.PP |
| 93 |
/var/adm/sm.bin \- directory for restricted programs on HP UX and Solaris |
| 94 |
.PP |
| 95 |
/usr/libexec/sm.bin \- directory for restricted programs on FreeBSD (>= 3.3) and DragonFly BSD |
| 96 |
|
| 97 |
.SH SEE ALSO |
| 98 |
sendmail(8) |