7f41f30875d3d677c1d6ce976c2d9d9cf63a881f
[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.18 2007/12/03 10:27:12 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@ "December  3, 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.  If the command matched is \fB\s-1ALL\s0\fR, the
526 \&\f(CW\*(C`SETENV\*(C'\fR tag is implied for that command; this default may
527 be overridden by use of the \f(CW\*(C`UNSETENV\*(C'\fR tag.
528 .Sh "Wildcards"
529 .IX Subsection "Wildcards"
530 \&\fBsudo\fR allows shell-style \fIwildcards\fR (aka meta or glob characters)
531 to be used in pathnames as well as command line arguments in the
532 \&\fIsudoers\fR file.  Wildcard matching is done via the \fB\s-1POSIX\s0\fR
533 \&\fIfnmatch\fR\|(3) routine.  Note that these are \fInot\fR regular expressions.
534 .ie n .IP "\*(C`*\*(C'" 8
535 .el .IP "\f(CW\*(C`*\*(C'\fR" 8
536 .IX Item "*"
537 Matches any set of zero or more characters.
538 .ie n .IP "\*(C`?\*(C'" 8
539 .el .IP "\f(CW\*(C`?\*(C'\fR" 8
540 .IX Item "?"
541 Matches any single character.
542 .ie n .IP "\*(C`[...]\*(C'" 8
543 .el .IP "\f(CW\*(C`[...]\*(C'\fR" 8
544 .IX Item "[...]"
545 Matches any character in the specified range.
546 .ie n .IP "\*(C`[!...]\*(C'" 8
547 .el .IP "\f(CW\*(C`[!...]\*(C'\fR" 8
548 .IX Item "[!...]"
549 Matches any character \fBnot\fR in the specified range.
550 .ie n .IP "\*(C`\ex\*(C'" 8
551 .el .IP "\f(CW\*(C`\ex\*(C'\fR" 8
552 .IX Item "x"
553 For any character \*(L"x\*(R", evaluates to \*(L"x\*(R".  This is used to
554 escape special characters such as: \*(L"*\*(R", \*(L"?\*(R", \*(L"[\*(R", and \*(L"}\*(R".
555 .PP
556 Note that a forward slash ('/') will \fBnot\fR be matched by
557 wildcards used in the pathname.  When matching the command
558 line arguments, however, a slash \fBdoes\fR get matched by
559 wildcards.  This is to make a path like:
560 .PP
561 .Vb 1
562 \&    /usr/bin/*
563 .Ve
564 .PP
565 match \fI/usr/bin/who\fR but not \fI/usr/bin/X11/xterm\fR.
566 .Sh "Exceptions to wildcard rules"
567 .IX Subsection "Exceptions to wildcard rules"
568 The following exceptions apply to the above rules:
569 .ie n .IP """""" 8
570 .el .IP "\f(CW``''\fR" 8
571 .IX Item """"""
572 If the empty string \f(CW""\fR is the only command line argument in the
573 \&\fIsudoers\fR entry it means that command is not allowed to be run
574 with \fBany\fR arguments.
575 .Sh "Other special characters and reserved words"
576 .IX Subsection "Other special characters and reserved words"
577 The pound sign ('#') is used to indicate a comment (unless it is
578 part of a #include directive or unless it occurs in the context of
579 a user name and is followed by one or more digits, in which case
580 it is treated as a uid).  Both the comment character and any text
581 after it, up to the end of the line, are ignored.
582 .PP
583 The reserved word \fB\s-1ALL\s0\fR is a built-in \fIalias\fR that always causes
584 a match to succeed.  It can be used wherever one might otherwise
585 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.
586 You should not try to define your own \fIalias\fR called \fB\s-1ALL\s0\fR as the
587 built-in alias will be used in preference to your own.  Please note
588 that using \fB\s-1ALL\s0\fR can be dangerous since in a command context, it
589 allows the user to run \fBany\fR command on the system.
590 .PP
591 An exclamation point ('!') can be used as a logical \fInot\fR operator
592 both in an \fIalias\fR and in front of a \f(CW\*(C`Cmnd\*(C'\fR.  This allows one to
593 exclude certain values.  Note, however, that using a \f(CW\*(C`!\*(C'\fR in
594 conjunction with the built-in \f(CW\*(C`ALL\*(C'\fR alias to allow a user to
595 run \*(L"all but a few\*(R" commands rarely works as intended (see \s-1SECURITY\s0
596 \&\s-1NOTES\s0 below).
597 .PP
598 Long lines can be continued with a backslash ('\e') as the last
599 character on the line.
600 .PP
601 Whitespace between elements in a list as well as special syntactic
602 characters in a \fIUser Specification\fR ('=', ':', '(', ')') is optional.
603 .PP
604 The following characters must be escaped with a backslash ('\e') when
605 used as part of a word (e.g.\ a username or hostname):
606 \&'@', '!', '=', ':', ',', '(', ')', '\e'.
607 .SH "SUDOERS OPTIONS"
608 .IX Header "SUDOERS OPTIONS"
609 \&\fBsudo\fR's behavior can be modified by \f(CW\*(C`Default_Entry\*(C'\fR lines, as
610 explained earlier.  A list of all supported Defaults parameters,
611 grouped by type, are listed below.
612 .PP
613 \&\fBFlags\fR:
614 .IP "always_set_home" 16
615 .IX Item "always_set_home"
616 If set, \fBsudo\fR will set the \f(CW\*(C`HOME\*(C'\fR environment variable to the home
617 directory of the target user (which is root unless the \fB\-u\fR option is used).
618 This effectively means that the \fB\-H\fR flag is always implied.
619 This flag is \fIoff\fR by default.
620 .IP "authenticate" 16
621 .IX Item "authenticate"
622 If set, users must authenticate themselves via a password (or other
623 means of authentication) before they may run commands.  This default
624 may be overridden via the \f(CW\*(C`PASSWD\*(C'\fR and \f(CW\*(C`NOPASSWD\*(C'\fR tags.
625 This flag is \fIon\fR by default.
626 .IP "env_editor" 16
627 .IX Item "env_editor"
628 If set, \fBvisudo\fR will use the value of the \s-1EDITOR\s0 or \s-1VISUAL\s0
629 environment variables before falling back on the default editor list.
630 Note that this may create a security hole as it allows the user to
631 run any arbitrary command as root without logging.  A safer alternative
632 is to place a colon-separated list of editors in the \f(CW\*(C`editor\*(C'\fR
633 variable.  \fBvisudo\fR will then only use the \s-1EDITOR\s0 or \s-1VISUAL\s0 if
634 they match a value specified in \f(CW\*(C`editor\*(C'\fR.  This flag is \fI@env_editor@\fR by
635 default.
636 .IP "env_reset" 16
637 .IX Item "env_reset"
638 If set, \fBsudo\fR will reset the environment to only contain the
639 \&\s-1LOGNAME\s0, \s-1SHELL\s0, \s-1USER\s0, \s-1USERNAME\s0 and the \f(CW\*(C`SUDO_*\*(C'\fR variables.  Any
640 variables in the caller's environment that match the \f(CW\*(C`env_keep\*(C'\fR
641 and \f(CW\*(C`env_check\*(C'\fR lists are then added.  The default contents of the
642 \&\f(CW\*(C`env_keep\*(C'\fR and \f(CW\*(C`env_check\*(C'\fR lists are displayed when \fBsudo\fR is
643 run by root with the \fI\-V\fR option.  If \fBsudo\fR was compiled with
644 the \f(CW\*(C`SECURE_PATH\*(C'\fR option, its value will be used for the \f(CW\*(C`PATH\*(C'\fR
645 environment variable.  This flag is \fIon\fR by default.
646 .IP "fqdn" 16
647 .IX Item "fqdn"
648 Set this flag if you want to put fully qualified hostnames in the
649 \&\fIsudoers\fR file.  I.e., instead of myhost you would use myhost.mydomain.edu.
650 You may still use the short form if you wish (and even mix the two).
651 Beware that turning on \fIfqdn\fR requires \fBsudo\fR to make \s-1DNS\s0 lookups
652 which may make \fBsudo\fR unusable if \s-1DNS\s0 stops working (for example
653 if the machine is not plugged into the network).  Also note that
654 you must use the host's official name as \s-1DNS\s0 knows it.  That is,
655 you may not use a host alias (\f(CW\*(C`CNAME\*(C'\fR entry) due to performance
656 issues and the fact that there is no way to get all aliases from
657 \&\s-1DNS\s0.  If your machine's hostname (as returned by the \f(CW\*(C`hostname\*(C'\fR
658 command) is already fully qualified you shouldn't need to set
659 \&\fIfqdn\fR.  This flag is \fI@fqdn@\fR by default.
660 .IP "ignore_dot" 16
661 .IX Item "ignore_dot"
662 If set, \fBsudo\fR will ignore '.' or '' (current dir) in the \f(CW\*(C`PATH\*(C'\fR
663 environment variable; the \f(CW\*(C`PATH\*(C'\fR itself is not modified.  This
664 flag is \fI@ignore_dot@\fR by default.  Currently, while it is possible
665 to set \fIignore_dot\fR in \fIsudoers\fR, its value is not used.  This option
666 should be considered read-only (it will be fixed in a future version
667 of \fBsudo\fR).
668 .IP "ignore_local_sudoers" 16
669 .IX Item "ignore_local_sudoers"
670 If set via \s-1LDAP\s0, parsing of \f(CW@sysconfdir\fR@/sudoers will be skipped.
671 This is intended for Enterprises that wish to prevent the usage of local
672 sudoers files so that only \s-1LDAP\s0 is used.  This thwarts the efforts of
673 rogue operators who would attempt to add roles to \f(CW@sysconfdir\fR@/sudoers.
674 When this option is present, \f(CW@sysconfdir\fR@/sudoers does not even need to exist. 
675 Since this option tells \fBsudo\fR how to behave when no specific \s-1LDAP\s0 entries
676 have been matched, this sudoOption is only meaningful for the cn=defaults
677 section.  This flag is \fIoff\fR by default.
678 .IP "insults" 16
679 .IX Item "insults"
680 If set, \fBsudo\fR will insult users when they enter an incorrect
681 password.  This flag is \fI@insults@\fR by default.
682 .IP "log_host" 16
683 .IX Item "log_host"
684 If set, the hostname will be logged in the (non\-syslog) \fBsudo\fR log file.
685 This flag is \fIoff\fR by default.
686 .IP "log_year" 16
687 .IX Item "log_year"
688 If set, the four-digit year will be logged in the (non\-syslog) \fBsudo\fR log file.
689 This flag is \fIoff\fR by default.
690 .IP "long_otp_prompt" 16
691 .IX Item "long_otp_prompt"
692 When validating with a One Time Password (\s-1OPT\s0) scheme such as
693 \&\fBS/Key\fR or \fB\s-1OPIE\s0\fR, a two-line prompt is used to make it easier
694 to cut and paste the challenge to a local window.  It's not as
695 pretty as the default but some people find it more convenient.  This
696 flag is \fI@long_otp_prompt@\fR by default.
697 .IP "mail_always" 16
698 .IX Item "mail_always"
699 Send mail to the \fImailto\fR user every time a users runs \fBsudo\fR.
700 This flag is \fIoff\fR by default.
701 .IP "mail_badpass" 16
702 .IX Item "mail_badpass"
703 Send mail to the \fImailto\fR user if the user running \fBsudo\fR does not
704 enter the correct password.  This flag is \fIoff\fR by default.
705 .IP "mail_no_host" 16
706 .IX Item "mail_no_host"
707 If set, mail will be sent to the \fImailto\fR user if the invoking
708 user exists in the \fIsudoers\fR file, but is not allowed to run
709 commands on the current host.  This flag is \fI@mail_no_host@\fR by default.
710 .IP "mail_no_perms" 16
711 .IX Item "mail_no_perms"
712 If set, mail will be sent to the \fImailto\fR user if the invoking
713 user is allowed to use \fBsudo\fR but the command they are trying is not
714 listed in their \fIsudoers\fR file entry or is explicitly denied.
715 This flag is \fI@mail_no_perms@\fR by default.
716 .IP "mail_no_user" 16
717 .IX Item "mail_no_user"
718 If set, mail will be sent to the \fImailto\fR user if the invoking
719 user is not in the \fIsudoers\fR file.  This flag is \fI@mail_no_user@\fR
720 by default.
721 .IP "noexec" 16
722 .IX Item "noexec"
723 If set, all commands run via \fBsudo\fR will behave as if the \f(CW\*(C`NOEXEC\*(C'\fR
724 tag has been set, unless overridden by a \f(CW\*(C`EXEC\*(C'\fR tag.  See the
725 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.
726 .IP "path_info" 16
727 .IX Item "path_info"
728 Normally, \fBsudo\fR will tell the user when a command could not be
729 found in their \f(CW\*(C`PATH\*(C'\fR environment variable.  Some sites may wish
730 to disable this as it could be used to gather information on the
731 location of executables that the normal user does not have access
732 to.  The disadvantage is that if the executable is simply not in
733 the user's \f(CW\*(C`PATH\*(C'\fR, \fBsudo\fR will tell the user that they are not
734 allowed to run it, which can be confusing.  This flag is \fI@path_info@\fR
735 by default.
736 .IP "passprompt_override" 16
737 .IX Item "passprompt_override"
738 The password prompt specified by \fIpassprompt\fR will normally only
739 be used if the passwod prompt provided by systems such as \s-1PAM\s0 matches
740 the string \*(L"Password:\*(R".  If \fIpassprompt_override\fR is set, \fIpassprompt\fR
741 will always be used.  This flag is \fIoff\fR by default.
742 .IP "preserve_groups" 16
743 .IX Item "preserve_groups"
744 By default \fBsudo\fR will initialize the group vector to the list of
745 groups the target user is in.  When \fIpreserve_groups\fR is set, the
746 user's existing group vector is left unaltered.  The real and
747 effective group IDs, however, are still set to match the target
748 user.  This flag is \fIoff\fR by default.
749 .IP "requiretty" 16
750 .IX Item "requiretty"
751 If set, \fBsudo\fR will only run when the user is logged in to a real
752 tty.  This will disallow things like \f(CW"rsh somehost sudo ls"\fR since
753 \&\fIrsh\fR\|(1) does not allocate a tty.  Because it is not possible to turn
754 off echo when there is no tty present, some sites may wish to set
755 this flag to prevent a user from entering a visible password.  This
756 flag is \fIoff\fR by default.
757 .IP "root_sudo" 16
758 .IX Item "root_sudo"
759 If set, root is allowed to run \fBsudo\fR too.  Disabling this prevents users
760 from \*(L"chaining\*(R" \fBsudo\fR commands to get a root shell by doing something
761 like \f(CW"sudo sudo /bin/sh"\fR.  Note, however, that turning off \fIroot_sudo\fR
762 will also prevent root and from running \fBsudoedit\fR.
763 Disabling \fIroot_sudo\fR provides no real additional security; it
764 exists purely for historical reasons.
765 This flag is \fI@root_sudo@\fR by default.
766 .IP "rootpw" 16
767 .IX Item "rootpw"
768 If set, \fBsudo\fR will prompt for the root password instead of the password
769 of the invoking user.  This flag is \fIoff\fR by default.
770 .IP "runaspw" 16
771 .IX Item "runaspw"
772 If set, \fBsudo\fR will prompt for the password of the user defined by the
773 \&\fIrunas_default\fR option (defaults to \f(CW\*(C`@runas_default@\*(C'\fR) instead of the
774 password of the invoking user.  This flag is \fIoff\fR by default.
775 .IP "set_home" 16
776 .IX Item "set_home"
777 If set and \fBsudo\fR is invoked with the \fB\-s\fR flag the \f(CW\*(C`HOME\*(C'\fR
778 environment variable will be set to the home directory of the target
779 user (which is root unless the \fB\-u\fR option is used).  This effectively
780 makes the \fB\-s\fR flag imply \fB\-H\fR.  This flag is \fIoff\fR by default.
781 .IP "set_logname" 16
782 .IX Item "set_logname"
783 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
784 environment variables to the name of the target user (usually root
785 unless the \fB\-u\fR flag is given).  However, since some programs
786 (including the \s-1RCS\s0 revision control system) use \f(CW\*(C`LOGNAME\*(C'\fR to
787 determine the real identity of the user, it may be desirable to
788 change this behavior.  This can be done by negating the set_logname
789 option.  Note that if the \fIenv_reset\fR option has not been disabled,
790 entries in the \fIenv_keep\fR list will override the value of
791 \&\fIset_logname\fR.  This flag is \fIoff\fR by default.
792 .IP "setenv" 16
793 .IX Item "setenv"
794 Allow the user to disable the \fIenv_reset\fR option from the command
795 line.  Additionally, environment variables set via the command line
796 are not subject to the restrictions imposed by \fIenv_check\fR,
797 \&\fIenv_delete\fR, or \fIenv_keep\fR.  As such, only trusted users should
798 be allowed to set variables in this manner.  This flag is \fIoff\fR
799 by default.
800 .IP "shell_noargs" 16
801 .IX Item "shell_noargs"
802 If set and \fBsudo\fR is invoked with no arguments it acts as if the
803 \&\fB\-s\fR flag had been given.  That is, it runs a shell as root (the
804 shell is determined by the \f(CW\*(C`SHELL\*(C'\fR environment variable if it is
805 set, falling back on the shell listed in the invoking user's
806 /etc/passwd entry if not).  This flag is \fIoff\fR by default.
807 .IP "stay_setuid" 16
808 .IX Item "stay_setuid"
809 Normally, when \fBsudo\fR executes a command the real and effective
810 UIDs are set to the target user (root by default).  This option
811 changes that behavior such that the real \s-1UID\s0 is left as the invoking
812 user's \s-1UID\s0.  In other words, this makes \fBsudo\fR act as a setuid
813 wrapper.  This can be useful on systems that disable some potentially
814 dangerous functionality when a program is run setuid.  This option
815 is only effective on systems with either the \fIsetreuid()\fR or \fIsetresuid()\fR
816 function.  This flag is \fIoff\fR by default.
817 .IP "targetpw" 16
818 .IX Item "targetpw"
819 If set, \fBsudo\fR will prompt for the password of the user specified by
820 the \fB\-u\fR flag (defaults to \f(CW\*(C`root\*(C'\fR) instead of the password of the
821 invoking user.  Note that this precludes the use of a uid not listed
822 in the passwd database as an argument to the \fB\-u\fR flag.
823 This flag is \fIoff\fR by default.
824 .IP "tty_tickets" 16
825 .IX Item "tty_tickets"
826 If set, users must authenticate on a per-tty basis.  Normally,
827 \&\fBsudo\fR uses a directory in the ticket dir with the same name as
828 the user running it.  With this flag enabled, \fBsudo\fR will use a
829 file named for the tty the user is logged in on in that directory.
830 This flag is \fI@tty_tickets@\fR by default.
831 .IP "use_loginclass" 16
832 .IX Item "use_loginclass"
833 If set, \fBsudo\fR will apply the defaults specified for the target user's
834 login class if one exists.  Only available if \fBsudo\fR is configured with
835 the \-\-with\-logincap option.  This flag is \fIoff\fR by default.
836 .PP
837 \&\fBIntegers\fR:
838 .IP "passwd_tries" 16
839 .IX Item "passwd_tries"
840 The number of tries a user gets to enter his/her password before
841 \&\fBsudo\fR logs the failure and exits.  The default is \f(CW\*(C`@passwd_tries@\*(C'\fR.
842 .PP
843 \&\fBIntegers that can be used in a boolean context\fR:
844 .IP "loglinelen" 16
845 .IX Item "loglinelen"
846 Number of characters per line for the file log.  This value is used
847 to decide when to wrap lines for nicer log files.  This has no
848 effect on the syslog log file, only the file log.  The default is
849 \&\f(CW\*(C`@loglen@\*(C'\fR (use 0 or negate the option to disable word wrap).
850 .IP "passwd_timeout" 16
851 .IX Item "passwd_timeout"
852 Number of minutes before the \fBsudo\fR password prompt times out.
853 The default is \f(CW\*(C`@password_timeout@\*(C'\fR; set this to \f(CW0\fR for no password timeout.
854 .IP "timestamp_timeout" 16
855 .IX Item "timestamp_timeout"
856 Number of minutes that can elapse before \fBsudo\fR will ask for a
857 passwd again.  The default is \f(CW\*(C`@timeout@\*(C'\fR.  Set this to \f(CW0\fR to always
858 prompt for a password.
859 If set to a value less than \f(CW0\fR the user's timestamp will never
860 expire.  This can be used to allow users to create or delete their
861 own timestamps via \f(CW\*(C`sudo \-v\*(C'\fR and \f(CW\*(C`sudo \-k\*(C'\fR respectively.
862 .IP "umask" 16
863 .IX Item "umask"
864 Umask to use when running the command.  Negate this option or set
865 it to 0777 to preserve the user's umask.  The default is \f(CW\*(C`@sudo_umask@\*(C'\fR.
866 .PP
867 \&\fBStrings\fR:
868 .IP "badpass_message" 16
869 .IX Item "badpass_message"
870 Message that is displayed if a user enters an incorrect password.
871 The default is \f(CW\*(C`@badpass_message@\*(C'\fR unless insults are enabled.
872 .IP "editor" 16
873 .IX Item "editor"
874 A colon (':') separated list of editors allowed to be used with
875 \&\fBvisudo\fR.  \fBvisudo\fR will choose the editor that matches the user's
876 \&\s-1EDITOR\s0 environment variable if possible, or the first editor in the
877 list that exists and is executable.  The default is the path to vi
878 on your system.
879 .IP "mailsub" 16
880 .IX Item "mailsub"
881 Subject of the mail sent to the \fImailto\fR user. The escape \f(CW%h\fR
882 will expand to the hostname of the machine.
883 Default is \f(CW\*(C`@mailsub@\*(C'\fR.
884 .IP "noexec_file" 16
885 .IX Item "noexec_file"
886 Path to a shared library containing dummy versions of the \fIexecv()\fR,
887 \&\fIexecve()\fR and \fIfexecve()\fR library functions that just return an error.
888 This is used to implement the \fInoexec\fR functionality on systems that
889 support \f(CW\*(C`LD_PRELOAD\*(C'\fR or its equivalent.  Defaults to \fI@noexec_file@\fR.
890 .IP "passprompt" 16
891 .IX Item "passprompt"
892 The default prompt to use when asking for a password; can be overridden
893 via the \fB\-p\fR option or the \f(CW\*(C`SUDO_PROMPT\*(C'\fR environment variable.
894 The following percent (`\f(CW\*(C`%\*(C'\fR') escapes are supported:
895 .RS 16
896 .ie n .IP "%H" 4
897 .el .IP "\f(CW%H\fR" 4
898 .IX Item "%H"
899 expanded to the local hostname including the domain name
900 (on if the machine's hostname is fully qualified or the \fIfqdn\fR
901 option is set)
902 .ie n .IP "%h" 4
903 .el .IP "\f(CW%h\fR" 4
904 .IX Item "%h"
905 expanded to the local hostname without the domain name
906 .ie n .IP "%U" 4
907 .el .IP "\f(CW%U\fR" 4
908 .IX Item "%U"
909 expanded to the login name of the user the command will
910 be run as (defaults to root)
911 .ie n .IP "%u" 4
912 .el .IP "\f(CW%u\fR" 4
913 .IX Item "%u"
914 expanded to the invoking user's login name
915 .ie n .IP "\*(C`%%\*(C'" 4
916 .el .IP "\f(CW\*(C`%%\*(C'\fR" 4
917 .IX Item "%%"
918 two consecutive \f(CW\*(C`%\*(C'\fR characters are collapsed into a single \f(CW\*(C`%\*(C'\fR character
919 .RE
920 .RS 16
921 .Sp
922 The default value is \f(CW\*(C`@passprompt@\*(C'\fR.
923 .RE
924 .IP "runas_default" 16
925 .IX Item "runas_default"
926 The default user to run commands as if the \fB\-u\fR flag is not specified
927 on the command line.  This defaults to \f(CW\*(C`@runas_default@\*(C'\fR.
928 Note that if \fIrunas_default\fR is set it \fBmust\fR occur before
929 any \f(CW\*(C`Runas_Alias\*(C'\fR specifications.
930 .IP "syslog_badpri" 16
931 .IX Item "syslog_badpri"
932 Syslog priority to use when user authenticates unsuccessfully.
933 Defaults to \f(CW\*(C`@badpri@\*(C'\fR.
934 .IP "syslog_goodpri" 16
935 .IX Item "syslog_goodpri"
936 Syslog priority to use when user authenticates successfully.
937 Defaults to \f(CW\*(C`@goodpri@\*(C'\fR.
938 .IP "timestampdir" 16
939 .IX Item "timestampdir"
940 The directory in which \fBsudo\fR stores its timestamp files.
941 The default is \fI@timedir@\fR.
942 .IP "timestampowner" 16
943 .IX Item "timestampowner"
944 The owner of the timestamp directory and the timestamps stored therein.
945 The default is \f(CW\*(C`root\*(C'\fR.
946 .PP
947 \&\fBStrings that can be used in a boolean context\fR:
948 .IP "exempt_group" 12
949 .IX Item "exempt_group"
950 Users in this group are exempt from password and \s-1PATH\s0 requirements.
951 This is not set by default.
952 .IP "lecture" 12
953 .IX Item "lecture"
954 This option controls when a short lecture will be printed along with
955 the password prompt.  It has the following possible values:
956 .RS 12
957 .IP "always" 8
958 .IX Item "always"
959 Always lecture the user.
960 .IP "never" 8
961 .IX Item "never"
962 Never lecture the user.
963 .IP "once" 8
964 .IX Item "once"
965 Only lecture the user the first time they run \fBsudo\fR.
966 .RE
967 .RS 12
968 .Sp
969 If no value is specified, a value of \fIonce\fR is implied.
970 Negating the option results in a value of \fInever\fR being used.
971 The default value is \fI@lecture@\fR.
972 .RE
973 .IP "lecture_file" 12
974 .IX Item "lecture_file"
975 Path to a file containing an alternate \fBsudo\fR lecture that will
976 be used in place of the standard lecture if the named file exists.
977 By default, \fBsudo\fR uses a built-in lecture.
978 .IP "listpw" 12
979 .IX Item "listpw"
980 This option controls when a password will be required when a
981 user runs \fBsudo\fR with the \fB\-l\fR flag.  It has the following possible values:
982 .RS 12
983 .IP "all" 8
984 .IX Item "all"
985 All the user's \fIsudoers\fR entries for the current host must have
986 the \f(CW\*(C`NOPASSWD\*(C'\fR flag set to avoid entering a password.
987 .IP "always" 8
988 .IX Item "always"
989 The user must always enter a password to use the \fB\-l\fR flag.
990 .IP "any" 8
991 .IX Item "any"
992 At least one of the user's \fIsudoers\fR entries for the current host
993 must have the \f(CW\*(C`NOPASSWD\*(C'\fR flag set to avoid entering a password.
994 .IP "never" 8
995 .IX Item "never"
996 The user need never enter a password to use the \fB\-l\fR flag.
997 .RE
998 .RS 12
999 .Sp
1000 If no value is specified, a value of \fIany\fR is implied.
1001 Negating the option results in a value of \fInever\fR being used.
1002 The default value is \fIany\fR.
1003 .RE
1004 .IP "logfile" 12
1005 .IX Item "logfile"
1006 Path to the \fBsudo\fR log file (not the syslog log file).  Setting a path
1007 turns on logging to a file; negating this option turns it off.
1008 By default, \fBsudo\fR logs via syslog.
1009 .IP "mailerflags" 12
1010 .IX Item "mailerflags"
1011 Flags to use when invoking mailer. Defaults to \fB\-t\fR.
1012 .IP "mailerpath" 12
1013 .IX Item "mailerpath"
1014 Path to mail program used to send warning mail.
1015 Defaults to the path to sendmail found at configure time.
1016 .IP "mailto" 12
1017 .IX Item "mailto"
1018 Address to send warning and error mail to.  The address should
1019 be enclosed in double quotes (\f(CW\*(C`"\*(C'\fR) to protect against \fBsudo\fR
1020 interpreting the \f(CW\*(C`@\*(C'\fR sign.  Defaults to \f(CW\*(C`@mailto@\*(C'\fR.
1021 .IP "syslog" 12
1022 .IX Item "syslog"
1023 Syslog facility if syslog is being used for logging (negate to
1024 disable syslog logging).  Defaults to \f(CW\*(C`@logfac@\*(C'\fR.
1025 .IP "verifypw" 12
1026 .IX Item "verifypw"
1027 This option controls when a password will be required when a user runs
1028 \&\fBsudo\fR with the \fB\-v\fR flag.  It has the following possible values:
1029 .RS 12
1030 .IP "all" 8
1031 .IX Item "all"
1032 All the user's \fIsudoers\fR entries for the current host must have
1033 the \f(CW\*(C`NOPASSWD\*(C'\fR flag set to avoid entering a password.
1034 .IP "always" 8
1035 .IX Item "always"
1036 The user must always enter a password to use the \fB\-v\fR flag.
1037 .IP "any" 8
1038 .IX Item "any"
1039 At least one of the user's \fIsudoers\fR entries for the current host
1040 must have the \f(CW\*(C`NOPASSWD\*(C'\fR flag set to avoid entering a password.
1041 .IP "never" 8
1042 .IX Item "never"
1043 The user need never enter a password to use the \fB\-v\fR flag.
1044 .RE
1045 .RS 12
1046 .Sp
1047 If no value is specified, a value of \fIall\fR is implied.
1048 Negating the option results in a value of \fInever\fR being used.
1049 The default value is \fIall\fR.
1050 .RE
1051 .PP
1052 \&\fBLists that can be used in a boolean context\fR:
1053 .IP "env_check" 16
1054 .IX Item "env_check"
1055 Environment variables to be removed from the user's environment if
1056 the variable's value contains \f(CW\*(C`%\*(C'\fR or \f(CW\*(C`/\*(C'\fR characters.  This can
1057 be used to guard against printf-style format vulnerabilities in
1058 poorly-written programs.  The argument may be a double\-quoted,
1059 space-separated list or a single value without double\-quotes.  The
1060 list can be replaced, added to, deleted from, or disabled by using
1061 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
1062 of whether the \f(CW\*(C`env_reset\*(C'\fR option is enabled or disabled, variables
1063 specified by \f(CW\*(C`env_check\*(C'\fR will be preserved in the environment if
1064 they pass the aforementioned check.  The default list of environment
1065 variables to check is displayed when \fBsudo\fR is run by root with
1066 the \fI\-V\fR option.
1067 .IP "env_delete" 16
1068 .IX Item "env_delete"
1069 Environment variables to be removed from the user's environment.
1070 The argument may be a double\-quoted, space-separated list or a
1071 single value without double\-quotes.  The list can be replaced, added
1072 to, deleted from, or disabled by using the \f(CW\*(C`=\*(C'\fR, \f(CW\*(C`+=\*(C'\fR, \f(CW\*(C`\-=\*(C'\fR, and
1073 \&\f(CW\*(C`!\*(C'\fR operators respectively.  The default list of environment
1074 variables to remove is displayed when \fBsudo\fR is run by root with the
1075 \&\fI\-V\fR option.  Note that many operating systems will remove potentially
1076 dangerous variables from the environment of any setuid process (such
1077 as \fBsudo\fR).
1078 .IP "env_keep" 16
1079 .IX Item "env_keep"
1080 Environment variables to be preserved in the user's environment
1081 when the \fIenv_reset\fR option is in effect.  This allows fine-grained
1082 control over the environment \fBsudo\fR\-spawned processes will receive.
1083 The argument may be a double\-quoted, space-separated list or a
1084 single value without double\-quotes.  The list can be replaced, added
1085 to, deleted from, or disabled by using the \f(CW\*(C`=\*(C'\fR, \f(CW\*(C`+=\*(C'\fR, \f(CW\*(C`\-=\*(C'\fR, and
1086 \&\f(CW\*(C`!\*(C'\fR operators respectively.  The default list of variables to keep
1087 is displayed when \fBsudo\fR is run by root with the \fI\-V\fR option.
1088 .PP
1089 When logging via \fIsyslog\fR\|(3), \fBsudo\fR accepts the following values
1090 for the syslog facility (the value of the \fBsyslog\fR Parameter):
1091 \&\fBauthpriv\fR (if your \s-1OS\s0 supports it), \fBauth\fR, \fBdaemon\fR, \fBuser\fR,
1092 \&\fBlocal0\fR, \fBlocal1\fR, \fBlocal2\fR, \fBlocal3\fR, \fBlocal4\fR, \fBlocal5\fR,
1093 \&\fBlocal6\fR, and \fBlocal7\fR.  The following syslog priorities are
1094 supported: \fBalert\fR, \fBcrit\fR, \fBdebug\fR, \fBemerg\fR, \fBerr\fR, \fBinfo\fR,
1095 \&\fBnotice\fR, and \fBwarning\fR.
1096 .SH "FILES"
1097 .IX Header "FILES"
1098 .ie n .IP "\fI@sysconfdir@/sudoers\fR\*(C`              \*(C' List of who can run what" 4
1099 .el .IP "\fI@sysconfdir@/sudoers\fR\f(CW\*(C`           \*(C'\fR List of who can run what" 4
1100 .IX Item "@sysconfdir@/sudoers           List of who can run what"
1101 .PD 0
1102 .ie n .IP "\fI/etc/group\fR\*(C`                \*(C' Local groups file" 4
1103 .el .IP "\fI/etc/group\fR\f(CW\*(C`             \*(C'\fR Local groups file" 4
1104 .IX Item "/etc/group             Local groups file"
1105 .ie n .IP "\fI/etc/netgroup\fR\*(C`             \*(C' List of network groups" 4
1106 .el .IP "\fI/etc/netgroup\fR\f(CW\*(C`          \*(C'\fR List of network groups" 4
1107 .IX Item "/etc/netgroup          List of network groups"
1108 .PD
1109 .SH "EXAMPLES"
1110 .IX Header "EXAMPLES"
1111 Since the \fIsudoers\fR file is parsed in a single pass, order is
1112 important.  In general, you should structure \fIsudoers\fR such that
1113 the \f(CW\*(C`Host_Alias\*(C'\fR, \f(CW\*(C`User_Alias\*(C'\fR, and \f(CW\*(C`Cmnd_Alias\*(C'\fR specifications
1114 come first, followed by any \f(CW\*(C`Default_Entry\*(C'\fR lines, and finally the
1115 \&\f(CW\*(C`Runas_Alias\*(C'\fR and user specifications.  The basic rule of thumb
1116 is you cannot reference an Alias that has not already been defined.
1117 .PP
1118 Below are example \fIsudoers\fR entries.  Admittedly, some of
1119 these are a bit contrived.  First, we define our \fIaliases\fR:
1120 .PP
1121 .Vb 4
1122 \& # User alias specification
1123 \& User_Alias     FULLTIMERS = millert, mikef, dowdy
1124 \& User_Alias     PARTTIMERS = bostley, jwfox, crawl
1125 \& User_Alias     WEBMASTERS = will, wendy, wim
1126 .Ve
1127 .PP
1128 .Vb 3
1129 \& # Runas alias specification
1130 \& Runas_Alias    OP = root, operator
1131 \& Runas_Alias    DB = oracle, sybase
1132 .Ve
1133 .PP
1134 .Vb 9
1135 \& # Host alias specification
1136 \& Host_Alias     SPARC = bigtime, eclipse, moet, anchor :\e
1137 \&                SGI = grolsch, dandelion, black :\e
1138 \&                ALPHA = widget, thalamus, foobar :\e
1139 \&                HPPA = boa, nag, python
1140 \& Host_Alias     CUNETS = 128.138.0.0/255.255.0.0
1141 \& Host_Alias     CSNETS = 128.138.243.0, 128.138.204.0/24, 128.138.242.0
1142 \& Host_Alias     SERVERS = master, mail, www, ns
1143 \& Host_Alias     CDROM = orion, perseus, hercules
1144 .Ve
1145 .PP
1146 .Vb 13
1147 \& # Cmnd alias specification
1148 \& Cmnd_Alias     DUMPS = /usr/bin/mt, /usr/sbin/dump, /usr/sbin/rdump,\e
1149 \&                        /usr/sbin/restore, /usr/sbin/rrestore
1150 \& Cmnd_Alias     KILL = /usr/bin/kill
1151 \& Cmnd_Alias     PRINTING = /usr/sbin/lpc, /usr/bin/lprm
1152 \& Cmnd_Alias     SHUTDOWN = /usr/sbin/shutdown
1153 \& Cmnd_Alias     HALT = /usr/sbin/halt
1154 \& Cmnd_Alias     REBOOT = /usr/sbin/reboot
1155 \& Cmnd_Alias     SHELLS = /usr/bin/sh, /usr/bin/csh, /usr/bin/ksh, \e
1156 \&                         /usr/local/bin/tcsh, /usr/bin/rsh, \e
1157 \&                         /usr/local/bin/zsh
1158 \& Cmnd_Alias     SU = /usr/bin/su
1159 \& Cmnd_Alias     PAGERS = /usr/bin/more, /usr/bin/pg, /usr/bin/less
1160 .Ve
1161 .PP
1162 Here we override some of the compiled in default values.  We want
1163 \&\fBsudo\fR to log via \fIsyslog\fR\|(3) using the \fIauth\fR facility in all
1164 cases.  We don't want to subject the full time staff to the \fBsudo\fR
1165 lecture, user \fBmillert\fR need not give a password, and we don't
1166 want to reset the \f(CW\*(C`LOGNAME\*(C'\fR, \f(CW\*(C`USER\*(C'\fR or \f(CW\*(C`USERNAME\*(C'\fR environment
1167 variables when running commands as root.  Additionally, on the
1168 machines in the \fI\s-1SERVERS\s0\fR \f(CW\*(C`Host_Alias\*(C'\fR, we keep an additional
1169 local log file and make sure we log the year in each log line since
1170 the log entries will be kept around for several years.  Lastly, we
1171 disable shell escapes for the commands in the \s-1PAGERS\s0 \f(CW\*(C`Cmnd_Alias\*(C'\fR
1172 (\fI/usr/bin/more\fR, \fI/usr/bin/pg\fR and \fI/usr/bin/less\fR).
1173 .PP
1174 .Vb 7
1175 \& # Override built-in defaults
1176 \& Defaults               syslog=auth
1177 \& Defaults>root          !set_logname
1178 \& Defaults:FULLTIMERS    !lecture
1179 \& Defaults:millert       !authenticate
1180 \& Defaults@SERVERS       log_year, logfile=/var/log/sudo.log
1181 \& Defaults!PAGERS        noexec
1182 .Ve
1183 .PP
1184 The \fIUser specification\fR is the part that actually determines who may
1185 run what.
1186 .PP
1187 .Vb 2
1188 \& root           ALL = (ALL) ALL
1189 \& %wheel         ALL = (ALL) ALL
1190 .Ve
1191 .PP
1192 We let \fBroot\fR and any user in group \fBwheel\fR run any command on any
1193 host as any user.
1194 .PP
1195 .Vb 1
1196 \& FULLTIMERS     ALL = NOPASSWD: ALL
1197 .Ve
1198 .PP
1199 Full time sysadmins (\fBmillert\fR, \fBmikef\fR, and \fBdowdy\fR) may run any
1200 command on any host without authenticating themselves.
1201 .PP
1202 .Vb 1
1203 \& PARTTIMERS     ALL = ALL
1204 .Ve
1205 .PP
1206 Part time sysadmins (\fBbostley\fR, \fBjwfox\fR, and \fBcrawl\fR) may run any
1207 command on any host but they must authenticate themselves first
1208 (since the entry lacks the \f(CW\*(C`NOPASSWD\*(C'\fR tag).
1209 .PP
1210 .Vb 1
1211 \& jack           CSNETS = ALL
1212 .Ve
1213 .PP
1214 The user \fBjack\fR may run any command on the machines in the \fI\s-1CSNETS\s0\fR alias
1215 (the networks \f(CW128.138.243.0\fR, \f(CW128.138.204.0\fR, and \f(CW128.138.242.0\fR).
1216 Of those networks, only \f(CW128.138.204.0\fR has an explicit netmask (in
1217 \&\s-1CIDR\s0 notation) indicating it is a class C network.  For the other
1218 networks in \fI\s-1CSNETS\s0\fR, the local machine's netmask will be used
1219 during matching.
1220 .PP
1221 .Vb 1
1222 \& lisa           CUNETS = ALL
1223 .Ve
1224 .PP
1225 The user \fBlisa\fR may run any command on any host in the \fI\s-1CUNETS\s0\fR alias
1226 (the class B network \f(CW128.138.0.0\fR).
1227 .PP
1228 .Vb 2
1229 \& operator       ALL = DUMPS, KILL, SHUTDOWN, HALT, REBOOT, PRINTING,\e
1230 \&                sudoedit /etc/printcap, /usr/oper/bin/
1231 .Ve
1232 .PP
1233 The \fBoperator\fR user may run commands limited to simple maintenance.
1234 Here, those are commands related to backups, killing processes, the
1235 printing system, shutting down the system, and any commands in the
1236 directory \fI/usr/oper/bin/\fR.
1237 .PP
1238 .Vb 1
1239 \& joe            ALL = /usr/bin/su operator
1240 .Ve
1241 .PP
1242 The user \fBjoe\fR may only \fIsu\fR\|(1) to operator.
1243 .PP
1244 .Vb 1
1245 \& pete           HPPA = /usr/bin/passwd [A-z]*, !/usr/bin/passwd root
1246 .Ve
1247 .PP
1248 The user \fBpete\fR is allowed to change anyone's password except for
1249 root on the \fI\s-1HPPA\s0\fR machines.  Note that this assumes \fIpasswd\fR\|(1)
1250 does not take multiple usernames on the command line.
1251 .PP
1252 .Vb 1
1253 \& bob            SPARC = (OP) ALL : SGI = (OP) ALL
1254 .Ve
1255 .PP
1256 The user \fBbob\fR may run anything on the \fI\s-1SPARC\s0\fR and \fI\s-1SGI\s0\fR machines
1257 as any user listed in the \fI\s-1OP\s0\fR \f(CW\*(C`Runas_Alias\*(C'\fR (\fBroot\fR and \fBoperator\fR).
1258 .PP
1259 .Vb 1
1260 \& jim            +biglab = ALL
1261 .Ve
1262 .PP
1263 The user \fBjim\fR may run any command on machines in the \fIbiglab\fR netgroup.
1264 \&\fBsudo\fR knows that \*(L"biglab\*(R" is a netgroup due to the '+' prefix.
1265 .PP
1266 .Vb 1
1267 \& +secretaries   ALL = PRINTING, /usr/bin/adduser, /usr/bin/rmuser
1268 .Ve
1269 .PP
1270 Users in the \fBsecretaries\fR netgroup need to help manage the printers
1271 as well as add and remove users, so they are allowed to run those
1272 commands on all machines.
1273 .PP
1274 .Vb 1
1275 \& fred           ALL = (DB) NOPASSWD: ALL
1276 .Ve
1277 .PP
1278 The user \fBfred\fR can run commands as any user in the \fI\s-1DB\s0\fR \f(CW\*(C`Runas_Alias\*(C'\fR
1279 (\fBoracle\fR or \fBsybase\fR) without giving a password.
1280 .PP
1281 .Vb 1
1282 \& john           ALPHA = /usr/bin/su [!-]*, !/usr/bin/su *root*
1283 .Ve
1284 .PP
1285 On the \fI\s-1ALPHA\s0\fR machines, user \fBjohn\fR may su to anyone except root
1286 but he is not allowed to give \fIsu\fR\|(1) any flags.
1287 .PP
1288 .Vb 1
1289 \& jen            ALL, !SERVERS = ALL
1290 .Ve
1291 .PP
1292 The user \fBjen\fR may run any command on any machine except for those
1293 in the \fI\s-1SERVERS\s0\fR \f(CW\*(C`Host_Alias\*(C'\fR (master, mail, www and ns).
1294 .PP
1295 .Vb 1
1296 \& jill           SERVERS = /usr/bin/, !SU, !SHELLS
1297 .Ve
1298 .PP
1299 For any machine in the \fI\s-1SERVERS\s0\fR \f(CW\*(C`Host_Alias\*(C'\fR, \fBjill\fR may run
1300 any commands in the directory \fI/usr/bin/\fR except for those commands
1301 belonging to the \fI\s-1SU\s0\fR and \fI\s-1SHELLS\s0\fR \f(CW\*(C`Cmnd_Aliases\*(C'\fR.
1302 .PP
1303 .Vb 1
1304 \& steve          CSNETS = (operator) /usr/local/op_commands/
1305 .Ve
1306 .PP
1307 The user \fBsteve\fR may run any command in the directory /usr/local/op_commands/
1308 but only as user operator.
1309 .PP
1310 .Vb 1
1311 \& matt           valkyrie = KILL
1312 .Ve
1313 .PP
1314 On his personal workstation, valkyrie, \fBmatt\fR needs to be able to
1315 kill hung processes.
1316 .PP
1317 .Vb 1
1318 \& WEBMASTERS     www = (www) ALL, (root) /usr/bin/su www
1319 .Ve
1320 .PP
1321 On the host www, any user in the \fI\s-1WEBMASTERS\s0\fR \f(CW\*(C`User_Alias\*(C'\fR (will,
1322 wendy, and wim), may run any command as user www (which owns the
1323 web pages) or simply \fIsu\fR\|(1) to www.
1324 .PP
1325 .Vb 2
1326 \& ALL            CDROM = NOPASSWD: /sbin/umount /CDROM,\e
1327 \&                /sbin/mount -o nosuid\e,nodev /dev/cd0a /CDROM
1328 .Ve
1329 .PP
1330 Any user may mount or unmount a CD-ROM on the machines in the \s-1CDROM\s0
1331 \&\f(CW\*(C`Host_Alias\*(C'\fR (orion, perseus, hercules) without entering a password.
1332 This is a bit tedious for users to type, so it is a prime candidate
1333 for encapsulating in a shell script.
1334 .SH "SECURITY NOTES"
1335 .IX Header "SECURITY NOTES"
1336 It is generally not effective to \*(L"subtract\*(R" commands from \f(CW\*(C`ALL\*(C'\fR
1337 using the '!' operator.  A user can trivially circumvent this
1338 by copying the desired command to a different name and then
1339 executing that.  For example:
1340 .PP
1341 .Vb 1
1342 \&    bill        ALL = ALL, !SU, !SHELLS
1343 .Ve
1344 .PP
1345 Doesn't really prevent \fBbill\fR from running the commands listed in
1346 \&\fI\s-1SU\s0\fR or \fI\s-1SHELLS\s0\fR since he can simply copy those commands to a
1347 different name, or use a shell escape from an editor or other
1348 program.  Therefore, these kind of restrictions should be considered
1349 advisory at best (and reinforced by policy).
1350 .SH "PREVENTING SHELL ESCAPES"
1351 .IX Header "PREVENTING SHELL ESCAPES"
1352 Once \fBsudo\fR executes a program, that program is free to do whatever
1353 it pleases, including run other programs.  This can be a security
1354 issue since it is not uncommon for a program to allow shell escapes,
1355 which lets a user bypass \fBsudo\fR's access control and logging.
1356 Common programs that permit shell escapes include shells (obviously),
1357 editors, paginators, mail and terminal programs.
1358 .PP
1359 There are two basic approaches to this problem:
1360 .IP "restrict" 10
1361 .IX Item "restrict"
1362 Avoid giving users access to commands that allow the user to run
1363 arbitrary commands.  Many editors have a restricted mode where shell
1364 escapes are disabled, though \fBsudoedit\fR is a better solution to
1365 running editors via \fBsudo\fR.  Due to the large number of programs that
1366 offer shell escapes, restricting users to the set of programs that
1367 do not if often unworkable.
1368 .IP "noexec" 10
1369 .IX Item "noexec"
1370 Many systems that support shared libraries have the ability to
1371 override default library functions by pointing an environment
1372 variable (usually \f(CW\*(C`LD_PRELOAD\*(C'\fR) to an alternate shared library.
1373 On such systems, \fBsudo\fR's \fInoexec\fR functionality can be used to
1374 prevent a program run by \fBsudo\fR from executing any other programs.
1375 Note, however, that this applies only to native dynamically-linked
1376 executables.  Statically-linked executables and foreign executables
1377 running under binary emulation are not affected.
1378 .Sp
1379 To tell whether or not \fBsudo\fR supports \fInoexec\fR, you can run
1380 the following as root:
1381 .Sp
1382 .Vb 1
1383 \&    sudo -V | grep "dummy exec"
1384 .Ve
1385 .Sp
1386 If the resulting output contains a line that begins with:
1387 .Sp
1388 .Vb 1
1389 \&    File containing dummy exec functions:
1390 .Ve
1391 .Sp
1392 then \fBsudo\fR may be able to replace the exec family of functions
1393 in the standard library with its own that simply return an error.
1394 Unfortunately, there is no foolproof way to know whether or not
1395 \&\fInoexec\fR will work at compile\-time.  \fInoexec\fR should work on
1396 SunOS, Solaris, *BSD, Linux, \s-1IRIX\s0, Tru64 \s-1UNIX\s0, MacOS X, and HP-UX
1397 11.x.  It is known \fBnot\fR to work on \s-1AIX\s0 and UnixWare.  \fInoexec\fR
1398 is expected to work on most operating systems that support the
1399 \&\f(CW\*(C`LD_PRELOAD\*(C'\fR environment variable.  Check your operating system's
1400 manual pages for the dynamic linker (usually ld.so, ld.so.1, dyld,
1401 dld.sl, rld, or loader) to see if \f(CW\*(C`LD_PRELOAD\*(C'\fR is supported.
1402 .Sp
1403 To enable \fInoexec\fR for a command, use the \f(CW\*(C`NOEXEC\*(C'\fR tag as documented
1404 in the User Specification section above.  Here is that example again:
1405 .Sp
1406 .Vb 1
1407 \& aaron  shanty = NOEXEC: /usr/bin/more, /usr/bin/vi
1408 .Ve
1409 .Sp
1410 This allows user \fBaaron\fR to run \fI/usr/bin/more\fR and \fI/usr/bin/vi\fR
1411 with \fInoexec\fR enabled.  This will prevent those two commands from
1412 executing other commands (such as a shell).  If you are unsure
1413 whether or not your system is capable of supporting \fInoexec\fR you
1414 can always just try it out and see if it works.
1415 .PP
1416 Note that restricting shell escapes is not a panacea.  Programs
1417 running as root are still capable of many potentially hazardous
1418 operations (such as changing or overwriting files) that could lead
1419 to unintended privilege escalation.  In the specific case of an
1420 editor, a safer approach is to give the user permission to run
1421 \&\fBsudoedit\fR.
1422 .SH "SEE ALSO"
1423 .IX Header "SEE ALSO"
1424 \&\fIrsh\fR\|(1), \fIsu\fR\|(1), \fIfnmatch\fR\|(3), \fIsudo\fR\|(@mansectsu@), \fIvisudo\fR\|(8)
1425 .SH "CAVEATS"
1426 .IX Header "CAVEATS"
1427 The \fIsudoers\fR file should \fBalways\fR be edited by the \fBvisudo\fR
1428 command which locks the file and does grammatical checking. It is
1429 imperative that \fIsudoers\fR be free of syntax errors since \fBsudo\fR
1430 will not run with a syntactically incorrect \fIsudoers\fR file.
1431 .PP
1432 When using netgroups of machines (as opposed to users), if you
1433 store fully qualified hostnames in the netgroup (as is usually the
1434 case), you either need to have the machine's hostname be fully qualified
1435 as returned by the \f(CW\*(C`hostname\*(C'\fR command or use the \fIfqdn\fR option in
1436 \&\fIsudoers\fR.
1437 .SH "BUGS"
1438 .IX Header "BUGS"
1439 If you feel you have found a bug in \fBsudo\fR, please submit a bug report
1440 at http://www.sudo.ws/sudo/bugs/
1441 .SH "SUPPORT"
1442 .IX Header "SUPPORT"
1443 Limited free support is available via the sudo-users mailing list,
1444 see http://www.sudo.ws/mailman/listinfo/sudo\-users to subscribe or
1445 search the archives.
1446 .SH "DISCLAIMER"
1447 .IX Header "DISCLAIMER"
1448 \&\fBsudo\fR is provided ``\s-1AS\s0 \s-1IS\s0'' and any express or implied warranties,
1449 including, but not limited to, the implied warranties of merchantability
1450 and fitness for a particular purpose are disclaimed.  See the \s-1LICENSE\s0
1451 file distributed with \fBsudo\fR or http://www.sudo.ws/sudo/license.html
1452 for complete details.