prepare to upload
[debian/sudo] / sudoers.pod
1 Copyright (c) 1994-1996, 1998-2005, 2007-2010
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 =pod
22
23 =head1 NAME
24
25 sudoers - list of which users may execute what
26
27 =head1 DESCRIPTION
28
29 The I<sudoers> file is composed of two types of entries: aliases
30 (basically variables) and user specifications (which specify who
31 may run what).
32
33 When multiple entries match for a user, they are applied in order.
34 Where there are multiple matches, the last match is used (which is
35 not necessarily the most specific match).
36
37 The I<sudoers> grammar will be described below in Extended Backus-Naur
38 Form (EBNF).  Don't despair if you don't know what EBNF is; it is
39 fairly simple, and the definitions below are annotated.
40
41 =head2 Quick guide to EBNF
42
43 EBNF is a concise and exact way of describing the grammar of a language.
44 Each EBNF definition is made up of I<production rules>.  E.g.,
45
46  symbol ::= definition | alternate1 | alternate2 ...
47
48 Each I<production rule> references others and thus makes up a
49 grammar for the language.  EBNF also contains the following
50 operators, which many readers will recognize from regular
51 expressions.  Do not, however, confuse them with "wildcard"
52 characters, which have different meanings.
53
54 =over 4
55
56 =item C<?>
57
58 Means that the preceding symbol (or group of symbols) is optional.
59 That is, it may appear once or not at all.
60
61 =item C<*>
62
63 Means that the preceding symbol (or group of symbols) may appear
64 zero or more times.
65
66 =item C<+>
67
68 Means that the preceding symbol (or group of symbols) may appear
69 one or more times.
70
71 =back
72
73 Parentheses may be used to group symbols together.  For clarity,
74 we will use single quotes ('') to designate what is a verbatim character
75 string (as opposed to a symbol name).
76
77 =head2 Aliases
78
79 There are four kinds of aliases: C<User_Alias>, C<Runas_Alias>,
80 C<Host_Alias> and C<Cmnd_Alias>.
81
82  Alias ::= 'User_Alias'  User_Alias (':' User_Alias)* |
83            'Runas_Alias' Runas_Alias (':' Runas_Alias)* |
84            'Host_Alias'  Host_Alias (':' Host_Alias)* |
85            'Cmnd_Alias'  Cmnd_Alias (':' Cmnd_Alias)*
86
87  User_Alias ::= NAME '=' User_List
88
89  Runas_Alias ::= NAME '=' Runas_List
90
91  Host_Alias ::= NAME '=' Host_List
92
93  Cmnd_Alias ::= NAME '=' Cmnd_List
94
95  NAME ::= [A-Z]([A-Z][0-9]_)*
96
97 Each I<alias> definition is of the form
98
99  Alias_Type NAME = item1, item2, ...
100
101 where I<Alias_Type> is one of C<User_Alias>, C<Runas_Alias>, C<Host_Alias>,
102 or C<Cmnd_Alias>.  A C<NAME> is a string of uppercase letters, numbers,
103 and underscore characters ('_').  A C<NAME> B<must> start with an
104 uppercase letter.  It is possible to put several alias definitions
105 of the same type on a single line, joined by a colon (':').  E.g.,
106
107  Alias_Type NAME = item1, item2, item3 : NAME = item4, item5
108
109 The definitions of what constitutes a valid I<alias> member follow.
110
111  User_List ::= User |
112                User ',' User_List
113
114  User ::= '!'* user name |
115           '!'* '#'uid |
116           '!'* '%'group |
117           '!'* '+'netgroup |
118           '!'* '%:'nonunix_group |
119           '!'* User_Alias
120
121 A C<User_List> is made up of one or more user names, uids (prefixed
122 with '#'), system groups (prefixed with '%'), netgroups (prefixed
123 with '+') and C<User_Alias>es.  Each list item may be prefixed with
124 zero or more '!' operators.  An odd number of '!' operators negate
125 the value of the item; an even number just cancel each other out.
126
127 A C<user name>, C<group>, C<netgroup> or C<nonunix_group> may
128 be enclosed in double quotes to avoid the need for escaping special
129 characters.  Alternately, special characters may be specified in
130 escaped hex mode, e.g. \x20 for space.
131
132 The C<nonunix_group> syntax depends on the underlying implementation.
133 For instance, the QAS AD backend supports the following formats:
134
135 =over 4
136
137 =item *
138
139 Group in the same domain: "Group Name"
140
141 =item *
142
143 Group in any domain: "Group Name@FULLY.QUALIFIED.DOMAIN"
144
145 =item *
146
147 Group SID: "S-1-2-34-5678901234-5678901234-5678901234-567"
148
149 =back
150
151 Note that quotes around group names are optional.  Unquoted strings must
152 use a backslash (\) to escape spaces and the '@' symbol.
153
154  Runas_List ::= Runas_Member |
155                 Runas_Member ',' Runas_List
156
157  Runas_Member ::= '!'* user name |
158                   '!'* '#'uid |
159                   '!'* '%'group |
160                   '!'* +netgroup |
161                   '!'* Runas_Alias
162
163 A C<Runas_List> is similar to a C<User_List> except that instead
164 of C<User_Alias>es it can contain C<Runas_Alias>es.  Note that
165 user names and groups are matched as strings.  In other words, two
166 users (groups) with the same uid (gid) are considered to be distinct.
167 If you wish to match all user names with the same uid (e.g.E<nbsp>root
168 and toor), you can use a uid instead (#0 in the example given).
169
170  Host_List ::= Host |
171                Host ',' Host_List
172
173  Host ::= '!'* host name |
174           '!'* ip_addr |
175           '!'* network(/netmask)? |
176           '!'* '+'netgroup |
177           '!'* Host_Alias
178
179 A C<Host_List> is made up of one or more host names, IP addresses,
180 network numbers, netgroups (prefixed with '+') and other aliases.
181 Again, the value of an item may be negated with the '!' operator.
182 If you do not specify a netmask along with the network number,
183 B<sudo> will query each of the local host's network interfaces and,
184 if the network number corresponds to one of the hosts's network
185 interfaces, the corresponding netmask will be used.  The netmask
186 may be specified either in standard IP address notation
187 (e.g.E<nbsp>255.255.255.0 or ffff:ffff:ffff:ffff::),
188 or CIDR notation (number of bits, e.g.E<nbsp>24 or 64).  A host name may
189 include shell-style wildcards (see the L<Wildcards> section below),
190 but unless the C<host name> command on your machine returns the fully
191 qualified host name, you'll need to use the I<fqdn> option for
192 wildcards to be useful.  Note B<sudo> only inspects actual network
193 interfaces; this means that IP address 127.0.0.1 (localhost) will
194 never match.  Also, the host name "localhost" will only match if
195 that is the actual host name, which is usually only the case for
196 non-networked systems.
197
198  Cmnd_List ::= Cmnd |
199                Cmnd ',' Cmnd_List
200
201  commandname ::= file name |
202                  file name args |
203                  file name '""'
204
205  Cmnd ::= '!'* commandname |
206           '!'* directory |
207           '!'* "sudoedit" |
208           '!'* Cmnd_Alias
209
210 A C<Cmnd_List> is a list of one or more commandnames, directories, and other
211 aliases.  A commandname is a fully qualified file name which may include
212 shell-style wildcards (see the L<Wildcards> section below).  A simple
213 file name allows the user to run the command with any arguments he/she
214 wishes.  However, you may also specify command line arguments (including
215 wildcards).  Alternately, you can specify C<""> to indicate that the command
216 may only be run B<without> command line arguments.  A directory is a
217 fully qualified path name ending in a '/'.  When you specify a directory
218 in a C<Cmnd_List>, the user will be able to run any file within that directory
219 (but not in any subdirectories therein).
220
221 If a C<Cmnd> has associated command line arguments, then the arguments
222 in the C<Cmnd> must match exactly those given by the user on the command line
223 (or match the wildcards if there are any).  Note that the following
224 characters must be escaped with a '\' if they are used in command
225 arguments: ',', ':', '=', '\'.  The special command C<"sudoedit">
226 is used to permit a user to run B<sudo> with the B<-e> option (or
227 as B<sudoedit>).  It may take command line arguments just as
228 a normal command does.
229
230 =head2 Defaults
231
232 Certain configuration options may be changed from their default
233 values at runtime via one or more C<Default_Entry> lines.  These
234 may affect all users on any host, all users on a specific host, a
235 specific user, a specific command, or commands being run as a specific user.
236 Note that per-command entries may not include command line arguments.
237 If you need to specify arguments, define a C<Cmnd_Alias> and reference
238 that instead.
239
240  Default_Type ::= 'Defaults' |
241                   'Defaults' '@' Host_List |
242                   'Defaults' ':' User_List |
243                   'Defaults' '!' Cmnd_List |
244                   'Defaults' '>' Runas_List
245
246  Default_Entry ::= Default_Type Parameter_List
247
248  Parameter_List ::= Parameter |
249                     Parameter ',' Parameter_List
250
251  Parameter ::= Parameter '=' Value |
252                Parameter '+=' Value |
253                Parameter '-=' Value |
254                '!'* Parameter
255
256 Parameters may be B<flags>, B<integer> values, B<strings>, or B<lists>.
257 Flags are implicitly boolean and can be turned off via the '!'
258 operator.  Some integer, string and list parameters may also be
259 used in a boolean context to disable them.  Values may be enclosed
260 in double quotes (C<">) when they contain multiple words.  Special
261 characters may be escaped with a backslash (C<\>).
262
263 Lists have two additional assignment operators, C<+=> and C<-=>.
264 These operators are used to add to and delete from a list respectively.
265 It is not an error to use the C<-=> operator to remove an element
266 that does not exist in a list.
267
268 Defaults entries are parsed in the following order: generic, host
269 and user Defaults first, then runas Defaults and finally command
270 defaults.
271
272 See L<"SUDOERS OPTIONS"> for a list of supported Defaults parameters.
273
274 =head2 User Specification
275
276  User_Spec ::= User_List Host_List '=' Cmnd_Spec_List \
277                (':' Host_List '=' Cmnd_Spec_List)*
278
279  Cmnd_Spec_List ::= Cmnd_Spec |
280                     Cmnd_Spec ',' Cmnd_Spec_List
281
282  Cmnd_Spec ::= Runas_Spec? SELinux_Spec? Tag_Spec* Cmnd
283
284  Runas_Spec ::= '(' Runas_List? (':' Runas_List)? ')'
285
286  SELinux_Spec ::= ('ROLE=role' | 'TYPE=type')
287
288  Tag_Spec ::= ('NOPASSWD:' | 'PASSWD:' | 'NOEXEC:' | 'EXEC:' |
289                'SETENV:' | 'NOSETENV:' | 'LOG_INPUT:' | 'NOLOG_INPUT:' |
290                'LOG_OUTPUT:' | 'NOLOG_OUTPUT:')
291
292 A B<user specification> determines which commands a user may run
293 (and as what user) on specified hosts.  By default, commands are
294 run as B<root>, but this can be changed on a per-command basis.
295
296 The basic structure of a user specification is `who = where (as_whom)
297 what'.  Let's break that down into its constituent parts:
298
299 =head2 Runas_Spec
300
301 A C<Runas_Spec> determines the user and/or the group that a command
302 may be run as.  A fully-specified C<Runas_Spec> consists of two
303 C<Runas_List>s (as defined above) separated by a colon (':') and
304 enclosed in a set of parentheses.  The first C<Runas_List> indicates
305 which users the command may be run as via B<sudo>'s B<-u> option.
306 The second defines a list of groups that can be specified via
307 B<sudo>'s B<-g> option.  If both C<Runas_List>s are specified, the
308 command may be run with any combination of users and groups listed
309 in their respective C<Runas_List>s.  If only the first is specified,
310 the command may be run as any user in the list but no B<-g> option
311 may be specified.  If the first C<Runas_List> is empty but the
312 second is specified, the command may be run as the invoking user
313 with the group set to any listed in the C<Runas_List>.  If no
314 C<Runas_Spec> is specified the command may be run as B<root> and
315 no group may be specified.
316
317 A C<Runas_Spec> sets the default for the commands that follow it.
318 What this means is that for the entry:
319
320  dgb    boulder = (operator) /bin/ls, /bin/kill, /usr/bin/lprm
321
322 The user B<dgb> may run F</bin/ls>, F</bin/kill>, and
323 F</usr/bin/lprm> -- but only as B<operator>.  E.g.,
324
325  $ sudo -u operator /bin/ls.
326
327 It is also possible to override a C<Runas_Spec> later on in an
328 entry.  If we modify the entry like so:
329
330  dgb    boulder = (operator) /bin/ls, (root) /bin/kill, /usr/bin/lprm
331
332 Then user B<dgb> is now allowed to run F</bin/ls> as B<operator>,
333 but  F</bin/kill> and F</usr/bin/lprm> as B<root>.
334
335 We can extend this to allow B<dgb> to run C</bin/ls> with either
336 the user or group set to B<operator>:
337
338  dgb    boulder = (operator : operator) /bin/ls, (root) /bin/kill, \
339         /usr/bin/lprm
340
341 In the following example, user B<tcm> may run commands that access
342 a modem device file with the dialer group.  Note that in this example
343 only the group will be set, the command still runs as user B<tcm>.
344
345  tcm    boulder = (:dialer) /usr/bin/tip, /usr/bin/cu, \
346         /usr/local/bin/minicom
347
348 =head2 SELinux_Spec
349
350 On systems with SELinux support, I<sudoers> entries may optionally have
351 an SELinux role and/or type associated with a command.  If a role or
352 type is specified with the command it will override any default values
353 specified in I<sudoers>.  A role or type specified on the command line,
354 however, will supercede the values in I<sudoers>.
355
356 =head2 Tag_Spec
357
358 A command may have zero or more tags associated with it.  There are
359 eight possible tag values, C<NOPASSWD>, C<PASSWD>, C<NOEXEC>,
360 C<EXEC>, C<SETENV>, C<NOSETENV>, C<LOG_INPUT>, C<NOLOG_INPUT>,
361 C<LOG_OUTPUT> and C<NOLOG_OUTPUT>.  Once a tag is set on a C<Cmnd>,
362 subsequent C<Cmnd>s in the C<Cmnd_Spec_List>, inherit the tag unless
363 it is overridden by the opposite tag (i.e.: C<PASSWD> overrides
364 C<NOPASSWD> and C<NOEXEC> overrides C<EXEC>).
365
366 =head3 NOPASSWD and PASSWD
367
368 By default, B<sudo> requires that a user authenticate him or herself
369 before running a command.  This behavior can be modified via the
370 C<NOPASSWD> tag.  Like a C<Runas_Spec>, the C<NOPASSWD> tag sets
371 a default for the commands that follow it in the C<Cmnd_Spec_List>.
372 Conversely, the C<PASSWD> tag can be used to reverse things.
373 For example:
374
375  ray    rushmore = NOPASSWD: /bin/kill, /bin/ls, /usr/bin/lprm
376
377 would allow the user B<ray> to run F</bin/kill>, F</bin/ls>, and
378 F</usr/bin/lprm> as B<root> on the machine rushmore without
379 authenticating himself.  If we only want B<ray> to be able to
380 run F</bin/kill> without a password the entry would be:
381
382  ray    rushmore = NOPASSWD: /bin/kill, PASSWD: /bin/ls, /usr/bin/lprm
383
384 Note, however, that the C<PASSWD> tag has no effect on users who are
385 in the group specified by the I<exempt_group> option.
386
387 By default, if the C<NOPASSWD> tag is applied to any of the entries
388 for a user on the current host, he or she will be able to run
389 C<sudo -l> without a password.  Additionally, a user may only run
390 C<sudo -v> without a password if the C<NOPASSWD> tag is present
391 for all a user's entries that pertain to the current host.
392 This behavior may be overridden via the verifypw and listpw options.
393
394 =head3 NOEXEC and EXEC
395
396 If B<sudo> has been compiled with I<noexec> support and the underlying
397 operating system supports it, the C<NOEXEC> tag can be used to prevent
398 a dynamically-linked executable from running further commands itself.
399
400 In the following example, user B<aaron> may run F</usr/bin/more>
401 and F</usr/bin/vi> but shell escapes will be disabled.
402
403  aaron  shanty = NOEXEC: /usr/bin/more, /usr/bin/vi
404
405 See the L<PREVENTING SHELL ESCAPES> section below for more details
406 on how C<NOEXEC> works and whether or not it will work on your system.
407
408 =head3 SETENV and NOSETENV
409
410 These tags override the value of the I<setenv> option on a per-command
411 basis.  Note that if C<SETENV> has been set for a command, any
412 environment variables set on the command line way are not subject
413 to the restrictions imposed by I<env_check>, I<env_delete>, or
414 I<env_keep>.  As such, only trusted users should be allowed to set
415 variables in this manner.  If the command matched is B<ALL>, the
416 C<SETENV> tag is implied for that command; this default may
417 be overridden by use of the C<NOSETENV> tag.
418
419 =head3 LOG_INPUT and NOLOG_INPUT
420
421 These tags override the value of the I<log_input> option on a
422 per-command basis.  For more information, see the description of
423 I<log_input> in the L<"SUDOERS OPTIONS"> section below.
424
425 =head3 LOG_OUTPUT and NOLOG_OUTPUT
426
427 These tags override the value of the I<log_output> option on a
428 per-command basis.  For more information, see the description of
429 I<log_output> in the L<"SUDOERS OPTIONS"> section below.
430
431 =head2 Wildcards
432
433 B<sudo> allows shell-style I<wildcards> (aka meta or glob characters)
434 to be used in host names, path names and command line arguments in
435 the I<sudoers> file.  Wildcard matching is done via the B<POSIX>
436 L<glob(3)> and L<fnmatch(3)> routines.  Note that these are I<not>
437 regular expressions.
438
439 =over 8
440
441 =item C<*>
442
443 Matches any set of zero or more characters.
444
445 =item C<?>
446
447 Matches any single character.
448
449 =item C<[...]>
450
451 Matches any character in the specified range.
452
453 =item C<[!...]>
454
455 Matches any character B<not> in the specified range.
456
457 =item C<\x>
458
459 For any character "x", evaluates to "x".  This is used to
460 escape special characters such as: "*", "?", "[", and "}".
461
462 =back
463
464 POSIX character classes may also be used if your system's L<glob(3)>
465 and L<fnmatch(3)> functions support them.  However, because the
466 C<':'> character has special meaning in I<sudoers>, it must be
467 escaped.  For example:
468
469     /bin/ls [[\:alpha\:]]*
470
471 Would match any file name beginning with a letter.
472
473 Note that a forward slash ('/') will B<not> be matched by
474 wildcards used in the path name.  When matching the command
475 line arguments, however, a slash B<does> get matched by
476 wildcards.  This is to make a path like:
477
478     /usr/bin/*
479
480 match F</usr/bin/who> but not F</usr/bin/X11/xterm>.
481
482 =head2 Exceptions to wildcard rules
483
484 The following exceptions apply to the above rules:
485
486 =over 8
487
488 =item C<"">
489
490 If the empty string C<""> is the only command line argument in the
491 I<sudoers> entry it means that command is not allowed to be run
492 with B<any> arguments.
493
494 =back
495
496 =head2 Including other files from within sudoers
497
498 It is possible to include other I<sudoers> files from within the
499 I<sudoers> file currently being parsed using the C<#include> and
500 C<#includedir> directives.
501
502 This can be used, for example, to keep a site-wide I<sudoers> file
503 in addition to a local, per-machine file.  For the sake of this
504 example the site-wide I<sudoers> will be F</etc/sudoers> and the
505 per-machine one will be F</etc/sudoers.local>.  To include
506 F</etc/sudoers.local> from within F</etc/sudoers> we would use the
507 following line in F</etc/sudoers>:
508
509 =over 4
510
511 C<#include /etc/sudoers.local>
512
513 =back
514
515 When B<sudo> reaches this line it will suspend processing of the
516 current file (F</etc/sudoers>) and switch to F</etc/sudoers.local>.
517 Upon reaching the end of F</etc/sudoers.local>, the rest of
518 F</etc/sudoers> will be processed.  Files that are included may
519 themselves include other files.  A hard limit of 128 nested include
520 files is enforced to prevent include file loops.
521
522 The file name may include the C<%h> escape, signifying the short form
523 of the host name.  I.e., if the machine's host name is "xerxes", then
524
525 C<#include /etc/sudoers.%h>
526
527 will cause B<sudo> to include the file F</etc/sudoers.xerxes>.
528
529 The C<#includedir> directive can be used to create a F<sudo.d>
530 directory that the system package manager can drop I<sudoers> rules
531 into as part of package installation.  For example, given:
532
533 C<#includedir /etc/sudoers.d>
534
535 B<sudo> will read each file in F</etc/sudoers.d>, skipping file
536 names that end in C<~> or contain a C<.> character to avoid causing
537 problems with package manager or editor temporary/backup files.
538 Files are parsed in sorted lexical order.  That is,
539 F</etc/sudoers.d/01_first> will be parsed before
540 F</etc/sudoers.d/10_second>.  Be aware that because the sorting is
541 lexical, not numeric, F</etc/sudoers.d/1_whoops> would be loaded
542 B<after> F</etc/sudoers.d/10_second>.  Using a consistent number
543 of leading zeroes in the file names can be used to avoid such
544 problems.
545
546 Note that unlike files included via C<#include>, B<visudo> will not
547 edit the files in a C<#includedir> directory unless one of them
548 contains a syntax error.  It is still possible to run B<visudo>
549 with the C<-f> flag to edit the files directly.
550
551 =head2 Other special characters and reserved words
552
553 The pound sign ('#') is used to indicate a comment (unless it is
554 part of a #include directive or unless it occurs in the context of
555 a user name and is followed by one or more digits, in which case
556 it is treated as a uid).  Both the comment character and any text
557 after it, up to the end of the line, are ignored.
558
559 The reserved word B<ALL> is a built-in I<alias> that always causes
560 a match to succeed.  It can be used wherever one might otherwise
561 use a C<Cmnd_Alias>, C<User_Alias>, C<Runas_Alias>, or C<Host_Alias>.
562 You should not try to define your own I<alias> called B<ALL> as the
563 built-in alias will be used in preference to your own.  Please note
564 that using B<ALL> can be dangerous since in a command context, it
565 allows the user to run B<any> command on the system.
566
567 An exclamation point ('!') can be used as a logical I<not> operator
568 both in an I<alias> and in front of a C<Cmnd>.  This allows one to
569 exclude certain values.  Note, however, that using a C<!> in
570 conjunction with the built-in C<ALL> alias to allow a user to
571 run "all but a few" commands rarely works as intended (see SECURITY
572 NOTES below).
573
574 Long lines can be continued with a backslash ('\') as the last
575 character on the line.
576
577 Whitespace between elements in a list as well as special syntactic
578 characters in a I<User Specification> ('=', ':', '(', ')') is optional.
579
580 The following characters must be escaped with a backslash ('\') when
581 used as part of a word (e.g.E<nbsp>a user name or host name):
582 '@', '!', '=', ':', ',', '(', ')', '\'.
583
584 =head1 SUDOERS OPTIONS
585
586 B<sudo>'s behavior can be modified by C<Default_Entry> lines, as
587 explained earlier.  A list of all supported Defaults parameters,
588 grouped by type, are listed below.
589
590 B<Boolean Flags>:
591
592 =over 16
593
594 =item always_set_home
595
596 If enabled, B<sudo> will set the C<HOME> environment variable to the
597 home directory of the target user (which is root unless the B<-u>
598 option is used).  This effectively means that the B<-H> option is
599 always implied.  Note that C<HOME> is already set when the the
600 I<env_reset> option is enabled, so I<always_set_home> is only
601 effective for configurations where I<env_reset> is disabled.
602 This flag is I<off> by default.
603
604 =item authenticate
605
606 If set, users must authenticate themselves via a password (or other
607 means of authentication) before they may run commands.  This default
608 may be overridden via the C<PASSWD> and C<NOPASSWD> tags.
609 This flag is I<on> by default.
610
611 =item closefrom_override
612
613 If set, the user may use B<sudo>'s B<-C> option which
614 overrides the default starting point at which B<sudo> begins
615 closing open file descriptors.  This flag is I<off> by default.
616
617 =item compress_io
618
619 If set, and B<sudo> is configured to log a command's input or output,
620 the I/O logs will be compressed using B<zlib>.  This flag is I<on>
621 by default when B<sudo> is compiled with B<zlib> support.
622
623 =item env_editor
624
625 If set, B<visudo> will use the value of the EDITOR or VISUAL
626 environment variables before falling back on the default editor list.
627 Note that this may create a security hole as it allows the user to
628 run any arbitrary command as root without logging.  A safer alternative
629 is to place a colon-separated list of editors in the C<editor>
630 variable.  B<visudo> will then only use the EDITOR or VISUAL if
631 they match a value specified in C<editor>.  This flag is I<@env_editor@> by
632 default.
633
634 =item env_reset
635
636 If set, B<sudo> will reset the environment to only contain the
637 LOGNAME, MAIL, SHELL, USER, USERNAME and the C<SUDO_*> variables.  Any
638 variables in the caller's environment that match the C<env_keep>
639 and C<env_check> lists are then added.  The default contents of the
640 C<env_keep> and C<env_check> lists are displayed when B<sudo> is
641 run by root with the I<-V> option.  If the I<secure_path> option
642 is set, its value will be used for the C<PATH> environment variable.
643 This flag is I<on> by default.
644
645 =item fast_glob
646
647 Normally, B<sudo> uses the L<glob(3)> function to do shell-style
648 globbing when matching path names.  However, since it accesses the
649 file system, L<glob(3)> can take a long time to complete for some
650 patterns, especially when the pattern references a network file
651 system that is mounted on demand (automounted).  The I<fast_glob>
652 option causes B<sudo> to use the L<fnmatch(3)> function, which does
653 not access the file system to do its matching.  The disadvantage
654 of I<fast_glob> is that it is unable to match relative path names
655 such as F<./ls> or F<../bin/ls>.  This has security implications
656 when path names that include globbing characters are used with the
657 negation operator, C<'!'>, as such rules can be trivially bypassed.
658 As such, this option should not be used when I<sudoers> contains rules 
659 that contain negated path names which include globbing characters.
660 This flag is I<off> by default.
661
662 =item fqdn
663
664 Set this flag if you want to put fully qualified host names in the
665 I<sudoers> file.  I.e., instead of myhost you would use myhost.mydomain.edu.
666 You may still use the short form if you wish (and even mix the two).
667 Beware that turning on I<fqdn> requires B<sudo> to make DNS lookups
668 which may make B<sudo> unusable if DNS stops working (for example
669 if the machine is not plugged into the network).  Also note that
670 you must use the host's official name as DNS knows it.  That is,
671 you may not use a host alias (C<CNAME> entry) due to performance
672 issues and the fact that there is no way to get all aliases from
673 DNS.  If your machine's host name (as returned by the C<hostname>
674 command) is already fully qualified you shouldn't need to set
675 I<fqdn>.  This flag is I<@fqdn@> by default.
676
677 =item ignore_dot
678
679 If set, B<sudo> will ignore '.' or '' (current dir) in the C<PATH>
680 environment variable; the C<PATH> itself is not modified.  This
681 flag is I<@ignore_dot@> by default.
682
683 =item ignore_local_sudoers
684
685 If set via LDAP, parsing of F<@sysconfdir@/sudoers> will be skipped.
686 This is intended for Enterprises that wish to prevent the usage of local
687 sudoers files so that only LDAP is used.  This thwarts the efforts of
688 rogue operators who would attempt to add roles to F<@sysconfdir@/sudoers>.
689 When this option is present, F<@sysconfdir@/sudoers> does not even need to
690 exist. Since this option tells B<sudo> how to behave when no specific LDAP
691 entries have been matched, this sudoOption is only meaningful for the
692 C<cn=defaults> section.  This flag is I<off> by default.
693
694 =item insults
695
696 If set, B<sudo> will insult users when they enter an incorrect
697 password.  This flag is I<@insults@> by default.
698
699 =item log_host
700
701 If set, the host name will be logged in the (non-syslog) B<sudo> log file.
702 This flag is I<off> by default.
703
704 =item log_year
705
706 If set, the four-digit year will be logged in the (non-syslog) B<sudo> log file.
707 This flag is I<off> by default.
708
709 =item long_otp_prompt
710
711 When validating with a One Time Password (OPT) scheme such as
712 B<S/Key> or B<OPIE>, a two-line prompt is used to make it easier
713 to cut and paste the challenge to a local window.  It's not as
714 pretty as the default but some people find it more convenient.  This
715 flag is I<@long_otp_prompt@> by default.
716
717 =item mail_always
718
719 Send mail to the I<mailto> user every time a users runs B<sudo>.
720 This flag is I<off> by default.
721
722 =item mail_badpass
723
724 Send mail to the I<mailto> user if the user running B<sudo> does not
725 enter the correct password.  This flag is I<off> by default.
726
727 =item mail_no_host
728
729 If set, mail will be sent to the I<mailto> user if the invoking
730 user exists in the I<sudoers> file, but is not allowed to run
731 commands on the current host.  This flag is I<@mail_no_host@> by default.
732
733 =item mail_no_perms
734
735 If set, mail will be sent to the I<mailto> user if the invoking
736 user is allowed to use B<sudo> but the command they are trying is not
737 listed in their I<sudoers> file entry or is explicitly denied.
738 This flag is I<@mail_no_perms@> by default.
739
740 =item mail_no_user
741
742 If set, mail will be sent to the I<mailto> user if the invoking
743 user is not in the I<sudoers> file.  This flag is I<@mail_no_user@>
744 by default.
745
746 =item noexec
747
748 If set, all commands run via B<sudo> will behave as if the C<NOEXEC>
749 tag has been set, unless overridden by a C<EXEC> tag.  See the
750 description of I<NOEXEC and EXEC> below as well as the L<PREVENTING SHELL
751 ESCAPES> section at the end of this manual.  This flag is I<off> by default.
752
753 =item path_info
754
755 Normally, B<sudo> will tell the user when a command could not be
756 found in their C<PATH> environment variable.  Some sites may wish
757 to disable this as it could be used to gather information on the
758 location of executables that the normal user does not have access
759 to.  The disadvantage is that if the executable is simply not in
760 the user's C<PATH>, B<sudo> will tell the user that they are not
761 allowed to run it, which can be confusing.  This flag is I<@path_info@>
762 by default.
763
764 =item passprompt_override
765
766 The password prompt specified by I<passprompt> will normally only
767 be used if the password prompt provided by systems such as PAM matches
768 the string "Password:".  If I<passprompt_override> is set, I<passprompt>
769 will always be used.  This flag is I<off> by default.
770
771 =item preserve_groups
772
773 By default, B<sudo> will initialize the group vector to the list of
774 groups the target user is in.  When I<preserve_groups> is set, the
775 user's existing group vector is left unaltered.  The real and
776 effective group IDs, however, are still set to match the target
777 user.  This flag is I<off> by default.
778
779 =item pwfeedback
780
781 By default, B<sudo> reads the password like most other Unix programs,
782 by turning off echo until the user hits the return (or enter) key.
783 Some users become confused by this as it appears to them that B<sudo>
784 has hung at this point.  When I<pwfeedback> is set, B<sudo> will
785 provide visual feedback when the user presses a key.  Note that
786 this does have a security impact as an onlooker may be able to
787 determine the length of the password being entered.
788 This flag is I<off> by default.
789
790 =item requiretty
791
792 If set, B<sudo> will only run when the user is logged in to a real
793 tty.  When this flag is set, B<sudo> can only be run from a login
794 session and not via other means such as L<cron(8)> or cgi-bin scripts.
795 This flag is I<off> by default.
796
797 =item root_sudo
798
799 If set, root is allowed to run B<sudo> too.  Disabling this prevents users
800 from "chaining" B<sudo> commands to get a root shell by doing something
801 like C<"sudo sudo /bin/sh">.  Note, however, that turning off I<root_sudo>
802 will also prevent root from running B<sudoedit>.
803 Disabling I<root_sudo> provides no real additional security; it
804 exists purely for historical reasons.
805 This flag is I<@root_sudo@> by default.
806
807 =item rootpw
808
809 If set, B<sudo> will prompt for the root password instead of the password
810 of the invoking user.  This flag is I<off> by default.
811
812 =item runaspw
813
814 If set, B<sudo> will prompt for the password of the user defined by the
815 I<runas_default> option (defaults to C<@runas_default@>) instead of the
816 password of the invoking user.  This flag is I<off> by default.
817
818 =item set_home
819
820 If enabled and B<sudo> is invoked with the B<-s> option the C<HOME>
821 environment variable will be set to the home directory of the target
822 user (which is root unless the B<-u> option is used).  This effectively
823 makes the B<-s> option imply B<-H>.  Note that C<HOME> is already
824 set when the the I<env_reset> option is enabled, so I<set_home> is
825 only effective for configurations where I<env_reset> is disabled.
826 This flag is I<off> by default.
827
828 =item set_logname
829
830 Normally, B<sudo> will set the C<LOGNAME>, C<USER> and C<USERNAME>
831 environment variables to the name of the target user (usually root
832 unless the B<-u> option is given).  However, since some programs
833 (including the RCS revision control system) use C<LOGNAME> to
834 determine the real identity of the user, it may be desirable to
835 change this behavior.  This can be done by negating the set_logname
836 option.  Note that if the I<env_reset> option has not been disabled,
837 entries in the I<env_keep> list will override the value of
838 I<set_logname>.  This flag is I<on> by default.
839
840 =item setenv
841
842 Allow the user to disable the I<env_reset> option from the command
843 line.  Additionally, environment variables set via the command line
844 are not subject to the restrictions imposed by I<env_check>,
845 I<env_delete>, or I<env_keep>.  As such, only trusted users should
846 be allowed to set variables in this manner.  This flag is I<off>
847 by default.
848
849 =item shell_noargs
850
851 If set and B<sudo> is invoked with no arguments it acts as if the
852 B<-s> option had been given.  That is, it runs a shell as root (the
853 shell is determined by the C<SHELL> environment variable if it is
854 set, falling back on the shell listed in the invoking user's
855 /etc/passwd entry if not).  This flag is I<off> by default.
856
857 =item stay_setuid
858
859 Normally, when B<sudo> executes a command the real and effective
860 UIDs are set to the target user (root by default).  This option
861 changes that behavior such that the real UID is left as the invoking
862 user's UID.  In other words, this makes B<sudo> act as a setuid
863 wrapper.  This can be useful on systems that disable some potentially
864 dangerous functionality when a program is run setuid.  This option
865 is only effective on systems with either the setreuid() or setresuid()
866 function.  This flag is I<off> by default.
867
868 =item targetpw
869
870 If set, B<sudo> will prompt for the password of the user specified
871 by the B<-u> option (defaults to C<root>) instead of the password
872 of the invoking user.  In addition, the timestamp file name will
873 include the target user's name.  Note that this flag precludes the
874 use of a uid not listed in the passwd database as an argument to
875 the B<-u> option.  This flag is I<off> by default.
876
877 =item log_input
878
879 If set, B<sudo> will run the command in a I<pseudo tty> and log all
880 user input.
881 If the standard input is not connected to the user's tty, due to
882 I/O redirection or because the command is part of a pipeline, that
883 input is also captured and stored in a separate log file.
884
885 Input is logged to the F</var/log/sudo-io> directory using a unique
886 session ID that is included in the normal B<sudo> log line, prefixed
887 with I<TSID=>.
888
889 =item log_output
890
891 If set, B<sudo> will run the command in a I<pseudo tty> and log all
892 output that is sent to the screen, similar to the script(1) command.
893 If the standard output or standard error is not connected to the
894 user's tty, due to I/O redirection or because the command is part
895 of a pipeline, that output is also captured and stored in separate
896 log files.
897
898 Output is logged to the
899 F</var/log/sudo-io> directory using a unique session ID that is
900 included in the normal B<sudo> log line, prefixed with I<TSID=>.
901
902 Output logs may be viewed with the L<sudoreplay(8)> utility, which
903 can also be used to list or search the available logs.
904
905 =item tty_tickets
906
907 If set, users must authenticate on a per-tty basis.  With this flag
908 enabled, B<sudo> will use a file named for the tty the user is
909 logged in on in the user's time stamp directory.  If disabled, the
910 time stamp of the directory is used instead.  This flag is
911 I<@tty_tickets@> by default.
912
913 =item umask_override
914
915 If set, B<sudo> will set the umask as specified by I<sudoers> without
916 modification.  This makes it possible to specify a more permissive
917 umask in I<sudoers> than the user's own umask and matches historical
918 behavior.  If I<umask_override> is not set, B<sudo> will set the
919 umask to be the union of the user's umask and what is specified in
920 I<sudoers>.  This flag is I<off> by default.
921
922 =item use_loginclass
923
924 If set, B<sudo> will apply the defaults specified for the target user's
925 login class if one exists.  Only available if B<sudo> is configured with
926 the --with-logincap option.  This flag is I<off> by default.
927
928 =item use_pty
929
930 If set, B<sudo> will run the command in a pseudo-pty even if no I/O
931 logging is being gone.  A malicious program run under B<sudo> could
932 conceivably fork a background process that retains to the user's
933 terminal device after the main program has finished executing.  Use
934 of this option will make that impossible.
935
936 =item visiblepw
937
938 By default, B<sudo> will refuse to run if the user must enter a
939 password but it is not possible to disable echo on the terminal.
940 If the I<visiblepw> flag is set, B<sudo> will prompt for a password
941 even when it would be visible on the screen.  This makes it possible
942 to run things like C<"rsh somehost sudo ls"> since L<rsh(1)> does
943 not allocate a tty.  This flag is I<off> by default.
944
945 =back
946
947 B<Integers>:
948
949 =over 16
950
951 =item closefrom
952
953 Before it executes a command, B<sudo> will close all open file
954 descriptors other than standard input, standard output and standard
955 error (ie: file descriptors 0-2).  The I<closefrom> option can be used
956 to specify a different file descriptor at which to start closing.
957 The default is C<3>.
958
959 =item passwd_tries
960
961 The number of tries a user gets to enter his/her password before
962 B<sudo> logs the failure and exits.  The default is C<@passwd_tries@>.
963
964 =back
965
966 B<Integers that can be used in a boolean context>:
967
968 =over 16
969
970 =item loglinelen
971
972 Number of characters per line for the file log.  This value is used
973 to decide when to wrap lines for nicer log files.  This has no
974 effect on the syslog log file, only the file log.  The default is
975 C<@loglen@> (use 0 or negate the option to disable word wrap).
976
977 =item passwd_timeout
978
979 Number of minutes before the B<sudo> password prompt times out, or
980 C<0> for no timeout.  The timeout may include a fractional component
981 if minute granularity is insufficient, for example C<2.5>.  The
982 default is C<@password_timeout@>.
983
984 =item timestamp_timeout
985
986 Number of minutes that can elapse before B<sudo> will ask for a
987 passwd again.  The timeout may include a fractional component if
988 minute granularity is insufficient, for example C<2.5>.  The default
989 is C<@timeout@>.  Set this to C<0> to always prompt for a password.
990 If set to a value less than C<0> the user's timestamp will never
991 expire.  This can be used to allow users to create or delete their
992 own timestamps via C<sudo -v> and C<sudo -k> respectively.
993
994 =item umask
995
996 Umask to use when running the command.  Negate this option or set
997 it to 0777 to preserve the user's umask.  The actual umask that is
998 used will be the union of the user's umask and the value of the
999 I<umask> option, which defaults to C<@sudo_umask@>.  This guarantees
1000 that B<sudo> never lowers the umask when running a command.  Note
1001 on systems that use PAM, the default PAM configuration may specify
1002 its own umask which will override the value set in I<sudoers>.
1003
1004 =back
1005
1006 B<Strings>:
1007
1008 =over 16
1009
1010 =item badpass_message
1011
1012 Message that is displayed if a user enters an incorrect password.
1013 The default is C<@badpass_message@> unless insults are enabled.
1014
1015 =item editor
1016
1017 A colon (':') separated list of editors allowed to be used with
1018 B<visudo>.  B<visudo> will choose the editor that matches the user's
1019 EDITOR environment variable if possible, or the first editor in the
1020 list that exists and is executable.  The default is C<"@editor@">.
1021
1022 =item mailsub
1023
1024 Subject of the mail sent to the I<mailto> user. The escape C<%h>
1025 will expand to the host name of the machine.
1026 Default is C<@mailsub@>.
1027
1028 =item noexec_file
1029
1030 Path to a shared library containing dummy versions of the execv(),
1031 execve() and fexecve() library functions that just return an error.
1032 This is used to implement the I<noexec> functionality on systems that
1033 support C<LD_PRELOAD> or its equivalent.  Defaults to F<@noexec_file@>.
1034
1035 =item passprompt
1036
1037 The default prompt to use when asking for a password; can be overridden
1038 via the B<-p> option or the C<SUDO_PROMPT> environment variable.
1039 The following percent (`C<%>') escapes are supported:
1040
1041 =over 4
1042
1043 =item C<%H>
1044
1045 expanded to the local host name including the domain name
1046 (on if the machine's host name is fully qualified or the I<fqdn>
1047 option is set)
1048
1049 =item C<%h>
1050
1051 expanded to the local host name without the domain name
1052
1053 =item C<%p>
1054
1055 expanded to the user whose password is being asked for (respects the 
1056 I<rootpw>, I<targetpw> and I<runaspw> flags in I<sudoers>)
1057
1058 =item C<%U>
1059
1060 expanded to the login name of the user the command will
1061 be run as (defaults to root)
1062
1063 =item C<%u>
1064
1065 expanded to the invoking user's login name
1066
1067 =item C<%%>
1068
1069 two consecutive C<%> characters are collapsed into a single C<%> character
1070
1071 =back
1072
1073 The default value is C<@passprompt@>.
1074
1075 =item role
1076
1077 The default SELinux role to use when constructing a new security
1078 context to run the command.  The default role may be overridden on
1079 a per-command basis in I<sudoers> or via command line options.
1080 This option is only available whe B<sudo> is built with SELinux support.
1081
1082 =item runas_default
1083
1084 The default user to run commands as if the B<-u> option is not specified
1085 on the command line.  This defaults to C<@runas_default@>.
1086 Note that if I<runas_default> is set it B<must> occur before
1087 any C<Runas_Alias> specifications.
1088
1089 =item syslog_badpri
1090
1091 Syslog priority to use when user authenticates unsuccessfully.
1092 Defaults to C<@badpri@>.
1093
1094 =item syslog_goodpri
1095
1096 Syslog priority to use when user authenticates successfully.
1097 Defaults to C<@goodpri@>.
1098
1099 =item sudoers_locale
1100
1101 Locale to use when parsing the sudoers file.  Note that changing
1102 the locale may affect how sudoers is interpreted.
1103 Defaults to C<"C">.
1104
1105 =item timestampdir
1106
1107 The directory in which B<sudo> stores its timestamp files.
1108 The default is F<@timedir@>.
1109
1110 =item timestampowner
1111
1112 The owner of the timestamp directory and the timestamps stored therein.
1113 The default is C<root>.
1114
1115 =item type
1116
1117 The default SELinux type to use when constructing a new security
1118 context to run the command.  The default type may be overridden on
1119 a per-command basis in I<sudoers> or via command line options.
1120 This option is only available whe B<sudo> is built with SELinux support.
1121
1122 =back
1123
1124 B<Strings that can be used in a boolean context>:
1125
1126 =over 12
1127
1128 =item askpass
1129
1130 The I<askpass> option specifies the fully qualified path to a helper
1131 program used to read the user's password when no terminal is
1132 available.  This may be the case when B<sudo> is executed from a
1133 graphical (as opposed to text-based) application.  The program
1134 specified by I<askpass> should display the argument passed to it
1135 as the prompt and write the user's password to the standard output.
1136 The value of I<askpass> may be overridden by the C<SUDO_ASKPASS>
1137 environment variable.
1138
1139 =item env_file
1140
1141 The I<env_file> options specifies the fully qualified path to a
1142 file containing variables to be set in the environment of the program
1143 being run.  Entries in this file should either be of the form
1144 C<VARIABLE=value> or C<export VARIABLE=value>.  The value may
1145 optionally be surrounded by single or double quotes.  Variables in
1146 this file are subject to other B<sudo> environment settings such
1147 as I<env_keep> and I<env_check>.
1148
1149 =item exempt_group
1150
1151 Users in this group are exempt from password and PATH requirements.
1152 This is not set by default.
1153
1154 =item lecture
1155
1156 This option controls when a short lecture will be printed along with
1157 the password prompt.  It has the following possible values:
1158
1159 =over 8
1160
1161 =item always
1162
1163 Always lecture the user.
1164
1165 =item never
1166
1167 Never lecture the user.
1168
1169 =item once
1170
1171 Only lecture the user the first time they run B<sudo>.
1172
1173 =back
1174
1175 If no value is specified, a value of I<once> is implied.
1176 Negating the option results in a value of I<never> being used.
1177 The default value is I<@lecture@>.
1178
1179 =item lecture_file
1180
1181 Path to a file containing an alternate B<sudo> lecture that will
1182 be used in place of the standard lecture if the named file exists.
1183 By default, B<sudo> uses a built-in lecture.
1184
1185 =item listpw
1186
1187 This option controls when a password will be required when a
1188 user runs B<sudo> with the B<-l> option.  It has the following possible values:
1189
1190 =over 8
1191
1192 =item all
1193
1194 All the user's I<sudoers> entries for the current host must have
1195 the C<NOPASSWD> flag set to avoid entering a password.
1196
1197 =item always
1198
1199 The user must always enter a password to use the B<-l> option.
1200
1201 =item any
1202
1203 At least one of the user's I<sudoers> entries for the current host
1204 must have the C<NOPASSWD> flag set to avoid entering a password.
1205
1206 =item never
1207
1208 The user need never enter a password to use the B<-l> option.
1209
1210 =back
1211
1212 If no value is specified, a value of I<any> is implied.
1213 Negating the option results in a value of I<never> being used.
1214 The default value is I<any>.
1215
1216 =item logfile
1217
1218 Path to the B<sudo> log file (not the syslog log file).  Setting a path
1219 turns on logging to a file; negating this option turns it off.
1220 By default, B<sudo> logs via syslog.
1221
1222 =item mailerflags
1223
1224 Flags to use when invoking mailer. Defaults to B<-t>.
1225
1226 =item mailerpath
1227
1228 Path to mail program used to send warning mail.
1229 Defaults to the path to sendmail found at configure time.
1230
1231 =item mailfrom
1232
1233 Address to use for the "from" address when sending warning and error
1234 mail.  The address should be enclosed in double quotes (C<">) to
1235 protect against B<sudo> interpreting the C<@> sign.  Defaults to
1236 the name of the user running B<sudo>.
1237
1238 =item mailto
1239
1240 Address to send warning and error mail to.  The address should
1241 be enclosed in double quotes (C<">) to protect against B<sudo>
1242 interpreting the C<@> sign.  Defaults to C<@mailto@>.
1243
1244 =item secure_path
1245
1246 Path used for every command run from B<sudo>.  If you don't trust the
1247 people running B<sudo> to have a sane C<PATH> environment variable you may
1248 want to use this.  Another use is if you want to have the "root path"
1249 be separate from the "user path."  Users in the group specified by the
1250 I<exempt_group> option are not affected by I<secure_path>.
1251 This option is @secure_path@ by default.
1252
1253 =item syslog
1254
1255 Syslog facility if syslog is being used for logging (negate to
1256 disable syslog logging).  Defaults to C<@logfac@>.
1257
1258 =item verifypw
1259
1260 This option controls when a password will be required when a user runs
1261 B<sudo> with the B<-v> option.  It has the following possible values:
1262
1263 =over 8
1264
1265 =item all
1266
1267 All the user's I<sudoers> entries for the current host must have
1268 the C<NOPASSWD> flag set to avoid entering a password.
1269
1270 =item always
1271
1272 The user must always enter a password to use the B<-v> option.
1273
1274 =item any
1275
1276 At least one of the user's I<sudoers> entries for the current host
1277 must have the C<NOPASSWD> flag set to avoid entering a password.
1278
1279 =item never
1280
1281 The user need never enter a password to use the B<-v> option.
1282
1283 =back
1284
1285 If no value is specified, a value of I<all> is implied.
1286 Negating the option results in a value of I<never> being used.
1287 The default value is I<all>.
1288
1289 =back
1290
1291 B<Lists that can be used in a boolean context>:
1292
1293 =over 16
1294
1295 =item env_check
1296
1297 Environment variables to be removed from the user's environment if
1298 the variable's value contains C<%> or C</> characters.  This can
1299 be used to guard against printf-style format vulnerabilities in
1300 poorly-written programs.  The argument may be a double-quoted,
1301 space-separated list or a single value without double-quotes.  The
1302 list can be replaced, added to, deleted from, or disabled by using
1303 the C<=>, C<+=>, C<-=>, and C<!> operators respectively.  Regardless
1304 of whether the C<env_reset> option is enabled or disabled, variables
1305 specified by C<env_check> will be preserved in the environment if
1306 they pass the aforementioned check.  The default list of environment
1307 variables to check is displayed when B<sudo> is run by root with
1308 the I<-V> option.
1309
1310 =item env_delete
1311
1312 Environment variables to be removed from the user's environment
1313 when the I<env_reset> option is not in effect.  The argument may
1314 be a double-quoted, space-separated list or a single value without
1315 double-quotes.  The list can be replaced, added to, deleted from,
1316 or disabled by using the C<=>, C<+=>, C<-=>, and C<!> operators
1317 respectively.  The default list of environment variables to remove
1318 is displayed when B<sudo> is run by root with the I<-V> option.
1319 Note that many operating systems will remove potentially dangerous
1320 variables from the environment of any setuid process (such as
1321 B<sudo>).
1322
1323 =item env_keep
1324
1325 Environment variables to be preserved in the user's environment
1326 when the I<env_reset> option is in effect.  This allows fine-grained
1327 control over the environment B<sudo>-spawned processes will receive.
1328 The argument may be a double-quoted, space-separated list or a
1329 single value without double-quotes.  The list can be replaced, added
1330 to, deleted from, or disabled by using the C<=>, C<+=>, C<-=>, and
1331 C<!> operators respectively.  The default list of variables to keep
1332 is displayed when B<sudo> is run by root with the I<-V> option.
1333
1334 =back
1335
1336 When logging via L<syslog(3)>, B<sudo> accepts the following values
1337 for the syslog facility (the value of the B<syslog> Parameter):
1338 B<authpriv> (if your OS supports it), B<auth>, B<daemon>, B<user>,
1339 B<local0>, B<local1>, B<local2>, B<local3>, B<local4>, B<local5>,
1340 B<local6>, and B<local7>.  The following syslog priorities are
1341 supported: B<alert>, B<crit>, B<debug>, B<emerg>, B<err>, B<info>,
1342 B<notice>, and B<warning>.
1343
1344 =head1 FILES
1345
1346 =over 24
1347
1348 =item F<@sysconfdir@/sudoers>
1349
1350 List of who can run what
1351
1352 =item F</etc/group>
1353
1354 Local groups file
1355
1356 =item F</etc/netgroup>
1357
1358 List of network groups
1359
1360 =item F</var/log/sudo-io>
1361
1362 I/O log files
1363
1364 =back
1365
1366 =head1 EXAMPLES
1367
1368 Below are example I<sudoers> entries.  Admittedly, some of
1369 these are a bit contrived.  First, we allow a few environment
1370 variables to pass and then define our I<aliases>:
1371
1372  # Run X applications through sudo; HOME is used to find the
1373  # .Xauthority file.  Note that other programs use HOME to find
1374  # configuration files and this may lead to privilege escalation!
1375  Defaults env_keep += "DISPLAY HOME"
1376
1377  # User alias specification
1378  User_Alias     FULLTIMERS = millert, mikef, dowdy
1379  User_Alias     PARTTIMERS = bostley, jwfox, crawl
1380  User_Alias     WEBMASTERS = will, wendy, wim
1381
1382  # Runas alias specification
1383  Runas_Alias    OP = root, operator
1384  Runas_Alias    DB = oracle, sybase
1385  Runas_Alias    ADMINGRP = adm, oper
1386
1387  # Host alias specification
1388  Host_Alias     SPARC = bigtime, eclipse, moet, anchor :\
1389                 SGI = grolsch, dandelion, black :\
1390                 ALPHA = widget, thalamus, foobar :\
1391                 HPPA = boa, nag, python
1392  Host_Alias     CUNETS = 128.138.0.0/255.255.0.0
1393  Host_Alias     CSNETS = 128.138.243.0, 128.138.204.0/24, 128.138.242.0
1394  Host_Alias     SERVERS = master, mail, www, ns
1395  Host_Alias     CDROM = orion, perseus, hercules
1396
1397  # Cmnd alias specification
1398  Cmnd_Alias     DUMPS = /usr/bin/mt, /usr/sbin/dump, /usr/sbin/rdump,\
1399                         /usr/sbin/restore, /usr/sbin/rrestore
1400  Cmnd_Alias     KILL = /usr/bin/kill
1401  Cmnd_Alias     PRINTING = /usr/sbin/lpc, /usr/bin/lprm
1402  Cmnd_Alias     SHUTDOWN = /usr/sbin/shutdown
1403  Cmnd_Alias     HALT = /usr/sbin/halt
1404  Cmnd_Alias     REBOOT = /usr/sbin/reboot
1405  Cmnd_Alias     SHELLS = /usr/bin/sh, /usr/bin/csh, /usr/bin/ksh, \
1406                          /usr/local/bin/tcsh, /usr/bin/rsh, \
1407                          /usr/local/bin/zsh
1408  Cmnd_Alias     SU = /usr/bin/su
1409  Cmnd_Alias     PAGERS = /usr/bin/more, /usr/bin/pg, /usr/bin/less
1410
1411 Here we override some of the compiled in default values.  We want
1412 B<sudo> to log via L<syslog(3)> using the I<auth> facility in all
1413 cases.  We don't want to subject the full time staff to the B<sudo>
1414 lecture, user B<millert> need not give a password, and we don't
1415 want to reset the C<LOGNAME>, C<USER> or C<USERNAME> environment
1416 variables when running commands as root.  Additionally, on the
1417 machines in the I<SERVERS> C<Host_Alias>, we keep an additional
1418 local log file and make sure we log the year in each log line since
1419 the log entries will be kept around for several years.  Lastly, we
1420 disable shell escapes for the commands in the PAGERS C<Cmnd_Alias>
1421 (F</usr/bin/more>, F</usr/bin/pg> and F</usr/bin/less>).
1422
1423  # Override built-in defaults
1424  Defaults               syslog=auth
1425  Defaults>root          !set_logname
1426  Defaults:FULLTIMERS    !lecture
1427  Defaults:millert       !authenticate
1428  Defaults@SERVERS       log_year, logfile=/var/log/sudo.log
1429  Defaults!PAGERS        noexec
1430
1431 The I<User specification> is the part that actually determines who may
1432 run what.
1433
1434  root           ALL = (ALL) ALL
1435  %wheel         ALL = (ALL) ALL
1436
1437 We let B<root> and any user in group B<wheel> run any command on any
1438 host as any user.
1439
1440  FULLTIMERS     ALL = NOPASSWD: ALL
1441
1442 Full time sysadmins (B<millert>, B<mikef>, and B<dowdy>) may run any
1443 command on any host without authenticating themselves.
1444
1445  PARTTIMERS     ALL = ALL
1446
1447 Part time sysadmins (B<bostley>, B<jwfox>, and B<crawl>) may run any
1448 command on any host but they must authenticate themselves first
1449 (since the entry lacks the C<NOPASSWD> tag).
1450
1451  jack           CSNETS = ALL
1452
1453 The user B<jack> may run any command on the machines in the I<CSNETS> alias
1454 (the networks C<128.138.243.0>, C<128.138.204.0>, and C<128.138.242.0>).
1455 Of those networks, only C<128.138.204.0> has an explicit netmask (in
1456 CIDR notation) indicating it is a class C network.  For the other
1457 networks in I<CSNETS>, the local machine's netmask will be used
1458 during matching.
1459
1460  lisa           CUNETS = ALL
1461
1462 The user B<lisa> may run any command on any host in the I<CUNETS> alias
1463 (the class B network C<128.138.0.0>).
1464
1465  operator       ALL = DUMPS, KILL, SHUTDOWN, HALT, REBOOT, PRINTING,\
1466                 sudoedit /etc/printcap, /usr/oper/bin/
1467
1468 The B<operator> user may run commands limited to simple maintenance.
1469 Here, those are commands related to backups, killing processes, the
1470 printing system, shutting down the system, and any commands in the
1471 directory F</usr/oper/bin/>.
1472
1473  joe            ALL = /usr/bin/su operator
1474
1475 The user B<joe> may only L<su(1)> to operator.
1476
1477  pete           HPPA = /usr/bin/passwd [A-Za-z]*, !/usr/bin/passwd root
1478
1479  %opers         ALL = (: ADMINGRP) /usr/sbin/
1480
1481 Users in the B<opers> group may run commands in F</usr/sbin/> as themselves
1482 with any group in the I<ADMINGRP> C<Runas_Alias> (the B<adm> and B<oper>
1483 groups).
1484
1485 The user B<pete> is allowed to change anyone's password except for
1486 root on the I<HPPA> machines.  Note that this assumes L<passwd(1)>
1487 does not take multiple user names on the command line.
1488
1489  bob            SPARC = (OP) ALL : SGI = (OP) ALL
1490
1491 The user B<bob> may run anything on the I<SPARC> and I<SGI> machines
1492 as any user listed in the I<OP> C<Runas_Alias> (B<root> and B<operator>).
1493
1494  jim            +biglab = ALL
1495
1496 The user B<jim> may run any command on machines in the I<biglab> netgroup.
1497 B<sudo> knows that "biglab" is a netgroup due to the '+' prefix.
1498
1499  +secretaries   ALL = PRINTING, /usr/bin/adduser, /usr/bin/rmuser
1500
1501 Users in the B<secretaries> netgroup need to help manage the printers
1502 as well as add and remove users, so they are allowed to run those
1503 commands on all machines.
1504
1505  fred           ALL = (DB) NOPASSWD: ALL
1506
1507 The user B<fred> can run commands as any user in the I<DB> C<Runas_Alias>
1508 (B<oracle> or B<sybase>) without giving a password.
1509
1510  john           ALPHA = /usr/bin/su [!-]*, !/usr/bin/su *root*
1511
1512 On the I<ALPHA> machines, user B<john> may su to anyone except root
1513 but he is not allowed to specify any options to the L<su(1)> command.
1514
1515  jen            ALL, !SERVERS = ALL
1516
1517 The user B<jen> may run any command on any machine except for those
1518 in the I<SERVERS> C<Host_Alias> (master, mail, www and ns).
1519
1520  jill           SERVERS = /usr/bin/, !SU, !SHELLS
1521
1522 For any machine in the I<SERVERS> C<Host_Alias>, B<jill> may run
1523 any commands in the directory F</usr/bin/> except for those commands
1524 belonging to the I<SU> and I<SHELLS> C<Cmnd_Aliases>.
1525
1526  steve          CSNETS = (operator) /usr/local/op_commands/
1527
1528 The user B<steve> may run any command in the directory /usr/local/op_commands/
1529 but only as user operator.
1530
1531  matt           valkyrie = KILL
1532
1533 On his personal workstation, valkyrie, B<matt> needs to be able to
1534 kill hung processes.
1535
1536  WEBMASTERS     www = (www) ALL, (root) /usr/bin/su www
1537
1538 On the host www, any user in the I<WEBMASTERS> C<User_Alias> (will,
1539 wendy, and wim), may run any command as user www (which owns the
1540 web pages) or simply L<su(1)> to www.
1541
1542  ALL            CDROM = NOPASSWD: /sbin/umount /CDROM,\
1543                 /sbin/mount -o nosuid\,nodev /dev/cd0a /CDROM
1544
1545 Any user may mount or unmount a CD-ROM on the machines in the CDROM
1546 C<Host_Alias> (orion, perseus, hercules) without entering a password.
1547 This is a bit tedious for users to type, so it is a prime candidate
1548 for encapsulating in a shell script.
1549
1550 =head1 SECURITY NOTES
1551
1552 It is generally not effective to "subtract" commands from C<ALL>
1553 using the '!' operator.  A user can trivially circumvent this
1554 by copying the desired command to a different name and then
1555 executing that.  For example:
1556
1557     bill        ALL = ALL, !SU, !SHELLS
1558
1559 Doesn't really prevent B<bill> from running the commands listed in
1560 I<SU> or I<SHELLS> since he can simply copy those commands to a
1561 different name, or use a shell escape from an editor or other
1562 program.  Therefore, these kind of restrictions should be considered
1563 advisory at best (and reinforced by policy).
1564
1565 Furthermore, if the I<fast_glob> option is in use, it is not possible
1566 to reliably negate commands where the path name includes globbing
1567 (aka wildcard) characters.  This is because the C library's
1568 L<fnmatch(3)> function cannot resolve relative paths.  While this
1569 is typically only an inconvenience for rules that grant privileges,
1570 it can result in a security issue for rules that subtract or revoke
1571 privileges.
1572
1573 For example, given the following I<sudoers> entry:
1574
1575  john   ALL = /usr/bin/passwd [a-zA-Z0-9]*, /usr/bin/chsh [a-zA-Z0-9]*,
1576       /usr/bin/chfn [a-zA-Z0-9]*, !/usr/bin/* root
1577
1578 User B<john> can still run C</usr/bin/passwd root> if I<fast_glob> is
1579 enabled by changing to F</usr/bin> and running C<./passwd root> instead.
1580
1581 =head1 PREVENTING SHELL ESCAPES
1582
1583 Once B<sudo> executes a program, that program is free to do whatever
1584 it pleases, including run other programs.  This can be a security
1585 issue since it is not uncommon for a program to allow shell escapes,
1586 which lets a user bypass B<sudo>'s access control and logging.
1587 Common programs that permit shell escapes include shells (obviously),
1588 editors, paginators, mail and terminal programs.
1589
1590 There are two basic approaches to this problem:
1591
1592 =over 10
1593
1594 =item restrict
1595
1596 Avoid giving users access to commands that allow the user to run
1597 arbitrary commands.  Many editors have a restricted mode where shell
1598 escapes are disabled, though B<sudoedit> is a better solution to
1599 running editors via B<sudo>.  Due to the large number of programs that
1600 offer shell escapes, restricting users to the set of programs that
1601 do not is often unworkable.
1602
1603 =item noexec
1604
1605 Many systems that support shared libraries have the ability to
1606 override default library functions by pointing an environment
1607 variable (usually C<LD_PRELOAD>) to an alternate shared library.
1608 On such systems, B<sudo>'s I<noexec> functionality can be used to
1609 prevent a program run by B<sudo> from executing any other programs.
1610 Note, however, that this applies only to native dynamically-linked
1611 executables.  Statically-linked executables and foreign executables
1612 running under binary emulation are not affected.
1613
1614 To tell whether or not B<sudo> supports I<noexec>, you can run
1615 the following as root:
1616
1617     sudo -V | grep "dummy exec"
1618
1619 If the resulting output contains a line that begins with:
1620
1621     File containing dummy exec functions:
1622
1623 then B<sudo> may be able to replace the exec family of functions
1624 in the standard library with its own that simply return an error.
1625 Unfortunately, there is no foolproof way to know whether or not
1626 I<noexec> will work at compile-time.  I<noexec> should work on
1627 SunOS, Solaris, *BSD, Linux, IRIX, Tru64 UNIX, MacOS X, and HP-UX
1628 11.x.  It is known B<not> to work on AIX and UnixWare.  I<noexec>
1629 is expected to work on most operating systems that support the
1630 C<LD_PRELOAD> environment variable.  Check your operating system's
1631 manual pages for the dynamic linker (usually ld.so, ld.so.1, dyld,
1632 dld.sl, rld, or loader) to see if C<LD_PRELOAD> is supported.
1633
1634 To enable I<noexec> for a command, use the C<NOEXEC> tag as documented
1635 in the User Specification section above.  Here is that example again:
1636
1637  aaron  shanty = NOEXEC: /usr/bin/more, /usr/bin/vi
1638
1639 This allows user B<aaron> to run F</usr/bin/more> and F</usr/bin/vi>
1640 with I<noexec> enabled.  This will prevent those two commands from
1641 executing other commands (such as a shell).  If you are unsure
1642 whether or not your system is capable of supporting I<noexec> you
1643 can always just try it out and see if it works.
1644
1645 =back
1646
1647 Note that restricting shell escapes is not a panacea.  Programs
1648 running as root are still capable of many potentially hazardous
1649 operations (such as changing or overwriting files) that could lead
1650 to unintended privilege escalation.  In the specific case of an
1651 editor, a safer approach is to give the user permission to run
1652 B<sudoedit>.
1653
1654 =head1 SEE ALSO
1655
1656 L<rsh(1)>, L<su(1)>, L<fnmatch(3)>, L<glob(3)>, L<sudo(8)>, L<visudo(8)>
1657
1658 =head1 CAVEATS
1659
1660 The I<sudoers> file should B<always> be edited by the B<visudo>
1661 command which locks the file and does grammatical checking. It is
1662 imperative that I<sudoers> be free of syntax errors since B<sudo>
1663 will not run with a syntactically incorrect I<sudoers> file.
1664
1665 When using netgroups of machines (as opposed to users), if you
1666 store fully qualified host name in the netgroup (as is usually the
1667 case), you either need to have the machine's host name be fully qualified
1668 as returned by the C<hostname> command or use the I<fqdn> option in
1669 I<sudoers>.
1670
1671 =head1 BUGS
1672
1673 If you feel you have found a bug in B<sudo>, please submit a bug report
1674 at http://www.sudo.ws/sudo/bugs/
1675
1676 =head1 SUPPORT
1677
1678 Limited free support is available via the sudo-users mailing list,
1679 see http://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or
1680 search the archives.
1681
1682 =head1 DISCLAIMER
1683
1684 B<sudo> is provided ``AS IS'' and any express or implied warranties,
1685 including, but not limited to, the implied warranties of merchantability
1686 and fitness for a particular purpose are disclaimed.  See the LICENSE
1687 file distributed with B<sudo> or http://www.sudo.ws/sudo/license.html
1688 for complete details.