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