Imported Debian patch 1.6.9p8-1
[debian/sudo] / sudoers.man.in
1 .\" Copyright (c) 1994-1996, 1998-2005, 2007
2 .\"     Todd C. Miller <Todd.Miller@courtesan.com>
3 .\" 
4 .\" Permission to use, copy, modify, and distribute this software for any
5 .\" purpose with or without fee is hereby granted, provided that the above
6 .\" copyright notice and this permission notice appear in all copies.
7 .\" 
8 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16 .\" 
17 .\" Sponsored in part by the Defense Advanced Research Projects
18 .\" Agency (DARPA) and Air Force Research Laboratory, Air Force
19 .\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
20 .\" 
21 .\" $Sudo: sudoers.man.in,v 1.45.2.17 2007/11/02 19:15:16 millert Exp $
22 .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
23 .\"
24 .\" Standard preamble:
25 .\" ========================================================================
26 .de Sh \" Subsection heading
27 .br
28 .if t .Sp
29 .ne 5
30 .PP
31 \fB\\$1\fR
32 .PP
33 ..
34 .de Sp \" Vertical space (when we can't use .PP)
35 .if t .sp .5v
36 .if n .sp
37 ..
38 .de Vb \" Begin verbatim text
39 .ft CW
40 .nf
41 .ne \\$1
42 ..
43 .de Ve \" End verbatim text
44 .ft R
45 .fi
46 ..
47 .\" Set up some character translations and predefined strings.  \*(-- will
48 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
49 .\" double quote, and \*(R" will give a right double quote.  | will give a
50 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
51 .\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
52 .\" expand to `' in nroff, nothing in troff, for use with C<>.
53 .tr \(*W-|\(bv\*(Tr
54 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
55 .ie n \{\
56 .    ds -- \(*W-
57 .    ds PI pi
58 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
59 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
60 .    ds L" ""
61 .    ds R" ""
62 .    ds C` 
63 .    ds C' 
64 'br\}
65 .el\{\
66 .    ds -- \|\(em\|
67 .    ds PI \(*p
68 .    ds L" ``
69 .    ds R" ''
70 'br\}
71 .\"
72 .\" If the F register is turned on, we'll generate index entries on stderr for
73 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
74 .\" entries marked with X<> in POD.  Of course, you'll have to process the
75 .\" output yourself in some meaningful fashion.
76 .if \nF \{\
77 .    de IX
78 .    tm Index:\\$1\t\\n%\t"\\$2"
79 ..
80 .    nr % 0
81 .    rr F
82 .\}
83 .\"
84 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
85 .\" way too many mistakes in technical documents.
86 .hy 0
87 .if n .na
88 .\"
89 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
90 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
91 .    \" fudge factors for nroff and troff
92 .if n \{\
93 .    ds #H 0
94 .    ds #V .8m
95 .    ds #F .3m
96 .    ds #[ \f1
97 .    ds #] \fP
98 .\}
99 .if t \{\
100 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
101 .    ds #V .6m
102 .    ds #F 0
103 .    ds #[ \&
104 .    ds #] \&
105 .\}
106 .    \" simple accents for nroff and troff
107 .if n \{\
108 .    ds ' \&
109 .    ds ` \&
110 .    ds ^ \&
111 .    ds , \&
112 .    ds ~ ~
113 .    ds /
114 .\}
115 .if t \{\
116 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
117 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
118 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
119 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
120 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
121 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
122 .\}
123 .    \" troff and (daisy-wheel) nroff accents
124 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
125 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
126 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
127 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
128 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
129 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
130 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
131 .ds ae a\h'-(\w'a'u*4/10)'e
132 .ds Ae A\h'-(\w'A'u*4/10)'E
133 .    \" corrections for vroff
134 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
135 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
136 .    \" for low resolution devices (crt and lpr)
137 .if \n(.H>23 .if \n(.V>19 \
138 \{\
139 .    ds : e
140 .    ds 8 ss
141 .    ds o a
142 .    ds d- d\h'-1'\(ga
143 .    ds D- D\h'-1'\(hy
144 .    ds th \o'bp'
145 .    ds Th \o'LP'
146 .    ds ae ae
147 .    ds Ae AE
148 .\}
149 .rm #[ #] #H #V #F C
150 .\" ========================================================================
151 .\"
152 .IX Title "SUDOERS @mansectform@"
153 .TH SUDOERS @mansectform@ "November  2, 2007" "1.6.9p8" "MAINTENANCE COMMANDS"
154 .SH "NAME"
155 sudoers \- list of which users may execute what
156 .SH "DESCRIPTION"
157 .IX Header "DESCRIPTION"
158 The \fIsudoers\fR file is composed of two types of entries: aliases
159 (basically variables) and user specifications (which specify who
160 may run what).
161 .PP
162 When multiple entries match for a user, they are applied in order.
163 Where there are multiple matches, the last match is used (which is
164 not necessarily the most specific match).
165 .PP
166 The \fIsudoers\fR grammar will be described below in Extended Backus-Naur
167 Form (\s-1EBNF\s0).  Don't despair if you don't know what \s-1EBNF\s0 is; it is
168 fairly simple, and the definitions below are annotated.
169 .Sh "Quick guide to \s-1EBNF\s0"
170 .IX Subsection "Quick guide to EBNF"
171 \&\s-1EBNF\s0 is a concise and exact way of describing the grammar of a language.
172 Each \s-1EBNF\s0 definition is made up of \fIproduction rules\fR.  E.g.,
173 .PP
174 .Vb 1
175 \& symbol ::= definition | alternate1 | alternate2 ...
176 .Ve
177 .PP
178 Each \fIproduction rule\fR references others and thus makes up a
179 grammar for the language.  \s-1EBNF\s0 also contains the following
180 operators, which many readers will recognize from regular
181 expressions.  Do not, however, confuse them with \*(L"wildcard\*(R"
182 characters, which have different meanings.
183 .ie n .IP "\*(C`?\*(C'" 4
184 .el .IP "\f(CW\*(C`?\*(C'\fR" 4
185 .IX Item "?"
186 Means that the preceding symbol (or group of symbols) is optional.
187 That is, it may appear once or not at all.
188 .ie n .IP "\*(C`*\*(C'" 4
189 .el .IP "\f(CW\*(C`*\*(C'\fR" 4
190 .IX Item "*"
191 Means that the preceding symbol (or group of symbols) may appear
192 zero or more times.
193 .ie n .IP "\*(C`+\*(C'" 4
194 .el .IP "\f(CW\*(C`+\*(C'\fR" 4
195 .IX Item "+"
196 Means that the preceding symbol (or group of symbols) may appear
197 one or more times.
198 .PP
199 Parentheses may be used to group symbols together.  For clarity,
200 we will use single quotes ('') to designate what is a verbatim character
201 string (as opposed to a symbol name).
202 .Sh "Aliases"
203 .IX Subsection "Aliases"
204 There are four kinds of aliases: \f(CW\*(C`User_Alias\*(C'\fR, \f(CW\*(C`Runas_Alias\*(C'\fR,
205 \&\f(CW\*(C`Host_Alias\*(C'\fR and \f(CW\*(C`Cmnd_Alias\*(C'\fR.
206 .PP
207 .Vb 4
208 \& Alias ::= 'User_Alias'  User_Alias (':' User_Alias)* |
209 \&           'Runas_Alias' Runas_Alias (':' Runas_Alias)* |
210 \&           'Host_Alias'  Host_Alias (':' Host_Alias)* |
211 \&           'Cmnd_Alias'  Cmnd_Alias (':' Cmnd_Alias)*
212 .Ve
213 .PP
214 .Vb 1
215 \& User_Alias ::= NAME '=' User_List
216 .Ve
217 .PP
218 .Vb 1
219 \& Runas_Alias ::= NAME '=' Runas_List
220 .Ve
221 .PP
222 .Vb 1
223 \& Host_Alias ::= NAME '=' Host_List
224 .Ve
225 .PP
226 .Vb 1
227 \& Cmnd_Alias ::= NAME '=' Cmnd_List
228 .Ve
229 .PP
230 .Vb 1
231 \& NAME ::= [A-Z]([A-Z][0-9]_)*
232 .Ve
233 .PP
234 Each \fIalias\fR definition is of the form
235 .PP
236 .Vb 1
237 \& Alias_Type NAME = item1, item2, ...
238 .Ve
239 .PP
240 where \fIAlias_Type\fR is one of \f(CW\*(C`User_Alias\*(C'\fR, \f(CW\*(C`Runas_Alias\*(C'\fR, \f(CW\*(C`Host_Alias\*(C'\fR,
241 or \f(CW\*(C`Cmnd_Alias\*(C'\fR.  A \f(CW\*(C`NAME\*(C'\fR is a string of uppercase letters, numbers,
242 and underscore characters ('_').  A \f(CW\*(C`NAME\*(C'\fR \fBmust\fR start with an
243 uppercase letter.  It is possible to put several alias definitions
244 of the same type on a single line, joined by a colon (':').  E.g.,
245 .PP
246 .Vb 1
247 \& Alias_Type NAME = item1, item2, item3 : NAME = item4, item5
248 .Ve
249 .PP
250 The definitions of what constitutes a valid \fIalias\fR member follow.
251 .PP
252 .Vb 2
253 \& User_List ::= User |
254 \&               User ',' User_List
255 .Ve
256 .PP
257 .Vb 4
258 \& User ::= '!'* username |
259 \&          '!'* '%'group |
260 \&          '!'* '+'netgroup |
261 \&          '!'* User_Alias
262 .Ve
263 .PP
264 A \f(CW\*(C`User_List\*(C'\fR is made up of one or more usernames, system groups
265 (prefixed with '%'), netgroups (prefixed with '+') and other aliases.
266 Each list item may be prefixed with one or more '!' operators.
267 An odd number of '!' operators negate the value of the item; an even
268 number just cancel each other out.
269 .PP
270 .Vb 2
271 \& Runas_List ::= Runas_User |
272 \&                Runas_User ',' Runas_List
273 .Ve
274 .PP
275 .Vb 5
276 \& Runas_User ::= '!'* username |
277 \&                '!'* '#'uid |
278 \&                '!'* '%'group |
279 \&                '!'* +netgroup |
280 \&                '!'* Runas_Alias
281 .Ve
282 .PP
283 A \f(CW\*(C`Runas_List\*(C'\fR is similar to a \f(CW\*(C`User_List\*(C'\fR except that it can
284 also contain uids (prefixed with '#') and instead of \f(CW\*(C`User_Alias\*(C'\fRes
285 it can contain \f(CW\*(C`Runas_Alias\*(C'\fRes.  Note that usernames and groups
286 are matched as strings.  In other words, two users (groups) with
287 the same uid (gid) are considered to be distinct.  If you wish to
288 match all usernames with the same uid (e.g.\ root and toor), you
289 can use a uid instead (#0 in the example given).
290 .PP
291 .Vb 2
292 \& Host_List ::= Host |
293 \&               Host ',' Host_List
294 .Ve
295 .PP
296 .Vb 5
297 \& Host ::= '!'* hostname |
298 \&          '!'* ip_addr |
299 \&          '!'* network(/netmask)? |
300 \&          '!'* '+'netgroup |
301 \&          '!'* Host_Alias
302 .Ve
303 .PP
304 A \f(CW\*(C`Host_List\*(C'\fR is made up of one or more hostnames, \s-1IP\s0 addresses,
305 network numbers, netgroups (prefixed with '+') and other aliases.
306 Again, the value of an item may be negated with the '!' operator.
307 If you do not specify a netmask along with the network number,
308 \&\fBsudo\fR will query each of the local host's network interfaces and,
309 if the network number corresponds to one of the hosts's network
310 interfaces, the corresponding netmask will be used.  The netmask
311 may be specified either in standard \s-1IP\s0 address notation
312 (e.g.\ 255.255.255.0 or ffff:ffff:ffff:ffff::),
313 or \s-1CIDR\s0 notation (number of bits, e.g.\ 24 or 64).  A hostname may
314 include shell-style wildcards (see the Wildcards section below),
315 but unless the \f(CW\*(C`hostname\*(C'\fR command on your machine returns the fully
316 qualified hostname, you'll need to use the \fIfqdn\fR option for
317 wildcards to be useful.
318 .PP
319 .Vb 2
320 \& Cmnd_List ::= Cmnd |
321 \&               Cmnd ',' Cmnd_List
322 .Ve
323 .PP
324 .Vb 3
325 \& commandname ::= filename |
326 \&                 filename args |
327 \&                 filename '""'
328 .Ve
329 .PP
330 .Vb 4
331 \& Cmnd ::= '!'* commandname |
332 \&          '!'* directory |
333 \&          '!'* "sudoedit" |
334 \&          '!'* Cmnd_Alias
335 .Ve
336 .PP
337 A \f(CW\*(C`Cmnd_List\*(C'\fR is a list of one or more commandnames, directories, and other
338 aliases.  A commandname is a fully qualified filename which may include
339 shell-style wildcards (see the Wildcards section below).  A simple
340 filename allows the user to run the command with any arguments he/she
341 wishes.  However, you may also specify command line arguments (including
342 wildcards).  Alternately, you can specify \f(CW""\fR to indicate that the command
343 may only be run \fBwithout\fR command line arguments.  A directory is a
344 fully qualified pathname ending in a '/'.  When you specify a directory
345 in a \f(CW\*(C`Cmnd_List\*(C'\fR, the user will be able to run any file within that directory
346 (but not in any subdirectories therein).
347 .PP
348 If a \f(CW\*(C`Cmnd\*(C'\fR has associated command line arguments, then the arguments
349 in the \f(CW\*(C`Cmnd\*(C'\fR must match exactly those given by the user on the command line
350 (or match the wildcards if there are any).  Note that the following
351 characters must be escaped with a '\e' if they are used in command
352 arguments: ',', ':', '=', '\e'.  The special command \f(CW"sudoedit"\fR
353 is used to permit a user to run \fBsudo\fR with the \fB\-e\fR flag (or
354 as \fBsudoedit\fR).  It may take command line arguments just as
355 a normal command does.
356 .Sh "Defaults"
357 .IX Subsection "Defaults"
358 Certain configuration options may be changed from their default
359 values at runtime via one or more \f(CW\*(C`Default_Entry\*(C'\fR lines.  These
360 may affect all users on any host, all users on a specific host, a
361 specific user, or commands being run as a specific user.
362 .PP
363 .Vb 4
364 \& Default_Type ::= 'Defaults' |
365 \&                  'Defaults' '@' Host_List |
366 \&                  'Defaults' ':' User_List |
367 \&                  'Defaults' '>' Runas_List
368 .Ve
369 .PP
370 .Vb 1
371 \& Default_Entry ::= Default_Type Parameter_List
372 .Ve
373 .PP
374 .Vb 2
375 \& Parameter_List ::= Parameter |
376 \&                    Parameter ',' Parameter_List
377 .Ve
378 .PP
379 .Vb 4
380 \& Parameter ::= Parameter '=' Value |
381 \&               Parameter '+=' Value |
382 \&               Parameter '-=' Value |
383 \&               '!'* Parameter
384 .Ve
385 .PP
386 Parameters may be \fBflags\fR, \fBinteger\fR values, \fBstrings\fR, or \fBlists\fR.
387 Flags are implicitly boolean and can be turned off via the '!'
388 operator.  Some integer, string and list parameters may also be
389 used in a boolean context to disable them.  Values may be enclosed
390 in double quotes (\f(CW\*(C`"\*(C'\fR) when they contain multiple words.  Special
391 characters may be escaped with a backslash (\f(CW\*(C`\e\*(C'\fR).
392 .PP
393 Lists have two additional assignment operators, \f(CW\*(C`+=\*(C'\fR and \f(CW\*(C`\-=\*(C'\fR.
394 These operators are used to add to and delete from a list respectively.
395 It is not an error to use the \f(CW\*(C`\-=\*(C'\fR operator to remove an element
396 that does not exist in a list.
397 .PP
398 See \*(L"\s-1SUDOERS\s0 \s-1OPTIONS\s0\*(R" for a list of supported Defaults parameters.
399 .Sh "User Specification"
400 .IX Subsection "User Specification"
401 .Vb 2
402 \& User_Spec ::= User_List Host_List '=' Cmnd_Spec_List \e
403 \&               (':' Host_List '=' Cmnd_Spec_List)*
404 .Ve
405 .PP
406 .Vb 2
407 \& Cmnd_Spec_List ::= Cmnd_Spec |
408 \&                    Cmnd_Spec ',' Cmnd_Spec_List
409 .Ve
410 .PP
411 .Vb 1
412 \& Cmnd_Spec ::= Runas_Spec? Tag_Spec* Cmnd
413 .Ve
414 .PP
415 .Vb 1
416 \& Runas_Spec ::= '(' Runas_List ')'
417 .Ve
418 .PP
419 .Vb 2
420 \& Tag_Spec ::= ('NOPASSWD:' | 'PASSWD:' | 'NOEXEC:' | 'EXEC:' |
421 \&               'SETENV:' | 'NOSETENV:')
422 .Ve
423 .PP
424 A \fBuser specification\fR determines which commands a user may run
425 (and as what user) on specified hosts.  By default, commands are
426 run as \fBroot\fR, but this can be changed on a per-command basis.
427 .PP
428 Let's break that down into its constituent parts:
429 .Sh "Runas_Spec"
430 .IX Subsection "Runas_Spec"
431 A \f(CW\*(C`Runas_Spec\*(C'\fR is simply a \f(CW\*(C`Runas_List\*(C'\fR (as defined above)
432 enclosed in a set of parentheses.  If you do not specify a
433 \&\f(CW\*(C`Runas_Spec\*(C'\fR in the user specification, a default \f(CW\*(C`Runas_Spec\*(C'\fR
434 of \fBroot\fR will be used.  A \f(CW\*(C`Runas_Spec\*(C'\fR sets the default for
435 commands that follow it.  What this means is that for the entry:
436 .PP
437 .Vb 1
438 \& dgb    boulder = (operator) /bin/ls, /bin/kill, /usr/bin/lprm
439 .Ve
440 .PP
441 The user \fBdgb\fR may run \fI/bin/ls\fR, \fI/bin/kill\fR, and
442 \&\fI/usr/bin/lprm\fR \*(-- but only as \fBoperator\fR.  E.g.,
443 .PP
444 .Vb 1
445 \& $ sudo -u operator /bin/ls.
446 .Ve
447 .PP
448 It is also possible to override a \f(CW\*(C`Runas_Spec\*(C'\fR later on in an
449 entry.  If we modify the entry like so:
450 .PP
451 .Vb 1
452 \& dgb    boulder = (operator) /bin/ls, (root) /bin/kill, /usr/bin/lprm
453 .Ve
454 .PP
455 Then user \fBdgb\fR is now allowed to run \fI/bin/ls\fR as \fBoperator\fR,
456 but  \fI/bin/kill\fR and \fI/usr/bin/lprm\fR as \fBroot\fR.
457 .Sh "Tag_Spec"
458 .IX Subsection "Tag_Spec"
459 A command may have zero or more tags associated with it.  There are
460 six possible tag values, \f(CW\*(C`NOPASSWD\*(C'\fR, \f(CW\*(C`PASSWD\*(C'\fR, \f(CW\*(C`NOEXEC\*(C'\fR, \f(CW\*(C`EXEC\*(C'\fR,
461 \&\f(CW\*(C`SETENV\*(C'\fR and \f(CW\*(C`NOSETENV\*(C'\fR.
462 Once a tag is set on a \f(CW\*(C`Cmnd\*(C'\fR, subsequent \f(CW\*(C`Cmnd\*(C'\fRs in the
463 \&\f(CW\*(C`Cmnd_Spec_List\*(C'\fR, inherit the tag unless it is overridden by the
464 opposite tag (i.e.: \f(CW\*(C`PASSWD\*(C'\fR overrides \f(CW\*(C`NOPASSWD\*(C'\fR and \f(CW\*(C`NOEXEC\*(C'\fR
465 overrides \f(CW\*(C`EXEC\*(C'\fR).
466 .PP
467 \fI\s-1NOPASSWD\s0 and \s-1PASSWD\s0\fR
468 .IX Subsection "NOPASSWD and PASSWD"
469 .PP
470 By default, \fBsudo\fR requires that a user authenticate him or herself
471 before running a command.  This behavior can be modified via the
472 \&\f(CW\*(C`NOPASSWD\*(C'\fR tag.  Like a \f(CW\*(C`Runas_Spec\*(C'\fR, the \f(CW\*(C`NOPASSWD\*(C'\fR tag sets
473 a default for the commands that follow it in the \f(CW\*(C`Cmnd_Spec_List\*(C'\fR.
474 Conversely, the \f(CW\*(C`PASSWD\*(C'\fR tag can be used to reverse things.
475 For example:
476 .PP
477 .Vb 1
478 \& ray    rushmore = NOPASSWD: /bin/kill, /bin/ls, /usr/bin/lprm
479 .Ve
480 .PP
481 would allow the user \fBray\fR to run \fI/bin/kill\fR, \fI/bin/ls\fR, and
482 \&\fI/usr/bin/lprm\fR as root on the machine rushmore as \fBroot\fR without
483 authenticating himself.  If we only want \fBray\fR to be able to
484 run \fI/bin/kill\fR without a password the entry would be:
485 .PP
486 .Vb 1
487 \& ray    rushmore = NOPASSWD: /bin/kill, PASSWD: /bin/ls, /usr/bin/lprm
488 .Ve
489 .PP
490 Note, however, that the \f(CW\*(C`PASSWD\*(C'\fR tag has no effect on users who are
491 in the group specified by the \fIexempt_group\fR option.
492 .PP
493 By default, if the \f(CW\*(C`NOPASSWD\*(C'\fR tag is applied to any of the entries
494 for a user on the current host, he or she will be able to run
495 \&\f(CW\*(C`sudo \-l\*(C'\fR without a password.  Additionally, a user may only run
496 \&\f(CW\*(C`sudo \-v\*(C'\fR without a password if the \f(CW\*(C`NOPASSWD\*(C'\fR tag is present
497 for all a user's entries that pertain to the current host.
498 This behavior may be overridden via the verifypw and listpw options.
499 .PP
500 \fI\s-1NOEXEC\s0 and \s-1EXEC\s0\fR
501 .IX Subsection "NOEXEC and EXEC"
502 .PP
503 If \fBsudo\fR has been compiled with \fInoexec\fR support and the underlying
504 operating system supports it, the \f(CW\*(C`NOEXEC\*(C'\fR tag can be used to prevent
505 a dynamically-linked executable from running further commands itself.
506 .PP
507 In the following example, user \fBaaron\fR may run \fI/usr/bin/more\fR
508 and \fI/usr/bin/vi\fR but shell escapes will be disabled.
509 .PP
510 .Vb 1
511 \& aaron  shanty = NOEXEC: /usr/bin/more, /usr/bin/vi
512 .Ve
513 .PP
514 See the \*(L"\s-1PREVENTING\s0 \s-1SHELL\s0 \s-1ESCAPES\s0\*(R" section below for more details
515 on how \f(CW\*(C`NOEXEC\*(C'\fR works and whether or not it will work on your system.
516 .PP
517 \fI\s-1SETENV\s0 and \s-1NOSETENV\s0\fR
518 .IX Subsection "SETENV and NOSETENV"
519 .PP
520 These tags override the value of the \fIsetenv\fR option on a per-command
521 basis.  Note that if \f(CW\*(C`SETENV\*(C'\fR has been set for a command, any
522 environment variables set on the command line way are not subject
523 to the restrictions imposed by \fIenv_check\fR, \fIenv_delete\fR, or
524 \&\fIenv_keep\fR.  As such, only trusted users should be allowed to set
525 variables in this manner.
526 .Sh "Wildcards"
527 .IX Subsection "Wildcards"
528 \&\fBsudo\fR allows shell-style \fIwildcards\fR (aka meta or glob characters)
529 to be used in pathnames as well as command line arguments in the
530 \&\fIsudoers\fR file.  Wildcard matching is done via the \fB\s-1POSIX\s0\fR
531 \&\fIfnmatch\fR\|(3) routine.  Note that these are \fInot\fR regular expressions.
532 .ie n .IP "\*(C`*\*(C'" 8
533 .el .IP "\f(CW\*(C`*\*(C'\fR" 8
534 .IX Item "*"
535 Matches any set of zero or more characters.
536 .ie n .IP "\*(C`?\*(C'" 8
537 .el .IP "\f(CW\*(C`?\*(C'\fR" 8
538 .IX Item "?"
539 Matches any single character.
540 .ie n .IP "\*(C`[...]\*(C'" 8
541 .el .IP "\f(CW\*(C`[...]\*(C'\fR" 8
542 .IX Item "[...]"
543 Matches any character in the specified range.
544 .ie n .IP "\*(C`[!...]\*(C'" 8
545 .el .IP "\f(CW\*(C`[!...]\*(C'\fR" 8
546 .IX Item "[!...]"
547 Matches any character \fBnot\fR in the specified range.
548 .ie n .IP "\*(C`\ex\*(C'" 8
549 .el .IP "\f(CW\*(C`\ex\*(C'\fR" 8
550 .IX Item "x"
551 For any character \*(L"x\*(R", evaluates to \*(L"x\*(R".  This is used to
552 escape special characters such as: \*(L"*\*(R", \*(L"?\*(R", \*(L"[\*(R", and \*(L"}\*(R".
553 .PP
554 Note that a forward slash ('/') will \fBnot\fR be matched by
555 wildcards used in the pathname.  When matching the command
556 line arguments, however, a slash \fBdoes\fR get matched by
557 wildcards.  This is to make a path like:
558 .PP
559 .Vb 1
560 \&    /usr/bin/*
561 .Ve
562 .PP
563 match \fI/usr/bin/who\fR but not \fI/usr/bin/X11/xterm\fR.
564 .Sh "Exceptions to wildcard rules"
565 .IX Subsection "Exceptions to wildcard rules"
566 The following exceptions apply to the above rules:
567 .ie n .IP """""" 8
568 .el .IP "\f(CW``''\fR" 8
569 .IX Item """"""
570 If the empty string \f(CW""\fR is the only command line argument in the
571 \&\fIsudoers\fR entry it means that command is not allowed to be run
572 with \fBany\fR arguments.
573 .Sh "Other special characters and reserved words"
574 .IX Subsection "Other special characters and reserved words"
575 The pound sign ('#') is used to indicate a comment (unless it is
576 part of a #include directive or unless it occurs in the context of
577 a user name and is followed by one or more digits, in which case
578 it is treated as a uid).  Both the comment character and any text
579 after it, up to the end of the line, are ignored.
580 .PP
581 The reserved word \fB\s-1ALL\s0\fR is a built-in \fIalias\fR that always causes
582 a match to succeed.  It can be used wherever one might otherwise
583 use a \f(CW\*(C`Cmnd_Alias\*(C'\fR, \f(CW\*(C`User_Alias\*(C'\fR, \f(CW\*(C`Runas_Alias\*(C'\fR, or \f(CW\*(C`Host_Alias\*(C'\fR.
584 You should not try to define your own \fIalias\fR called \fB\s-1ALL\s0\fR as the
585 built-in alias will be used in preference to your own.  Please note
586 that using \fB\s-1ALL\s0\fR can be dangerous since in a command context, it
587 allows the user to run \fBany\fR command on the system.
588 .PP
589 An exclamation point ('!') can be used as a logical \fInot\fR operator
590 both in an \fIalias\fR and in front of a \f(CW\*(C`Cmnd\*(C'\fR.  This allows one to
591 exclude certain values.  Note, however, that using a \f(CW\*(C`!\*(C'\fR in
592 conjunction with the built-in \f(CW\*(C`ALL\*(C'\fR alias to allow a user to
593 run \*(L"all but a few\*(R" commands rarely works as intended (see \s-1SECURITY\s0
594 \&\s-1NOTES\s0 below).
595 .PP
596 Long lines can be continued with a backslash ('\e') as the last
597 character on the line.
598 .PP
599 Whitespace between elements in a list as well as special syntactic
600 characters in a \fIUser Specification\fR ('=', ':', '(', ')') is optional.
601 .PP
602 The following characters must be escaped with a backslash ('\e') when
603 used as part of a word (e.g.\ a username or hostname):
604 \&'@', '!', '=', ':', ',', '(', ')', '\e'.
605 .SH "SUDOERS OPTIONS"
606 .IX Header "SUDOERS OPTIONS"
607 \&\fBsudo\fR's behavior can be modified by \f(CW\*(C`Default_Entry\*(C'\fR lines, as
608 explained earlier.  A list of all supported Defaults parameters,
609 grouped by type, are listed below.
610 .PP
611 \&\fBFlags\fR:
612 .IP "always_set_home" 16
613 .IX Item "always_set_home"
614 If set, \fBsudo\fR will set the \f(CW\*(C`HOME\*(C'\fR environment variable to the home
615 directory of the target user (which is root unless the \fB\-u\fR option is used).
616 This effectively means that the \fB\-H\fR flag is always implied.
617 This flag is \fIoff\fR by default.
618 .IP "authenticate" 16
619 .IX Item "authenticate"
620 If set, users must authenticate themselves via a password (or other
621 means of authentication) before they may run commands.  This default
622 may be overridden via the \f(CW\*(C`PASSWD\*(C'\fR and \f(CW\*(C`NOPASSWD\*(C'\fR tags.
623 This flag is \fIon\fR by default.
624 .IP "env_editor" 16
625 .IX Item "env_editor"
626 If set, \fBvisudo\fR will use the value of the \s-1EDITOR\s0 or \s-1VISUAL\s0
627 environment variables before falling back on the default editor list.
628 Note that this may create a security hole as it allows the user to
629 run any arbitrary command as root without logging.  A safer alternative
630 is to place a colon-separated list of editors in the \f(CW\*(C`editor\*(C'\fR
631 variable.  \fBvisudo\fR will then only use the \s-1EDITOR\s0 or \s-1VISUAL\s0 if
632 they match a value specified in \f(CW\*(C`editor\*(C'\fR.  This flag is \fI@env_editor@\fR by
633 default.
634 .IP "env_reset" 16
635 .IX Item "env_reset"
636 If set, \fBsudo\fR will reset the environment to only contain the
637 \&\s-1LOGNAME\s0, \s-1SHELL\s0, \s-1USER\s0, \s-1USERNAME\s0 and the \f(CW\*(C`SUDO_*\*(C'\fR variables.  Any
638 variables in the caller's environment that match the \f(CW\*(C`env_keep\*(C'\fR
639 and \f(CW\*(C`env_check\*(C'\fR lists are then added.  The default contents of the
640 \&\f(CW\*(C`env_keep\*(C'\fR and \f(CW\*(C`env_check\*(C'\fR lists are displayed when \fBsudo\fR is
641 run by root with the \fI\-V\fR option.  If \fBsudo\fR was compiled with
642 the \f(CW\*(C`SECURE_PATH\*(C'\fR option, its value will be used for the \f(CW\*(C`PATH\*(C'\fR
643 environment variable.  This flag is \fIon\fR by default.
644 .IP "fqdn" 16
645 .IX Item "fqdn"
646 Set this flag if you want to put fully qualified hostnames in the
647 \&\fIsudoers\fR file.  I.e., instead of myhost you would use myhost.mydomain.edu.
648 You may still use the short form if you wish (and even mix the two).
649 Beware that turning on \fIfqdn\fR requires \fBsudo\fR to make \s-1DNS\s0 lookups
650 which may make \fBsudo\fR unusable if \s-1DNS\s0 stops working (for example
651 if the machine is not plugged into the network).  Also note that
652 you must use the host's official name as \s-1DNS\s0 knows it.  That is,
653 you may not use a host alias (\f(CW\*(C`CNAME\*(C'\fR entry) due to performance
654 issues and the fact that there is no way to get all aliases from
655 \&\s-1DNS\s0.  If your machine's hostname (as returned by the \f(CW\*(C`hostname\*(C'\fR
656 command) is already fully qualified you shouldn't need to set
657 \&\fIfqdn\fR.  This flag is \fI@fqdn@\fR by default.
658 .IP "ignore_dot" 16
659 .IX Item "ignore_dot"
660 If set, \fBsudo\fR will ignore '.' or '' (current dir) in the \f(CW\*(C`PATH\*(C'\fR
661 environment variable; the \f(CW\*(C`PATH\*(C'\fR itself is not modified.  This
662 flag is \fI@ignore_dot@\fR by default.  Currently, while it is possible
663 to set \fIignore_dot\fR in \fIsudoers\fR, its value is not used.  This option
664 should be considered read-only (it will be fixed in a future version
665 of \fBsudo\fR).
666 .IP "ignore_local_sudoers" 16
667 .IX Item "ignore_local_sudoers"
668 If set via \s-1LDAP\s0, parsing of \f(CW@sysconfdir\fR@/sudoers will be skipped.
669 This is intended for Enterprises that wish to prevent the usage of local
670 sudoers files so that only \s-1LDAP\s0 is used.  This thwarts the efforts of
671 rogue operators who would attempt to add roles to \f(CW@sysconfdir\fR@/sudoers.
672 When this option is present, \f(CW@sysconfdir\fR@/sudoers does not even need to exist. 
673 Since this option tells \fBsudo\fR how to behave when no specific \s-1LDAP\s0 entries
674 have been matched, this sudoOption is only meaningful for the cn=defaults
675 section.  This flag is \fIoff\fR by default.
676 .IP "insults" 16
677 .IX Item "insults"
678 If set, \fBsudo\fR will insult users when they enter an incorrect
679 password.  This flag is \fI@insults@\fR by default.
680 .IP "log_host" 16
681 .IX Item "log_host"
682 If set, the hostname will be logged in the (non\-syslog) \fBsudo\fR log file.
683 This flag is \fIoff\fR by default.
684 .IP "log_year" 16
685 .IX Item "log_year"
686 If set, the four-digit year will be logged in the (non\-syslog) \fBsudo\fR log file.
687 This flag is \fIoff\fR by default.
688 .IP "long_otp_prompt" 16
689 .IX Item "long_otp_prompt"
690 When validating with a One Time Password (\s-1OPT\s0) scheme such as
691 \&\fBS/Key\fR or \fB\s-1OPIE\s0\fR, a two-line prompt is used to make it easier
692 to cut and paste the challenge to a local window.  It's not as
693 pretty as the default but some people find it more convenient.  This
694 flag is \fI@long_otp_prompt@\fR by default.
695 .IP "mail_always" 16
696 .IX Item "mail_always"
697 Send mail to the \fImailto\fR user every time a users runs \fBsudo\fR.
698 This flag is \fIoff\fR by default.
699 .IP "mail_badpass" 16
700 .IX Item "mail_badpass"
701 Send mail to the \fImailto\fR user if the user running \fBsudo\fR does not
702 enter the correct password.  This flag is \fIoff\fR by default.
703 .IP "mail_no_host" 16
704 .IX Item "mail_no_host"
705 If set, mail will be sent to the \fImailto\fR user if the invoking
706 user exists in the \fIsudoers\fR file, but is not allowed to run
707 commands on the current host.  This flag is \fI@mail_no_host@\fR by default.
708 .IP "mail_no_perms" 16
709 .IX Item "mail_no_perms"
710 If set, mail will be sent to the \fImailto\fR user if the invoking
711 user is allowed to use \fBsudo\fR but the command they are trying is not
712 listed in their \fIsudoers\fR file entry or is explicitly denied.
713 This flag is \fI@mail_no_perms@\fR by default.
714 .IP "mail_no_user" 16
715 .IX Item "mail_no_user"
716 If set, mail will be sent to the \fImailto\fR user if the invoking
717 user is not in the \fIsudoers\fR file.  This flag is \fI@mail_no_user@\fR
718 by default.
719 .IP "noexec" 16
720 .IX Item "noexec"
721 If set, all commands run via \fBsudo\fR will behave as if the \f(CW\*(C`NOEXEC\*(C'\fR
722 tag has been set, unless overridden by a \f(CW\*(C`EXEC\*(C'\fR tag.  See the
723 description of \fI\s-1NOEXEC\s0 and \s-1EXEC\s0\fR below as well as the \*(L"\s-1PREVENTING\s0 \s-1SHELL\s0 \s-1ESCAPES\s0\*(R" section at the end of this manual.  This flag is \fIoff\fR by default.
724 .IP "path_info" 16
725 .IX Item "path_info"
726 Normally, \fBsudo\fR will tell the user when a command could not be
727 found in their \f(CW\*(C`PATH\*(C'\fR environment variable.  Some sites may wish
728 to disable this as it could be used to gather information on the
729 location of executables that the normal user does not have access
730 to.  The disadvantage is that if the executable is simply not in
731 the user's \f(CW\*(C`PATH\*(C'\fR, \fBsudo\fR will tell the user that they are not
732 allowed to run it, which can be confusing.  This flag is \fI@path_info@\fR
733 by default.
734 .IP "preserve_groups" 16
735 .IX Item "preserve_groups"
736 By default \fBsudo\fR will initialize the group vector to the list of
737 groups the target user is in.  When \fIpreserve_groups\fR is set, the
738 user's existing group vector is left unaltered.  The real and
739 effective group IDs, however, are still set to match the target
740 user.  This flag is \fIoff\fR by default.
741 .IP "requiretty" 16
742 .IX Item "requiretty"
743 If set, \fBsudo\fR will only run when the user is logged in to a real
744 tty.  This will disallow things like \f(CW"rsh somehost sudo ls"\fR since
745 \&\fIrsh\fR\|(1) does not allocate a tty.  Because it is not possible to turn
746 off echo when there is no tty present, some sites may wish to set
747 this flag to prevent a user from entering a visible password.  This
748 flag is \fIoff\fR by default.
749 .IP "root_sudo" 16
750 .IX Item "root_sudo"
751 If set, root is allowed to run \fBsudo\fR too.  Disabling this prevents users
752 from \*(L"chaining\*(R" \fBsudo\fR commands to get a root shell by doing something
753 like \f(CW"sudo sudo /bin/sh"\fR.  Note, however, that turning off \fIroot_sudo\fR
754 will also prevent root and from running \fBsudoedit\fR.
755 Disabling \fIroot_sudo\fR provides no real additional security; it
756 exists purely for historical reasons.
757 This flag is \fI@root_sudo@\fR by default.
758 .IP "rootpw" 16
759 .IX Item "rootpw"
760 If set, \fBsudo\fR will prompt for the root password instead of the password
761 of the invoking user.  This flag is \fIoff\fR by default.
762 .IP "runaspw" 16
763 .IX Item "runaspw"
764 If set, \fBsudo\fR will prompt for the password of the user defined by the
765 \&\fIrunas_default\fR option (defaults to \f(CW\*(C`@runas_default@\*(C'\fR) instead of the
766 password of the invoking user.  This flag is \fIoff\fR by default.
767 .IP "set_home" 16
768 .IX Item "set_home"
769 If set and \fBsudo\fR is invoked with the \fB\-s\fR flag the \f(CW\*(C`HOME\*(C'\fR
770 environment variable will be set to the home directory of the target
771 user (which is root unless the \fB\-u\fR option is used).  This effectively
772 makes the \fB\-s\fR flag imply \fB\-H\fR.  This flag is \fIoff\fR by default.
773 .IP "set_logname" 16
774 .IX Item "set_logname"
775 Normally, \fBsudo\fR will set the \f(CW\*(C`LOGNAME\*(C'\fR, \f(CW\*(C`USER\*(C'\fR and \f(CW\*(C`USERNAME\*(C'\fR
776 environment variables to the name of the target user (usually root
777 unless the \fB\-u\fR flag is given).  However, since some programs
778 (including the \s-1RCS\s0 revision control system) use \f(CW\*(C`LOGNAME\*(C'\fR to
779 determine the real identity of the user, it may be desirable to
780 change this behavior.  This can be done by negating the set_logname
781 option.  Note that if the \fIenv_reset\fR option has not been disabled,
782 entries in the \fIenv_keep\fR list will override the value of
783 \&\fIset_logname\fR.  This flag is \fIoff\fR by default.
784 .IP "setenv" 16
785 .IX Item "setenv"
786 Allow the user to disable the \fIenv_reset\fR option from the command
787 line.  Additionally, environment variables set via the command line
788 are not subject to the restrictions imposed by \fIenv_check\fR,
789 \&\fIenv_delete\fR, or \fIenv_keep\fR.  As such, only trusted users should
790 be allowed to set variables in this manner.  This flag is \fIoff\fR
791 by default.
792 .IP "shell_noargs" 16
793 .IX Item "shell_noargs"
794 If set and \fBsudo\fR is invoked with no arguments it acts as if the
795 \&\fB\-s\fR flag had been given.  That is, it runs a shell as root (the
796 shell is determined by the \f(CW\*(C`SHELL\*(C'\fR environment variable if it is
797 set, falling back on the shell listed in the invoking user's
798 /etc/passwd entry if not).  This flag is \fIoff\fR by default.
799 .IP "stay_setuid" 16
800 .IX Item "stay_setuid"
801 Normally, when \fBsudo\fR executes a command the real and effective
802 UIDs are set to the target user (root by default).  This option
803 changes that behavior such that the real \s-1UID\s0 is left as the invoking
804 user's \s-1UID\s0.  In other words, this makes \fBsudo\fR act as a setuid
805 wrapper.  This can be useful on systems that disable some potentially
806 dangerous functionality when a program is run setuid.  This option
807 is only effective on systems with either the \fIsetreuid()\fR or \fIsetresuid()\fR
808 function.  This flag is \fIoff\fR by default.
809 .IP "targetpw" 16
810 .IX Item "targetpw"
811 If set, \fBsudo\fR will prompt for the password of the user specified by
812 the \fB\-u\fR flag (defaults to \f(CW\*(C`root\*(C'\fR) instead of the password of the
813 invoking user.  Note that this precludes the use of a uid not listed
814 in the passwd database as an argument to the \fB\-u\fR flag.
815 This flag is \fIoff\fR by default.
816 .IP "tty_tickets" 16
817 .IX Item "tty_tickets"
818 If set, users must authenticate on a per-tty basis.  Normally,
819 \&\fBsudo\fR uses a directory in the ticket dir with the same name as
820 the user running it.  With this flag enabled, \fBsudo\fR will use a
821 file named for the tty the user is logged in on in that directory.
822 This flag is \fI@tty_tickets@\fR by default.
823 .IP "use_loginclass" 16
824 .IX Item "use_loginclass"
825 If set, \fBsudo\fR will apply the defaults specified for the target user's
826 login class if one exists.  Only available if \fBsudo\fR is configured with
827 the \-\-with\-logincap option.  This flag is \fIoff\fR by default.
828 .PP
829 \&\fBIntegers\fR:
830 .IP "passwd_tries" 16
831 .IX Item "passwd_tries"
832 The number of tries a user gets to enter his/her password before
833 \&\fBsudo\fR logs the failure and exits.  The default is \f(CW\*(C`@passwd_tries@\*(C'\fR.
834 .PP
835 \&\fBIntegers that can be used in a boolean context\fR:
836 .IP "loglinelen" 16
837 .IX Item "loglinelen"
838 Number of characters per line for the file log.  This value is used
839 to decide when to wrap lines for nicer log files.  This has no
840 effect on the syslog log file, only the file log.  The default is
841 \&\f(CW\*(C`@loglen@\*(C'\fR (use 0 or negate the option to disable word wrap).
842 .IP "passwd_timeout" 16
843 .IX Item "passwd_timeout"
844 Number of minutes before the \fBsudo\fR password prompt times out.
845 The default is \f(CW\*(C`@password_timeout@\*(C'\fR; set this to \f(CW0\fR for no password timeout.
846 .IP "timestamp_timeout" 16
847 .IX Item "timestamp_timeout"
848 Number of minutes that can elapse before \fBsudo\fR will ask for a
849 passwd again.  The default is \f(CW\*(C`@timeout@\*(C'\fR.  Set this to \f(CW0\fR to always
850 prompt for a password.
851 If set to a value less than \f(CW0\fR the user's timestamp will never
852 expire.  This can be used to allow users to create or delete their
853 own timestamps via \f(CW\*(C`sudo \-v\*(C'\fR and \f(CW\*(C`sudo \-k\*(C'\fR respectively.
854 .IP "umask" 16
855 .IX Item "umask"
856 Umask to use when running the command.  Negate this option or set
857 it to 0777 to preserve the user's umask.  The default is \f(CW\*(C`@sudo_umask@\*(C'\fR.
858 .PP
859 \&\fBStrings\fR:
860 .IP "badpass_message" 16
861 .IX Item "badpass_message"
862 Message that is displayed if a user enters an incorrect password.
863 The default is \f(CW\*(C`@badpass_message@\*(C'\fR unless insults are enabled.
864 .IP "editor" 16
865 .IX Item "editor"
866 A colon (':') separated list of editors allowed to be used with
867 \&\fBvisudo\fR.  \fBvisudo\fR will choose the editor that matches the user's
868 \&\s-1EDITOR\s0 environment variable if possible, or the first editor in the
869 list that exists and is executable.  The default is the path to vi
870 on your system.
871 .IP "mailsub" 16
872 .IX Item "mailsub"
873 Subject of the mail sent to the \fImailto\fR user. The escape \f(CW%h\fR
874 will expand to the hostname of the machine.
875 Default is \f(CW\*(C`@mailsub@\*(C'\fR.
876 .IP "noexec_file" 16
877 .IX Item "noexec_file"
878 Path to a shared library containing dummy versions of the \fIexecv()\fR,
879 \&\fIexecve()\fR and \fIfexecve()\fR library functions that just return an error.
880 This is used to implement the \fInoexec\fR functionality on systems that
881 support \f(CW\*(C`LD_PRELOAD\*(C'\fR or its equivalent.  Defaults to \fI@noexec_file@\fR.
882 .IP "passprompt" 16
883 .IX Item "passprompt"
884 The default prompt to use when asking for a password; can be overridden
885 via the \fB\-p\fR option or the \f(CW\*(C`SUDO_PROMPT\*(C'\fR environment variable.
886 The following percent (`\f(CW\*(C`%\*(C'\fR') escapes are supported:
887 .RS 16
888 .ie n .IP "%H" 4
889 .el .IP "\f(CW%H\fR" 4
890 .IX Item "%H"
891 expanded to the local hostname including the domain name
892 (on if the machine's hostname is fully qualified or the \fIfqdn\fR
893 option is set)
894 .ie n .IP "%h" 4
895 .el .IP "\f(CW%h\fR" 4
896 .IX Item "%h"
897 expanded to the local hostname without the domain name
898 .ie n .IP "%U" 4
899 .el .IP "\f(CW%U\fR" 4
900 .IX Item "%U"
901 expanded to the login name of the user the command will
902 be run as (defaults to root)
903 .ie n .IP "%u" 4
904 .el .IP "\f(CW%u\fR" 4
905 .IX Item "%u"
906 expanded to the invoking user's login name
907 .ie n .IP "\*(C`%%\*(C'" 4
908 .el .IP "\f(CW\*(C`%%\*(C'\fR" 4
909 .IX Item "%%"
910 two consecutive \f(CW\*(C`%\*(C'\fR characters are collapsed into a single \f(CW\*(C`%\*(C'\fR character
911 .RE
912 .RS 16
913 .Sp
914 The default value is \f(CW\*(C`@passprompt@\*(C'\fR.
915 .RE
916 .IP "runas_default" 16
917 .IX Item "runas_default"
918 The default user to run commands as if the \fB\-u\fR flag is not specified
919 on the command line.  This defaults to \f(CW\*(C`@runas_default@\*(C'\fR.
920 Note that if \fIrunas_default\fR is set it \fBmust\fR occur before
921 any \f(CW\*(C`Runas_Alias\*(C'\fR specifications.
922 .IP "syslog_badpri" 16
923 .IX Item "syslog_badpri"
924 Syslog priority to use when user authenticates unsuccessfully.
925 Defaults to \f(CW\*(C`@badpri@\*(C'\fR.
926 .IP "syslog_goodpri" 16
927 .IX Item "syslog_goodpri"
928 Syslog priority to use when user authenticates successfully.
929 Defaults to \f(CW\*(C`@goodpri@\*(C'\fR.
930 .IP "timestampdir" 16
931 .IX Item "timestampdir"
932 The directory in which \fBsudo\fR stores its timestamp files.
933 The default is \fI@timedir@\fR.
934 .IP "timestampowner" 16
935 .IX Item "timestampowner"
936 The owner of the timestamp directory and the timestamps stored therein.
937 The default is \f(CW\*(C`root\*(C'\fR.
938 .PP
939 \&\fBStrings that can be used in a boolean context\fR:
940 .IP "exempt_group" 12
941 .IX Item "exempt_group"
942 Users in this group are exempt from password and \s-1PATH\s0 requirements.
943 This is not set by default.
944 .IP "lecture" 12
945 .IX Item "lecture"
946 This option controls when a short lecture will be printed along with
947 the password prompt.  It has the following possible values:
948 .RS 12
949 .IP "always" 8
950 .IX Item "always"
951 Always lecture the user.
952 .IP "never" 8
953 .IX Item "never"
954 Never lecture the user.
955 .IP "once" 8
956 .IX Item "once"
957 Only lecture the user the first time they run \fBsudo\fR.
958 .RE
959 .RS 12
960 .Sp
961 If no value is specified, a value of \fIonce\fR is implied.
962 Negating the option results in a value of \fInever\fR being used.
963 The default value is \fI@lecture@\fR.
964 .RE
965 .IP "lecture_file" 12
966 .IX Item "lecture_file"
967 Path to a file containing an alternate \fBsudo\fR lecture that will
968 be used in place of the standard lecture if the named file exists.
969 By default, \fBsudo\fR uses a built-in lecture.
970 .IP "listpw" 12
971 .IX Item "listpw"
972 This option controls when a password will be required when a
973 user runs \fBsudo\fR with the \fB\-l\fR flag.  It has the following possible values:
974 .RS 12
975 .IP "all" 8
976 .IX Item "all"
977 All the user's \fIsudoers\fR entries for the current host must have
978 the \f(CW\*(C`NOPASSWD\*(C'\fR flag set to avoid entering a password.
979 .IP "always" 8
980 .IX Item "always"
981 The user must always enter a password to use the \fB\-l\fR flag.
982 .IP "any" 8
983 .IX Item "any"
984 At least one of the user's \fIsudoers\fR entries for the current host
985 must have the \f(CW\*(C`NOPASSWD\*(C'\fR flag set to avoid entering a password.
986 .IP "never" 8
987 .IX Item "never"
988 The user need never enter a password to use the \fB\-l\fR flag.
989 .RE
990 .RS 12
991 .Sp
992 If no value is specified, a value of \fIany\fR is implied.
993 Negating the option results in a value of \fInever\fR being used.
994 The default value is \fIany\fR.
995 .RE
996 .IP "logfile" 12
997 .IX Item "logfile"
998 Path to the \fBsudo\fR log file (not the syslog log file).  Setting a path
999 turns on logging to a file; negating this option turns it off.
1000 By default, \fBsudo\fR logs via syslog.
1001 .IP "mailerflags" 12
1002 .IX Item "mailerflags"
1003 Flags to use when invoking mailer. Defaults to \fB\-t\fR.
1004 .IP "mailerpath" 12
1005 .IX Item "mailerpath"
1006 Path to mail program used to send warning mail.
1007 Defaults to the path to sendmail found at configure time.
1008 .IP "mailto" 12
1009 .IX Item "mailto"
1010 Address to send warning and error mail to.  The address should
1011 be enclosed in double quotes (\f(CW\*(C`"\*(C'\fR) to protect against \fBsudo\fR
1012 interpreting the \f(CW\*(C`@\*(C'\fR sign.  Defaults to \f(CW\*(C`@mailto@\*(C'\fR.
1013 .IP "exempt_group" 12
1014 .IX Item "exempt_group"
1015 Users in this group are exempt from password and \s-1PATH\s0 requirements.
1016 On Debian systems, this is set to the group 'sudo' by default. 
1017 .IP "syslog" 12
1018 .IX Item "syslog"
1019 Syslog facility if syslog is being used for logging (negate to
1020 disable syslog logging).  Defaults to \f(CW\*(C`@logfac@\*(C'\fR.
1021 .IP "verifypw" 12
1022 .IX Item "verifypw"
1023 This option controls when a password will be required when a user runs
1024 \&\fBsudo\fR with the \fB\-v\fR flag.  It has the following possible values:
1025 .RS 12
1026 .IP "all" 8
1027 .IX Item "all"
1028 All the user's \fIsudoers\fR entries for the current host must have
1029 the \f(CW\*(C`NOPASSWD\*(C'\fR flag set to avoid entering a password.
1030 .IP "always" 8
1031 .IX Item "always"
1032 The user must always enter a password to use the \fB\-v\fR flag.
1033 .IP "any" 8
1034 .IX Item "any"
1035 At least one of the user's \fIsudoers\fR entries for the current host
1036 must have the \f(CW\*(C`NOPASSWD\*(C'\fR flag set to avoid entering a password.
1037 .IP "never" 8
1038 .IX Item "never"
1039 The user need never enter a password to use the \fB\-v\fR flag.
1040 .RE
1041 .RS 12
1042 .Sp
1043 If no value is specified, a value of \fIall\fR is implied.
1044 Negating the option results in a value of \fInever\fR being used.
1045 The default value is \fIall\fR.
1046 .RE
1047 .PP
1048 \&\fBLists that can be used in a boolean context\fR:
1049 .IP "env_check" 16
1050 .IX Item "env_check"
1051 Environment variables to be removed from the user's environment if
1052 the variable's value contains \f(CW\*(C`%\*(C'\fR or \f(CW\*(C`/\*(C'\fR characters.  This can
1053 be used to guard against printf-style format vulnerabilities in
1054 poorly-written programs.  The argument may be a double\-quoted,
1055 space-separated list or a single value without double\-quotes.  The
1056 list can be replaced, added to, deleted from, or disabled by using
1057 the \f(CW\*(C`=\*(C'\fR, \f(CW\*(C`+=\*(C'\fR, \f(CW\*(C`\-=\*(C'\fR, and \f(CW\*(C`!\*(C'\fR operators respectively.  Regardless
1058 of whether the \f(CW\*(C`env_reset\*(C'\fR option is enabled or disabled, variables
1059 specified by \f(CW\*(C`env_check\*(C'\fR will be preserved in the environment if
1060 they pass the aforementioned check.  The default list of environment
1061 variables to check is displayed when \fBsudo\fR is run by root with
1062 the \fI\-V\fR option.
1063 .IP "env_delete" 16
1064 .IX Item "env_delete"
1065 Environment variables to be removed from the user's environment.
1066 The argument may be a double\-quoted, space-separated list or a
1067 single value without double\-quotes.  The list can be replaced, added
1068 to, deleted from, or disabled by using the \f(CW\*(C`=\*(C'\fR, \f(CW\*(C`+=\*(C'\fR, \f(CW\*(C`\-=\*(C'\fR, and
1069 \&\f(CW\*(C`!\*(C'\fR operators respectively.  The default list of environment
1070 variables to remove is displayed when \fBsudo\fR is run by root with the
1071 \&\fI\-V\fR option.  Note that many operating systems will remove potentially
1072 dangerous variables from the environment of any setuid process (such
1073 as \fBsudo\fR).
1074 .IP "env_keep" 16
1075 .IX Item "env_keep"
1076 Environment variables to be preserved in the user's environment
1077 when the \fIenv_reset\fR option is in effect.  This allows fine-grained
1078 control over the environment \fBsudo\fR\-spawned processes will receive.
1079 The argument may be a double\-quoted, space-separated list or a
1080 single value without double\-quotes.  The list can be replaced, added
1081 to, deleted from, or disabled by using the \f(CW\*(C`=\*(C'\fR, \f(CW\*(C`+=\*(C'\fR, \f(CW\*(C`\-=\*(C'\fR, and
1082 \&\f(CW\*(C`!\*(C'\fR operators respectively.  The default list of variables to keep
1083 is displayed when \fBsudo\fR is run by root with the \fI\-V\fR option.
1084 .PP
1085 When logging via \fIsyslog\fR\|(3), \fBsudo\fR accepts the following values
1086 for the syslog facility (the value of the \fBsyslog\fR Parameter):
1087 \&\fBauthpriv\fR (if your \s-1OS\s0 supports it), \fBauth\fR, \fBdaemon\fR, \fBuser\fR,
1088 \&\fBlocal0\fR, \fBlocal1\fR, \fBlocal2\fR, \fBlocal3\fR, \fBlocal4\fR, \fBlocal5\fR,
1089 \&\fBlocal6\fR, and \fBlocal7\fR.  The following syslog priorities are
1090 supported: \fBalert\fR, \fBcrit\fR, \fBdebug\fR, \fBemerg\fR, \fBerr\fR, \fBinfo\fR,
1091 \&\fBnotice\fR, and \fBwarning\fR.
1092 .SH "FILES"
1093 .IX Header "FILES"
1094 .ie n .IP "\fI@sysconfdir@/sudoers\fR\*(C`              \*(C' List of who can run what" 4
1095 .el .IP "\fI@sysconfdir@/sudoers\fR\f(CW\*(C`           \*(C'\fR List of who can run what" 4
1096 .IX Item "@sysconfdir@/sudoers           List of who can run what"
1097 .PD 0
1098 .ie n .IP "\fI/etc/group\fR\*(C`                \*(C' Local groups file" 4
1099 .el .IP "\fI/etc/group\fR\f(CW\*(C`             \*(C'\fR Local groups file" 4
1100 .IX Item "/etc/group             Local groups file"
1101 .ie n .IP "\fI/etc/netgroup\fR\*(C`             \*(C' List of network groups" 4
1102 .el .IP "\fI/etc/netgroup\fR\f(CW\*(C`          \*(C'\fR List of network groups" 4
1103 .IX Item "/etc/netgroup          List of network groups"
1104 .PD
1105 .SH "EXAMPLES"
1106 .IX Header "EXAMPLES"
1107 Since the \fIsudoers\fR file is parsed in a single pass, order is
1108 important.  In general, you should structure \fIsudoers\fR such that
1109 the \f(CW\*(C`Host_Alias\*(C'\fR, \f(CW\*(C`User_Alias\*(C'\fR, and \f(CW\*(C`Cmnd_Alias\*(C'\fR specifications
1110 come first, followed by any \f(CW\*(C`Default_Entry\*(C'\fR lines, and finally the
1111 \&\f(CW\*(C`Runas_Alias\*(C'\fR and user specifications.  The basic rule of thumb
1112 is you cannot reference an Alias that has not already been defined.
1113 .PP
1114 Below are example \fIsudoers\fR entries.  Admittedly, some of
1115 these are a bit contrived.  First, we define our \fIaliases\fR:
1116 .PP
1117 .Vb 4
1118 \& # User alias specification
1119 \& User_Alias     FULLTIMERS = millert, mikef, dowdy
1120 \& User_Alias     PARTTIMERS = bostley, jwfox, crawl
1121 \& User_Alias     WEBMASTERS = will, wendy, wim
1122 .Ve
1123 .PP
1124 .Vb 3
1125 \& # Runas alias specification
1126 \& Runas_Alias    OP = root, operator
1127 \& Runas_Alias    DB = oracle, sybase
1128 .Ve
1129 .PP
1130 .Vb 9
1131 \& # Host alias specification
1132 \& Host_Alias     SPARC = bigtime, eclipse, moet, anchor :\e
1133 \&                SGI = grolsch, dandelion, black :\e
1134 \&                ALPHA = widget, thalamus, foobar :\e
1135 \&                HPPA = boa, nag, python
1136 \& Host_Alias     CUNETS = 128.138.0.0/255.255.0.0
1137 \& Host_Alias     CSNETS = 128.138.243.0, 128.138.204.0/24, 128.138.242.0
1138 \& Host_Alias     SERVERS = master, mail, www, ns
1139 \& Host_Alias     CDROM = orion, perseus, hercules
1140 .Ve
1141 .PP
1142 .Vb 13
1143 \& # Cmnd alias specification
1144 \& Cmnd_Alias     DUMPS = /usr/bin/mt, /usr/sbin/dump, /usr/sbin/rdump,\e
1145 \&                        /usr/sbin/restore, /usr/sbin/rrestore
1146 \& Cmnd_Alias     KILL = /usr/bin/kill
1147 \& Cmnd_Alias     PRINTING = /usr/sbin/lpc, /usr/bin/lprm
1148 \& Cmnd_Alias     SHUTDOWN = /usr/sbin/shutdown
1149 \& Cmnd_Alias     HALT = /usr/sbin/halt
1150 \& Cmnd_Alias     REBOOT = /usr/sbin/reboot
1151 \& Cmnd_Alias     SHELLS = /usr/bin/sh, /usr/bin/csh, /usr/bin/ksh, \e
1152 \&                         /usr/local/bin/tcsh, /usr/bin/rsh, \e
1153 \&                         /usr/local/bin/zsh
1154 \& Cmnd_Alias     SU = /usr/bin/su
1155 \& Cmnd_Alias     PAGERS = /usr/bin/more, /usr/bin/pg, /usr/bin/less
1156 .Ve
1157 .PP
1158 Here we override some of the compiled in default values.  We want
1159 \&\fBsudo\fR to log via \fIsyslog\fR\|(3) using the \fIauth\fR facility in all
1160 cases.  We don't want to subject the full time staff to the \fBsudo\fR
1161 lecture, user \fBmillert\fR need not give a password, and we don't
1162 want to reset the \f(CW\*(C`LOGNAME\*(C'\fR, \f(CW\*(C`USER\*(C'\fR or \f(CW\*(C`USERNAME\*(C'\fR environment
1163 variables when running commands as root.  Additionally, on the
1164 machines in the \fI\s-1SERVERS\s0\fR \f(CW\*(C`Host_Alias\*(C'\fR, we keep an additional
1165 local log file and make sure we log the year in each log line since
1166 the log entries will be kept around for several years.  Lastly, we
1167 disable shell escapes for the commands in the \s-1PAGERS\s0 \f(CW\*(C`Cmnd_Alias\*(C'\fR
1168 (\fI/usr/bin/more\fR, \fI/usr/bin/pg\fR and \fI/usr/bin/less\fR).
1169 .PP
1170 .Vb 7
1171 \& # Override built-in defaults
1172 \& Defaults               syslog=auth
1173 \& Defaults>root          !set_logname
1174 \& Defaults:FULLTIMERS    !lecture
1175 \& Defaults:millert       !authenticate
1176 \& Defaults@SERVERS       log_year, logfile=/var/log/sudo.log
1177 \& Defaults!PAGERS        noexec
1178 .Ve
1179 .PP
1180 The \fIUser specification\fR is the part that actually determines who may
1181 run what.
1182 .PP
1183 .Vb 2
1184 \& root           ALL = (ALL) ALL
1185 \& %wheel         ALL = (ALL) ALL
1186 .Ve
1187 .PP
1188 We let \fBroot\fR and any user in group \fBwheel\fR run any command on any
1189 host as any user.
1190 .PP
1191 .Vb 1
1192 \& FULLTIMERS     ALL = NOPASSWD: ALL
1193 .Ve
1194 .PP
1195 Full time sysadmins (\fBmillert\fR, \fBmikef\fR, and \fBdowdy\fR) may run any
1196 command on any host without authenticating themselves.
1197 .PP
1198 .Vb 1
1199 \& PARTTIMERS     ALL = ALL
1200 .Ve
1201 .PP
1202 Part time sysadmins (\fBbostley\fR, \fBjwfox\fR, and \fBcrawl\fR) may run any
1203 command on any host but they must authenticate themselves first
1204 (since the entry lacks the \f(CW\*(C`NOPASSWD\*(C'\fR tag).
1205 .PP
1206 .Vb 1
1207 \& jack           CSNETS = ALL
1208 .Ve
1209 .PP
1210 The user \fBjack\fR may run any command on the machines in the \fI\s-1CSNETS\s0\fR alias
1211 (the networks \f(CW128.138.243.0\fR, \f(CW128.138.204.0\fR, and \f(CW128.138.242.0\fR).
1212 Of those networks, only \f(CW128.138.204.0\fR has an explicit netmask (in
1213 \&\s-1CIDR\s0 notation) indicating it is a class C network.  For the other
1214 networks in \fI\s-1CSNETS\s0\fR, the local machine's netmask will be used
1215 during matching.
1216 .PP
1217 .Vb 1
1218 \& lisa           CUNETS = ALL
1219 .Ve
1220 .PP
1221 The user \fBlisa\fR may run any command on any host in the \fI\s-1CUNETS\s0\fR alias
1222 (the class B network \f(CW128.138.0.0\fR).
1223 .PP
1224 .Vb 2
1225 \& operator       ALL = DUMPS, KILL, SHUTDOWN, HALT, REBOOT, PRINTING,\e
1226 \&                sudoedit /etc/printcap, /usr/oper/bin/
1227 .Ve
1228 .PP
1229 The \fBoperator\fR user may run commands limited to simple maintenance.
1230 Here, those are commands related to backups, killing processes, the
1231 printing system, shutting down the system, and any commands in the
1232 directory \fI/usr/oper/bin/\fR.
1233 .PP
1234 .Vb 1
1235 \& joe            ALL = /usr/bin/su operator
1236 .Ve
1237 .PP
1238 The user \fBjoe\fR may only \fIsu\fR\|(1) to operator.
1239 .PP
1240 .Vb 1
1241 \& pete           HPPA = /usr/bin/passwd [A-z]*, !/usr/bin/passwd root
1242 .Ve
1243 .PP
1244 The user \fBpete\fR is allowed to change anyone's password except for
1245 root on the \fI\s-1HPPA\s0\fR machines.  Note that this assumes \fIpasswd\fR\|(1)
1246 does not take multiple usernames on the command line.
1247 .PP
1248 .Vb 1
1249 \& bob            SPARC = (OP) ALL : SGI = (OP) ALL
1250 .Ve
1251 .PP
1252 The user \fBbob\fR may run anything on the \fI\s-1SPARC\s0\fR and \fI\s-1SGI\s0\fR machines
1253 as any user listed in the \fI\s-1OP\s0\fR \f(CW\*(C`Runas_Alias\*(C'\fR (\fBroot\fR and \fBoperator\fR).
1254 .PP
1255 .Vb 1
1256 \& jim            +biglab = ALL
1257 .Ve
1258 .PP
1259 The user \fBjim\fR may run any command on machines in the \fIbiglab\fR netgroup.
1260 \&\fBsudo\fR knows that \*(L"biglab\*(R" is a netgroup due to the '+' prefix.
1261 .PP
1262 .Vb 1
1263 \& +secretaries   ALL = PRINTING, /usr/bin/adduser, /usr/bin/rmuser
1264 .Ve
1265 .PP
1266 Users in the \fBsecretaries\fR netgroup need to help manage the printers
1267 as well as add and remove users, so they are allowed to run those
1268 commands on all machines.
1269 .PP
1270 .Vb 1
1271 \& fred           ALL = (DB) NOPASSWD: ALL
1272 .Ve
1273 .PP
1274 The user \fBfred\fR can run commands as any user in the \fI\s-1DB\s0\fR \f(CW\*(C`Runas_Alias\*(C'\fR
1275 (\fBoracle\fR or \fBsybase\fR) without giving a password.
1276 .PP
1277 .Vb 1
1278 \& john           ALPHA = /usr/bin/su [!-]*, !/usr/bin/su *root*
1279 .Ve
1280 .PP
1281 On the \fI\s-1ALPHA\s0\fR machines, user \fBjohn\fR may su to anyone except root
1282 but he is not allowed to give \fIsu\fR\|(1) any flags.
1283 .PP
1284 .Vb 1
1285 \& jen            ALL, !SERVERS = ALL
1286 .Ve
1287 .PP
1288 The user \fBjen\fR may run any command on any machine except for those
1289 in the \fI\s-1SERVERS\s0\fR \f(CW\*(C`Host_Alias\*(C'\fR (master, mail, www and ns).
1290 .PP
1291 .Vb 1
1292 \& jill           SERVERS = /usr/bin/, !SU, !SHELLS
1293 .Ve
1294 .PP
1295 For any machine in the \fI\s-1SERVERS\s0\fR \f(CW\*(C`Host_Alias\*(C'\fR, \fBjill\fR may run
1296 any commands in the directory \fI/usr/bin/\fR except for those commands
1297 belonging to the \fI\s-1SU\s0\fR and \fI\s-1SHELLS\s0\fR \f(CW\*(C`Cmnd_Aliases\*(C'\fR.
1298 .PP
1299 .Vb 1
1300 \& steve          CSNETS = (operator) /usr/local/op_commands/
1301 .Ve
1302 .PP
1303 The user \fBsteve\fR may run any command in the directory /usr/local/op_commands/
1304 but only as user operator.
1305 .PP
1306 .Vb 1
1307 \& matt           valkyrie = KILL
1308 .Ve
1309 .PP
1310 On his personal workstation, valkyrie, \fBmatt\fR needs to be able to
1311 kill hung processes.
1312 .PP
1313 .Vb 1
1314 \& WEBMASTERS     www = (www) ALL, (root) /usr/bin/su www
1315 .Ve
1316 .PP
1317 On the host www, any user in the \fI\s-1WEBMASTERS\s0\fR \f(CW\*(C`User_Alias\*(C'\fR (will,
1318 wendy, and wim), may run any command as user www (which owns the
1319 web pages) or simply \fIsu\fR\|(1) to www.
1320 .PP
1321 .Vb 2
1322 \& ALL            CDROM = NOPASSWD: /sbin/umount /CDROM,\e
1323 \&                /sbin/mount -o nosuid\e,nodev /dev/cd0a /CDROM
1324 .Ve
1325 .PP
1326 Any user may mount or unmount a CD-ROM on the machines in the \s-1CDROM\s0
1327 \&\f(CW\*(C`Host_Alias\*(C'\fR (orion, perseus, hercules) without entering a password.
1328 This is a bit tedious for users to type, so it is a prime candidate
1329 for encapsulating in a shell script.
1330 .SH "SECURITY NOTES"
1331 .IX Header "SECURITY NOTES"
1332 It is generally not effective to \*(L"subtract\*(R" commands from \f(CW\*(C`ALL\*(C'\fR
1333 using the '!' operator.  A user can trivially circumvent this
1334 by copying the desired command to a different name and then
1335 executing that.  For example:
1336 .PP
1337 .Vb 1
1338 \&    bill        ALL = ALL, !SU, !SHELLS
1339 .Ve
1340 .PP
1341 Doesn't really prevent \fBbill\fR from running the commands listed in
1342 \&\fI\s-1SU\s0\fR or \fI\s-1SHELLS\s0\fR since he can simply copy those commands to a
1343 different name, or use a shell escape from an editor or other
1344 program.  Therefore, these kind of restrictions should be considered
1345 advisory at best (and reinforced by policy).
1346 .SH "PREVENTING SHELL ESCAPES"
1347 .IX Header "PREVENTING SHELL ESCAPES"
1348 Once \fBsudo\fR executes a program, that program is free to do whatever
1349 it pleases, including run other programs.  This can be a security
1350 issue since it is not uncommon for a program to allow shell escapes,
1351 which lets a user bypass \fBsudo\fR's access control and logging.
1352 Common programs that permit shell escapes include shells (obviously),
1353 editors, paginators, mail and terminal programs.
1354 .PP
1355 There are two basic approaches to this problem:
1356 .IP "restrict" 10
1357 .IX Item "restrict"
1358 Avoid giving users access to commands that allow the user to run
1359 arbitrary commands.  Many editors have a restricted mode where shell
1360 escapes are disabled, though \fBsudoedit\fR is a better solution to
1361 running editors via \fBsudo\fR.  Due to the large number of programs that
1362 offer shell escapes, restricting users to the set of programs that
1363 do not if often unworkable.
1364 .IP "noexec" 10
1365 .IX Item "noexec"
1366 Many systems that support shared libraries have the ability to
1367 override default library functions by pointing an environment
1368 variable (usually \f(CW\*(C`LD_PRELOAD\*(C'\fR) to an alternate shared library.
1369 On such systems, \fBsudo\fR's \fInoexec\fR functionality can be used to
1370 prevent a program run by \fBsudo\fR from executing any other programs.
1371 Note, however, that this applies only to native dynamically-linked
1372 executables.  Statically-linked executables and foreign executables
1373 running under binary emulation are not affected.
1374 .Sp
1375 To tell whether or not \fBsudo\fR supports \fInoexec\fR, you can run
1376 the following as root:
1377 .Sp
1378 .Vb 1
1379 \&    sudo -V | grep "dummy exec"
1380 .Ve
1381 .Sp
1382 If the resulting output contains a line that begins with:
1383 .Sp
1384 .Vb 1
1385 \&    File containing dummy exec functions:
1386 .Ve
1387 .Sp
1388 then \fBsudo\fR may be able to replace the exec family of functions
1389 in the standard library with its own that simply return an error.
1390 Unfortunately, there is no foolproof way to know whether or not
1391 \&\fInoexec\fR will work at compile\-time.  \fInoexec\fR should work on
1392 SunOS, Solaris, *BSD, Linux, \s-1IRIX\s0, Tru64 \s-1UNIX\s0, MacOS X, and HP-UX
1393 11.x.  It is known \fBnot\fR to work on \s-1AIX\s0 and UnixWare.  \fInoexec\fR
1394 is expected to work on most operating systems that support the
1395 \&\f(CW\*(C`LD_PRELOAD\*(C'\fR environment variable.  Check your operating system's
1396 manual pages for the dynamic linker (usually ld.so, ld.so.1, dyld,
1397 dld.sl, rld, or loader) to see if \f(CW\*(C`LD_PRELOAD\*(C'\fR is supported.
1398 .Sp
1399 To enable \fInoexec\fR for a command, use the \f(CW\*(C`NOEXEC\*(C'\fR tag as documented
1400 in the User Specification section above.  Here is that example again:
1401 .Sp
1402 .Vb 1
1403 \& aaron  shanty = NOEXEC: /usr/bin/more, /usr/bin/vi
1404 .Ve
1405 .Sp
1406 This allows user \fBaaron\fR to run \fI/usr/bin/more\fR and \fI/usr/bin/vi\fR
1407 with \fInoexec\fR enabled.  This will prevent those two commands from
1408 executing other commands (such as a shell).  If you are unsure
1409 whether or not your system is capable of supporting \fInoexec\fR you
1410 can always just try it out and see if it works.
1411 .PP
1412 Note that restricting shell escapes is not a panacea.  Programs
1413 running as root are still capable of many potentially hazardous
1414 operations (such as changing or overwriting files) that could lead
1415 to unintended privilege escalation.  In the specific case of an
1416 editor, a safer approach is to give the user permission to run
1417 \&\fBsudoedit\fR.
1418 .SH "SEE ALSO"
1419 .IX Header "SEE ALSO"
1420 \&\fIrsh\fR\|(1), \fIsu\fR\|(1), \fIfnmatch\fR\|(3), \fIsudo\fR\|(@mansectsu@), \fIvisudo\fR\|(8)
1421 .SH "CAVEATS"
1422 .IX Header "CAVEATS"
1423 The \fIsudoers\fR file should \fBalways\fR be edited by the \fBvisudo\fR
1424 command which locks the file and does grammatical checking. It is
1425 imperative that \fIsudoers\fR be free of syntax errors since \fBsudo\fR
1426 will not run with a syntactically incorrect \fIsudoers\fR file.
1427 .PP
1428 When using netgroups of machines (as opposed to users), if you
1429 store fully qualified hostnames in the netgroup (as is usually the
1430 case), you either need to have the machine's hostname be fully qualified
1431 as returned by the \f(CW\*(C`hostname\*(C'\fR command or use the \fIfqdn\fR option in
1432 \&\fIsudoers\fR.
1433 .SH "BUGS"
1434 .IX Header "BUGS"
1435 If you feel you have found a bug in \fBsudo\fR, please submit a bug report
1436 at http://www.sudo.ws/sudo/bugs/
1437 .SH "SUPPORT"
1438 .IX Header "SUPPORT"
1439 Limited free support is available via the sudo-users mailing list,
1440 see http://www.sudo.ws/mailman/listinfo/sudo\-users to subscribe or
1441 search the archives.
1442 .SH "DISCLAIMER"
1443 .IX Header "DISCLAIMER"
1444 \&\fBsudo\fR is provided ``\s-1AS\s0 \s-1IS\s0'' and any express or implied warranties,
1445 including, but not limited to, the implied warranties of merchantability
1446 and fitness for a particular purpose are disclaimed.  See the \s-1LICENSE\s0
1447 file distributed with \fBsudo\fR or http://www.sudo.ws/sudo/license.html
1448 for complete details.