1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
.\" Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers.
.\" All rights reserved.
.\" Copyright (c) 1993 Eric P. Allman. All rights reserved.
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" By using this file, you agree to the terms and conditions set
.\" forth in the LICENSE file which can be found at the top level of
.\" the sendmail distribution.
.\"
.\"
.\" $OpenBSD: smrsh.8,v 1.5 2001/01/17 05:26:51 millert Exp $
.\" $Sendmail: smrsh.8,v 8.11.16.2 2000/12/15 19:50:46 gshapiro Exp $
.\"
.Dd December 15, 2000
.Dt SMRSH 8
.Os
.Sh NAME
.Nm smrsh
.Nd restricted shell for sendmail
.Sh SYNOPSIS
.Nm smrsh
.Fl c Ar command
.Sh DESCRIPTION
The
.Nm smrsh
program is intended as a replacement for
.Pa /bin/sh
for use in the
.Dq prog
mailer in
.Xr sendmail 8
configuration files.
It sharply limits the commands that can be run using the
.Dq |program
syntax of
.Xr sendmail 8
in order to improve the overall security of your system.
Briefly, even if a
.Dq bad guy
can get sendmail to run a program
without going through an alias or forward file,
.Nm smrsh
limits the set of programs that he or she can execute.
.Pp
Briefly,
.Nm smrsh
limits programs to be in a single directory, by default
.Pa /usr/libexec/sm.bin ,
allowing the system administrator to choose the set of acceptable commands,
and the shell builtin commands
.Dq exec ,
.Dq exit ,
and
.Dq echo .
It also rejects any commands with the characters
.Sq \e ,
.Sq < ,
.Sq > ,
.So
;
.Sc ,
.Sq $ ,
.So
(
.Sc ,
.So
)
.Sc ,
.Sq \er
(carriage return), or
.Sq \en
(newline) on the command line to prevent
.Dq end run
attacks.
It allows
.Dq ||
and
.Dq &&
to enable commands like:
.Bd -literal -compact -offset "XXXX"
.Qq "|exec /usr/local/bin/procmail -f- /etc/procmailrcs/user || exit 75"
.Ed
.Pp
Initial pathnames on programs are stripped,
so forwarding to
.Pa /usr/ucb/vacation ,
.Pa /usr/bin/vacation ,
.Pa /home/server/mydir/bin/vacation ,
and
.Pa vacation
all actually forward to
.Pa /usr/libexec/sm.bin/vacation .
.Pp
System administrators should be conservative about populating
the sm.bin directory.
Reasonable additions are
.Xr vacation 1 ,
.Xr procmail 1 ,
and the like.
No matter how brow-beaten you may be,
never include any shell or shell-like program
(such as
.Xr perl 1 )
in the
sm.bin
directory.
Note that this does not restrict the use of shell or perl scripts
in the sm.bin directory (using the
.Dq #!
syntax);
it simply disallows execution of arbitrary programs.
.Sh FILES
.Bl -tag -width "/usr/libexec/sm.bin" -compact
.It Pa /usr/libexec/sm.bin
directory for restricted programs
.El
.Sh SEE ALSO
.Xr sendmail 8
|