Imported Debian patch 1.6.6-1.6
[debian/sudo] / sudoers.pod
1 =cut
2 Copyright (c) 1994-1996,1998-2001 Todd C. Miller <Todd.Miller@courtesan.com>
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8
9 1. Redistributions of source code must retain the above copyright
10    notice, this list of conditions and the following disclaimer.
11
12 2. Redistributions in binary form must reproduce the above copyright
13    notice, this list of conditions and the following disclaimer in the
14    documentation and/or other materials provided with the distribution.
15
16 3. The name of the author may not be used to endorse or promote products
17    derived from this software without specific prior written permission
18    from the author.
19
20 4. Products derived from this software may not be called "Sudo" nor
21    may "Sudo" appear in their names without specific prior written
22    permission from the author.
23
24 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
26 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
27 THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
30 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35 $Sudo: sudoers.pod,v 1.63 2002/01/13 18:36:44 millert Exp $
36 =pod
37
38 =head1 NAME
39
40 sudoers - list of which users may execute what
41
42 =head1 DESCRIPTION
43
44 The I<sudoers> file is composed of two types of entries:
45 aliases (basically variables) and user specifications
46 (which specify who may run what).  The grammar of I<sudoers>
47 will be described below in Extended Backus-Naur Form (EBNF).
48 Don't despair if you don't know what EBNF is; it is fairly
49 simple, and the definitions below are annotated.
50
51 =head2 Quick guide to EBNF
52
53 EBNF is a concise and exact way of describing the grammar of a language.
54 Each EBNF definition is made up of I<production rules>.  E.g.,
55
56  symbol ::= definition | alternate1 | alternate2 ...
57
58 Each I<production rule> references others and thus makes up a
59 grammar for the language.  EBNF also contains the following
60 operators, which many readers will recognize from regular
61 expressions.  Do not, however, confuse them with "wildcard"
62 characters, which have different meanings.
63
64 =over 8
65
66 =item C<?>
67
68 Means that the preceding symbol (or group of symbols) is optional.
69 That is, it may appear once or not at all.
70
71 =item C<*>
72
73 Means that the preceding symbol (or group of symbols) may appear
74 zero or more times.
75
76 =item C<+>
77
78 Means that the preceding symbol (or group of symbols) may appear
79 one or more times.
80
81 =back
82
83 Parentheses may be used to group symbols together.  For clarity,
84 we will use single quotes ('') to designate what is a verbatim character
85 string (as opposed to a symbol name).
86
87 =head2 Aliases
88
89 There are four kinds of aliases: C<User_Alias>, C<Runas_Alias>,
90 C<Host_Alias> and C<Cmnd_Alias>.
91
92  Alias ::= 'User_Alias'  User_Alias (':' User_Alias)* |
93            'Runas_Alias' Runas_Alias (':' Runas_Alias)* |
94            'Host_Alias'  Host_Alias (':' Host_Alias)* |
95            'Cmnd_Alias'  Cmnd_Alias (':' Cmnd_Alias)*
96
97  User_Alias ::= NAME '=' User_List
98
99  Runas_Alias ::= NAME '=' Runas_List
100
101  Host_Alias ::= NAME '=' Host_List
102
103  Cmnd_Alias ::= NAME '=' Cmnd_List
104
105  NAME ::= [A-Z]([A-Z][0-9]_)*
106
107 Each I<alias> definition is of the form
108
109  Alias_Type NAME = item1, item2, ...
110
111 where I<Alias_Type> is one of C<User_Alias>, C<Runas_Alias>, C<Host_Alias>,
112 or C<Cmnd_Alias>.  A C<NAME> is a string of uppercase letters, numbers,
113 and the underscore characters ('_').  A C<NAME> B<must> start with an
114 uppercase letter.  It is possible to put several alias definitions
115 of the same type on a single line, joined by a colon (':').  E.g.,
116
117  Alias_Type NAME = item1, item2, item3 : NAME = item4, item5
118
119 The definitions of what constitutes a valid I<alias> member follow.
120
121  User_List ::= User |
122                User ',' User_List
123
124  User ::= '!'* username |
125           '!'* '%'group |
126           '!'* '+'netgroup |
127           '!'* User_Alias
128
129 A C<User_List> is made up of one or more usernames, uids
130 (prefixed with '#'), System groups (prefixed with '%'),
131 netgroups (prefixed with '+') and other aliases.  Each list
132 item may be prefixed with one or more '!' operators.  An odd number
133 of '!' operators negate the value of the item; an even number
134 just cancel each other out.
135
136  Runas_List ::= Runas_User |
137                 Runas_User ',' Runas_List
138
139  Runas_User ::= '!'* username |
140                 '!'* '#'uid |
141                 '!'* '%'group |
142                 '!'* +netgroup |
143                 '!'* Runas_Alias
144
145 A C<Runas_List> is similar to a C<User_List> except that it can
146 also contain uids (prefixed with '#') and instead of C<User_Alias>es
147 it can contain C<Runas_Alias>es.
148
149  Host_List ::= Host |
150                Host ',' Host_List
151
152  Host ::= '!'* hostname |
153           '!'* ip_addr |
154           '!'* network(/netmask)? |
155           '!'* '+'netgroup |
156           '!'* Host_Alias
157
158 A C<Host_List> is made up of one or more hostnames, IP addresses,
159 network numbers, netgroups (prefixed with '+') and other aliases.
160 Again, the value of an item may be negated with the '!' operator.
161 If you do not specify a netmask with a network number, the netmask
162 of the host's ethernet interface(s) will be used when matching.
163 The netmask may be specified either in dotted quad notation (e.g.
164 255.255.255.0) or CIDR notation (number of bits, e.g. 24).  A hostname
165 may include shell-style wildcards (see `Wildcards' section below),
166 but unless the C<hostname> command on your machine returns the fully
167 qualified hostname, you'll need to use the I<fqdn> option for wildcards
168 to be useful.
169
170  Cmnd_List ::= Cmnd |
171                Cmnd ',' Cmnd_List
172
173  commandname ::= filename |
174                  filename args |
175                  filename '""'
176
177  Cmnd ::= '!'* commandname |
178           '!'* directory |
179           '!'* Cmnd_Alias
180
181 A C<Cmnd_List> is a list of one or more commandnames, directories, and other
182 aliases.  A commandname is a fully qualified filename which may include
183 shell-style wildcards (see `Wildcards' section below).  A simple
184 filename allows the user to run the command with any arguments he/she
185 wishes.  However, you may also specify command line arguments (including
186 wildcards).  Alternately, you can specify C<""> to indicate that the command
187 may only be run B<without> command line arguments.  A directory is a
188 fully qualified pathname ending in a '/'.  When you specify a directory
189 in a C<Cmnd_List>, the user will be able to run any file within that directory
190 (but not in any subdirectories therein).
191
192 If a C<Cmnd> has associated command line arguments, then the arguments
193 in the C<Cmnd> must match exactly those given by the user on the command line
194 (or match the wildcards if there are any).  Note that the following
195 characters must be escaped with a '\' if they are used in command
196 arguments: ',', ':', '=', '\'.
197
198 =head2 Defaults
199
200 Certain configuration options may be changed from their default
201 values at runtime via one or more C<Default_Entry> lines.  These
202 may affect all users on any host, all users on a specific host,
203 or just a specific user.  When multiple entries match, they are
204 applied in order.  Where there are conflicting values, the last
205 value on a matching line takes effect.
206
207  Default_Type ::= 'Defaults' ||
208                   'Defaults' ':' User ||
209                   'Defaults' '@' Host
210
211  Default_Entry ::= Default_Type Parameter_List
212
213  Parameter ::= Parameter '=' Value ||
214                Parameter '+=' Value ||
215                Parameter '-=' Value ||
216                '!'* Parameter ||
217
218 Parameters may be B<flags>, B<integer> values, B<strings>, or B<lists>.
219 Flags are implicitly boolean and can be turned off via the '!'
220 operator.  Some integer, string and list parameters may also be
221 used in a boolean context to disable them.  Values may be enclosed
222 in double quotes (C<">) when they contain multiple words.  Special
223 characters may be escaped with a backslash (C<\>).
224
225 Lists have two additional assignment operators, C<+=> and C<-=>.
226 These operators are used to add to and delete from a list respectively.
227 It is not an error to use the C<-=> operator to remove an element
228 that does not exist in a list.
229
230 Note that since the I<sudoers> file is parsed in order the best place
231 to put the Defaults section is after the Host, User, and Cmnd aliases
232 but before the user specifications.
233
234 B<Flags>:
235
236 =over 12
237
238 =item long_otp_prompt
239
240 When validating with a One Time Password scheme (B<S/Key> or B<OPIE>),
241 a two-line prompt is used to make it easier to cut and paste the
242 challenge to a local window.  It's not as pretty as the default but
243 some people find it more convenient.  This flag is I<@long_otp_prompt@>
244 by default.
245
246 =item ignore_dot
247
248 If set, B<sudo> will ignore '.' or '' (current dir) in the C<PATH>
249 environment variable; the C<PATH> itself is not modified.  This
250 flag is I<@ignore_dot@> by default.
251
252 =item mail_always
253
254 Send mail to the I<mailto> user every time a users runs B<sudo>.
255 This flag is I<off> by default.
256
257 =item mail_badpass
258
259 Send mail to the I<mailto> user if the user running sudo does not
260 enter the correct password.  This flag is I<off> by default.
261
262 =item mail_no_user
263
264 If set, mail will be sent to the I<mailto> user if the invoking
265 user is not in the I<sudoers> file.  This flag is I<@mail_no_user@>
266 by default.
267
268 =item mail_no_host
269
270 If set, mail will be sent to the I<mailto> user if the invoking
271 user exists in the I<sudoers> file, but is not allowed to run
272 commands on the current host.  This flag is I<@mail_no_host@> by default.
273
274 =item mail_no_perms
275
276 If set, mail will be sent to the I<mailto> user if the invoking
277 user allowed to use B<sudo> but the command they are trying is not
278 listed in their I<sudoers> file entry.  This flag is I<@mail_no_perms@>
279 by default.
280
281 =item tty_tickets
282
283 If set, users must authenticate on a per-tty basis.  Normally,
284 B<sudo> uses a directory in the ticket dir with the same name as
285 the user running it.  With this flag enabled, B<sudo> will use a
286 file named for the tty the user is logged in on in that directory.
287 This flag is I<@tty_tickets@> by default.
288
289 =item lecture
290
291 If set, a user will receive a short lecture the first time he/she
292 runs B<sudo>.  This flag is I<@lecture@> by default.
293
294 =item authenticate
295
296 If set, users must authenticate themselves via a password (or other
297 means of authentication) before they may run commands.  This default
298 may be overridden via the C<PASSWD> and C<NOPASSWD> tags.
299 This flag is I<on> by default.
300
301 =item root_sudo
302
303 If set, root is allowed to run B<sudo> too.  Disabling this prevents users
304 from "chaining" B<sudo> commands to get a root shell by doing something
305 like C<"sudo sudo /bin/sh">.
306 This flag is I<on> by default.
307
308 =item log_host
309
310 If set, the hostname will be logged in the (non-syslog) B<sudo> log file.
311 This flag is I<off> by default.
312
313 =item log_year
314
315 If set, the four-digit year will be logged in the (non-syslog) B<sudo> log file.
316 This flag is I<off> by default.
317
318 =item shell_noargs
319
320 If set and B<sudo> is invoked with no arguments it acts as if the
321 B<-s> flag had been given.  That is, it runs a shell as root (the
322 shell is determined by the C<SHELL> environment variable if it is
323 set, falling back on the shell listed in the invoking user's
324 /etc/passwd entry if not).  This flag is I<off> by default.
325
326 =item set_home
327
328 If set and B<sudo> is invoked with the B<-s> flag the C<HOME>
329 environment variable will be set to the home directory of the target
330 user (which is root unless the B<-u> option is used).  This effectively
331 makes the B<-s> flag imply B<-H>.  This flag is I<off> by default.
332
333 =item always_set_home
334
335 If set, B<sudo> will set the C<HOME> environment variable to the home
336 directory of the target user (which is root unless the B<-u> option is used).
337 This effectively means that the B<-H> flag is always implied.
338 This flag is I<off> by default.
339
340 =item path_info
341
342 Normally, B<sudo> will tell the user when a command could not be
343 found in their C<PATH> environment variable.  Some sites may wish
344 to disable this as it could be used to gather information on the
345 location of executables that the normal user does not have access
346 to.  The disadvantage is that if the executable is simply not in
347 the user's C<PATH>, B<sudo> will tell the user that they are not
348 allowed to run it, which can be confusing.  This flag is I<off> by
349 default.
350
351 =item preserve_groups
352
353 By default B<sudo> will initialize the group vector to the list of
354 groups the target user is in.  When I<preserve_groups> is set, the
355 user's existing group vector is left unaltered.  The real and
356 effective group IDs, however, are still set to match the target
357 user.  This flag is I<off> by default.
358
359 =item fqdn
360
361 Set this flag if you want to put fully qualified hostnames in the
362 I<sudoers> file.  I.e.: instead of myhost you would use myhost.mydomain.edu.
363 You may still use the short form if you wish (and even mix the two).
364 Beware that turning on I<fqdn> requires B<sudo> to make DNS lookups
365 which may make B<sudo> unusable if DNS stops working (for example
366 if the machine is not plugged into the network).  Also note that
367 you must use the host's official name as DNS knows it.  That is,
368 you may not use a host alias (C<CNAME> entry) due to performance
369 issues and the fact that there is no way to get all aliases from
370 DNS.  If your machine's hostname (as returned by the C<hostname>
371 command) is already fully qualified you shouldn't need to set
372 I<fqdn>.  This flag is I<@fqdn@> by default.
373
374 =item insults
375
376 If set, B<sudo> will insult users when they enter an incorrect
377 password.  This flag is I<@insults@> by default.
378
379 =item requiretty
380
381 If set, B<sudo> will only run when the user is logged in to a real
382 tty.  This will disallow things like C<"rsh somehost sudo ls"> since
383 rsh(1) does not allocate a tty.  Because it is not possible to turn
384 of echo when there is no tty present, some sites may with to set
385 this flag to prevent a user from entering a visible password.  This
386 flag is I<off> by default.
387
388 =item env_editor
389
390 If set, B<visudo> will use the value of the EDITOR or VISUAL
391 environment variables before falling back on the default editor list.
392 Note that this may create a security hole as it allows the user to
393 run any arbitrary command as root without logging.  A safer alternative
394 is to place a colon-separated list of editors in the C<editor>
395 variable.  B<visudo> will then only use the EDITOR or VISUAL if
396 they match a value specified in C<editor>.  This flag is C<@env_editor@> by
397 default.
398
399 =item rootpw
400
401 If set, B<sudo> will prompt for the root password instead of the password
402 of the invoking user.  This flag is I<off> by default.
403
404 =item runaspw
405
406 If set, B<sudo> will prompt for the password of the user defined by the
407 I<runas_default> option (defaults to C<root>) instead of the password
408 of the invoking user.  This flag is I<off> by default.
409
410 =item targetpw
411
412 If set, B<sudo> will prompt for the password of the user specified by
413 the B<-u> flag (defaults to C<root>) instead of the password of the
414 invoking user.  This flag is I<off> by default.
415
416 =item set_logname
417
418 Normally, B<sudo> will set the C<LOGNAME> and C<USER> environment variables
419 to the name of the target user (usually root unless the B<-u> flag is given).
420 However, since some programs (including the RCS revision control system)
421 use C<LOGNAME> to determine the real identity of the user, it may be desirable
422 to change this behavior.  This can be done by negating the set_logname option.
423
424 =item stay_setuid
425
426 Normally, when B<sudo> executes a command the real and effective
427 UIDs are set to the target user (root by default).  This option
428 changes that behavior such that the real UID is left as the invoking
429 user's UID.  In other words, this makes B<sudo> act as a setuid
430 wrapper.  This can be useful on systems that disable some potentially
431 dangerous functionality when a program is run setuid.  Note, however,
432 that this means that sudo will run with the real uid of the invoking
433 user which may allow that user to kill B<sudo> before it can log a
434 failure, depending on how your OS defines the interaction between
435 signals and setuid processes.
436
437 =item env_reset
438
439 If set, B<sudo> will reset the environment to only contain the
440 following variables: C<HOME>, C<LOGNAME>, C<PATH>, C<SHELL>, C<TERM>,
441 C<DISPLAY>, C<XAUTHORITY>, C<XAUTHORIZATION>,
442 C<LANG>, C<LANGUAGE>, C<LC_*>,
443 and C<USER> (in addition to the C<SUDO_*> variables).
444
445 Of these, only C<TERM>, C<DISPLAY>, C<XAUTHORITY>, C<XAUTHORIZATION>,
446 C<LANG>, C<LANGUAGE>, and C<LC_*> are copied unaltered from the old environment.
447 The other variables are set to default values (possibly modified
448 by the value of the I<set_logname> option).  If B<sudo> was compiled
449 with the C<SECURE_PATH> option, its value will be used for the C<PATH>
450 environment variable.
451
452 This option is enabled by default.
453
454 Other variables may be preserved with the I<env_keep> option.
455
456 =item use_loginclass
457
458 If set, B<sudo> will apply the defaults specified for the target user's
459 login class if one exists.  Only available if B<sudo> is configured with
460 the --with-logincap option.  This flag is I<off> by default.
461
462 =back
463
464 B<Integers>:
465
466 =over 12
467
468 =item passwd_tries
469
470 The number of tries a user gets to enter his/her password before
471 B<sudo> logs the failure and exits.  The default is C<@passwd_tries@>.
472
473 =back
474
475 B<Integers that can be used in a boolean context>:
476
477 =over 12
478
479 =item loglinelen
480
481 Number of characters per line for the file log.  This value is used
482 to decide when to wrap lines for nicer log files.  This has no
483 effect on the syslog log file, only the file log.  The default is
484 C<@loglen@> (use 0 or negate the option to disable word wrap).
485
486 =item timestamp_timeout
487
488 Number of minutes that can elapse before B<sudo> will ask for a
489 passwd again.  The default is C<@timeout@>.  Set this to C<0> to always
490 prompt for a password.
491 If set to a value less than C<0> the user's timestamp will never
492 expire.  This can be used to allow users to create or delete their
493 own timestamps via C<sudo -v> and C<sudo -k> respectively.
494
495 =item passwd_timeout
496
497 Number of minutes before the B<sudo> password prompt times out.
498 The default is C<@password_timeout@>, set this to C<0> for no password timeout.
499
500 =item umask
501
502 Umask to use when running the command.  Negate this option or set
503 it to 0777 to preserve the user's umask.  The default is C<@sudo_umask@>.
504
505 =back
506
507 B<Strings>:
508
509 =over 12
510
511 =item mailsub
512
513 Subject of the mail sent to the I<mailto> user. The escape C<%h>
514 will expand to the hostname of the machine.
515 Default is C<@mailsub@>.
516
517 =item badpass_message
518
519 Message that is displayed if a user enters an incorrect password.
520 The default is C<@badpass_message@> unless insults are enabled.
521
522 =item timestampdir
523
524 The directory in which B<sudo> stores its timestamp files.
525 The default is F<@timedir@>.
526
527 =item passprompt
528
529 The default prompt to use when asking for a password; can be overridden
530 via the B<-p> option or the C<SUDO_PROMPT> environment variable. Supports
531 two escapes: "%u" expands to the user's login name and "%h" expands
532 to the local hostname.  The default value is C<@passprompt@>.
533
534 =item runas_default
535
536 The default user to run commands as if the B<-u> flag is not specified
537 on the command line.  This defaults to C<@runas_default@>.
538
539 =item syslog_goodpri
540
541 Syslog priority to use when user authenticates successfully.
542 Defaults to C<@goodpri@>.
543
544 =item syslog_badpri
545
546 Syslog priority to use when user authenticates unsuccessfully.
547 Defaults to C<@badpri@>.
548
549 =item editor
550
551 A colon (':') separated list of editors allowed to be used with
552 B<visudo>.  B<visudo> will choose the editor that matches the user's
553 USER environment variable if possible, or the first editor in the
554 list that exists and is executable.  The default is the path to vi
555 on your system.
556
557 =back
558
559 B<Strings that can be used in a boolean context>:
560
561 =over 12
562
563 =item logfile
564
565 Path to the B<sudo> log file (not the syslog log file).  Setting a path
566 turns on logging to a file; negating this option turns it off.
567
568 =item syslog
569
570 Syslog facility if syslog is being used for logging (negate to
571 disable syslog logging).  Defaults to C<@logfac@>.
572
573 =item mailerpath
574
575 Path to mail program used to send warning mail.
576 Defaults to the path to sendmail found at configure time.
577
578 =item mailerflags
579
580 Flags to use when invoking mailer. Defaults to B<-t>.
581
582 =item mailto
583
584 Address to send warning and error mail to.  The address should
585 be enclosed in double quotes (C<">) to protect against sudo
586 interpreting the C<@> sign.  Defaults to C<@mailto@>.
587
588 =item exempt_group
589
590 Users in this group are exempt from password and PATH requirements.  This
591 option is turned on for Debian.
592
593 =item verifypw
594
595 This option controls when a password will be required when a user runs
596 B<sudo> with the B<-v> flag.  It has the following possible values:
597
598 =over 8
599
600 =item all
601
602 All the user's I<sudoers> entries for the current host must have
603 the C<NOPASSWD> flag set to avoid entering a password.
604
605 =item any
606
607 At least one of the user's I<sudoers> entries for the current host
608 must have the C<NOPASSWD> flag set to avoid entering a password.
609
610 =item never
611
612 The user need never enter a password to use the B<-v> flag.
613
614 =item always
615
616 The user must always enter a password to use the B<-v> flag.
617
618 =back
619
620 The default value is `all'.
621
622 =item listpw
623
624 This option controls when a password will be required when a
625 user runs B<sudo> with the B<-l>.  It has the following possible values:
626
627 =over 8
628
629 =item all
630
631 All the user's I<sudoers> entries for the current host must have
632 the C<NOPASSWD> flag set to avoid entering a password.
633
634 =item any
635
636 At least one of the user's I<sudoers> entries for the current host
637 must have the C<NOPASSWD> flag set to avoid entering a password.
638
639 =item never
640
641 The user need never enter a password to use the B<-l> flag.
642
643 =item always
644
645 The user must always enter a password to use the B<-l> flag.
646
647 =back
648
649 The default value is `any'.
650
651 =back
652
653 B<Lists that can be used in a boolean context>:
654
655 =over 12
656
657 =item env_check
658
659 Environment variables to be removed from the user's environment if
660 the variable's value contains C<%> or C</> characters.  This can
661 be used to guard against printf-style format vulnerabilties in
662 poorly-written programs.  The argument may be a double-quoted,
663 space-separated list or a single value without double-quotes.  The
664 list can be replaced, added to, deleted from, or disabled by using
665 the C<=>, C<+=>, C<-=>, and C<!> operators respectively.  The default
666 list of environment variable to check is printed when B<sudo> is
667 run by root with the I<-V> option.
668
669 =item env_delete
670
671 Environment variables to be removed from the user's environment.
672 The argument may be a double-quoted, space-separated list or a
673 single value without double-quotes.  The list can be replaced, added
674 to, deleted from, or disabled by using the C<=>, C<+=>, C<-=>, and
675 C<!> operators respectively.  The default list of environment
676 variable to remove is printed when B<sudo> is run by root with the
677 I<-V> option.
678
679 =item env_keep
680
681 Environment variables to be preserved in the user's environment
682 when the I<env_reset> option is in effect.  This allows fine-grained
683 control over the environment B<sudo>-spawned processes will receive.
684 The argument may be a double-quoted, space-separated list or a
685 single value without double-quotes.  The list can be replaced, added
686 to, deleted from, or disabled by using the C<=>, C<+=>, C<-=>, and
687 C<!> operators respectively.  This list has no default members.
688
689 =back
690
691 When logging via syslog(3), B<sudo> accepts the following values for the syslog
692 facility (the value of the B<syslog> Parameter): B<authpriv> (if your OS
693 supports it), B<auth>, B<daemon>, B<user>, B<local0>, B<local1>, B<local2>,
694 B<local3>, B<local4>, B<local5>, B<local6>, and B<local7>.  The following
695 syslog priorities are supported: B<alert>, B<crit>, B<debug>, B<emerg>,
696 B<err>, B<info>, B<notice>, and B<warning>.
697
698 =head2 User Specification
699
700  User_Spec ::= User_list Host_List '=' Cmnd_Spec_List \
701                (':' User_Spec)*
702
703  Cmnd_Spec_List ::= Cmnd_Spec |
704                     Cmnd_Spec ',' Cmnd_Spec_List
705
706  Cmnd_Spec ::= Runas_Spec? ('NOPASSWD:' | 'PASSWD:')? Cmnd
707
708  Runas_Spec ::= '(' Runas_List ')'
709
710 A B<user specification> determines which commands a user may run
711 (and as what user) on specified hosts.  By default, commands are
712 run as B<root>, but this can be changed on a per-command basis.
713
714 Let's break that down into its constituent parts:
715
716 =head2 Runas_Spec
717
718 A C<Runas_Spec> is simply a C<Runas_List> (as defined above)
719 enclosed in a set of parentheses.  If you do not specify a
720 C<Runas_Spec> in the user specification, a default C<Runas_Spec>
721 of B<root> will be used.  A C<Runas_Spec> sets the default for
722 commands that follow it.  What this means is that for the entry:
723
724  dgb    boulder = (operator) /bin/ls, /bin/kill, /usr/bin/who
725
726 The user B<dgb> may run F</bin/ls>, F</bin/kill>, and
727 F</usr/bin/lprm> -- but only as B<operator>.  E.g.,
728
729     sudo -u operator /bin/ls.
730
731 It is also possible to override a C<Runas_Spec> later on in an
732 entry.  If we modify the entry like so:
733
734  dgb    boulder = (operator) /bin/ls, (root) /bin/kill, /usr/bin/lprm
735
736 Then user B<dgb> is now allowed to run F</bin/ls> as B<operator>,
737 but  F</bin/kill> and F</usr/bin/lprm> as B<root>.
738
739 =head2 NOPASSWD and PASSWD
740
741 By default, B<sudo> requires that a user authenticate him or herself
742 before running a command.  This behavior can be modified via the
743 C<NOPASSWD> tag.  Like a C<Runas_Spec>, the C<NOPASSWD> tag sets
744 a default for the commands that follow it in the C<Cmnd_Spec_List>.
745 Conversely, the C<PASSWD> tag can be used to reverse things.
746 For example:
747
748  ray    rushmore = NOPASSWD: /bin/kill, /bin/ls, /usr/bin/lprm
749
750 would allow the user B<ray> to run F</bin/kill>, F</bin/ls>, and
751 F</usr/bin/lprm> as root on the machine rushmore as B<root> without
752 authenticating himself.  If we only want B<ray> to be able to
753 run F</bin/kill> without a password the entry would be:
754
755  ray    rushmore = NOPASSWD: /bin/kill, PASSWD: /bin/ls, /usr/bin/lprm
756
757 Note, however, that the C<PASSWD> tag has no effect on users who are
758 in the group specified by the exempt_group option.
759
760 By default, if the C<NOPASSWD> tag is applied to any of the entries
761 for a user on the current host, he or she will be able to run
762 C<sudo -l> without a password.  Additionally, a user may only run
763 C<sudo -v> without a password if the C<NOPASSWD> tag is present
764 for all a user's entries that pertain to the current host.
765 This behavior may be overridden via the verifypw and listpw options.
766
767 =head2 Wildcards (aka meta characters):
768
769 B<sudo> allows shell-style I<wildcards> to be used in pathnames
770 as well as command line arguments in the I<sudoers> file.  Wildcard
771 matching is done via the B<POSIX> C<fnmatch(3)> routine.  Note that
772 these are I<not> regular expressions.
773
774 =over 8
775
776 =item C<*>
777
778 Matches any set of zero or more characters.
779
780 =item C<?>
781
782 Matches any single character.
783
784 =item C<[...]>
785
786 Matches any character in the specified range.
787
788 =item C<[!...]>
789
790 Matches any character B<not> in the specified range.
791
792 =item C<\x>
793
794 For any character "x", evaluates to "x".  This is used to
795 escape special characters such as: "*", "?", "[", and "}".
796
797 =back
798
799 Note that a forward slash ('/') will B<not> be matched by
800 wildcards used in the pathname.  When matching the command
801 line arguments, however, as slash B<does> get matched by
802 wildcards.  This is to make a path like:
803
804     /usr/bin/*
805
806 match C</usr/bin/who> but not C</usr/bin/X11/xterm>.
807
808 =head2 Exceptions to wildcard rules:
809
810 The following exceptions apply to the above rules:
811
812 =over 8
813
814 =item C<"">
815
816 If the empty string C<""> is the only command line argument in the
817 I<sudoers> entry it means that command is not allowed to be run
818 with B<any> arguments.
819
820 =back
821
822 =head2 Other special characters and reserved words:
823
824 The pound sign ('#') is used to indicate a comment (unless it
825 occurs in the context of a user name and is followed by one or
826 more digits, in which case it is treated as a uid).  Both the
827 comment character and any text after it, up to the end of the line,
828 are ignored.
829
830 The reserved word B<ALL> is a built in I<alias> that always causes
831 a match to succeed.  It can be used wherever one might otherwise
832 use a C<Cmnd_Alias>, C<User_Alias>, C<Runas_Alias>, or C<Host_Alias>.
833 You should not try to define your own I<alias> called B<ALL> as the
834 built in alias will be used in preference to your own.  Please note
835 that using B<ALL> can be dangerous since in a command context, it
836 allows the user to run B<any> command on the system.
837
838 An exclamation point ('!') can be used as a logical I<not> operator
839 both in an I<alias> and in front of a C<Cmnd>.  This allows one to
840 exclude certain values.  Note, however, that using a C<!> in
841 conjunction with the built in C<ALL> alias to allow a user to
842 run "all but a few" commands rarely works as intended (see SECURITY
843 NOTES below).
844
845 Long lines can be continued with a backslash ('\') as the last
846 character on the line.
847
848 Whitespace between elements in a list as well as special syntactic
849 characters in a I<User Specification> ('=', ':', '(', ')') is optional.
850
851 The following characters must be escaped with a backslash ('\') when
852 used as part of a word (e.g. a username or hostname):
853 '@', '!', '=', ':', ',', '(', ')', '\'.
854
855 =head1 EXAMPLES
856
857 Below are example I<sudoers> entries.  Admittedly, some of
858 these are a bit contrived.  First, we define our I<aliases>:
859
860  # User alias specification
861  User_Alias     FULLTIMERS = millert, mikef, dowdy
862  User_Alias     PARTTIMERS = bostley, jwfox, crawl
863  User_Alias     WEBMASTERS = will, wendy, wim
864
865  # Runas alias specification
866  Runas_Alias    OP = root, operator
867  Runas_Alias    DB = oracle, sybase
868
869  # Host alias specification
870  Host_Alias     SPARC = bigtime, eclipse, moet, anchor :\
871                 SGI = grolsch, dandelion, black :\
872                 ALPHA = widget, thalamus, foobar :\
873                 HPPA = boa, nag, python
874  Host_Alias     CUNETS = 128.138.0.0/255.255.0.0
875  Host_Alias     CSNETS = 128.138.243.0, 128.138.204.0/24, 128.138.242.0
876  Host_Alias     SERVERS = master, mail, www, ns
877  Host_Alias     CDROM = orion, perseus, hercules
878
879  # Cmnd alias specification
880  Cmnd_Alias     DUMPS = /usr/bin/mt, /usr/sbin/dump, /usr/sbin/rdump,\
881                         /usr/sbin/restore, /usr/sbin/rrestore
882  Cmnd_Alias     KILL = /usr/bin/kill
883  Cmnd_Alias     PRINTING = /usr/sbin/lpc, /usr/bin/lprm
884  Cmnd_Alias     SHUTDOWN = /usr/sbin/shutdown
885  Cmnd_Alias     HALT = /usr/sbin/halt, /usr/sbin/fasthalt
886  Cmnd_Alias     REBOOT = /usr/sbin/reboot, /usr/sbin/fastboot
887  Cmnd_Alias     SHELLS = /usr/bin/sh, /usr/bin/csh, /usr/bin/ksh, \
888                          /usr/local/bin/tcsh, /usr/bin/rsh, \
889                          /usr/local/bin/zsh
890  Cmnd_Alias     SU = /usr/bin/su
891
892 Here we override some of the compiled in default values.  We want
893 B<sudo> to log via syslog(3) using the I<auth> facility in all cases.
894 We don't want to subject the full time staff to the B<sudo> lecture,
895 and user B<millert> need not give a password.  In addition, on the
896 machines in the I<SERVERS> C<Host_Alias>, we keep an additional
897 local log file and make sure we log the year in each log line since
898 the log entries will be kept around for several years.
899
900  # Override built in defaults
901  Defaults               syslog=auth
902  Defaults:FULLTIMERS    !lecture
903  Defaults:millert       !authenticate
904  Defaults@SERVERS       log_year, logfile=/var/log/sudo.log
905
906 The I<User specification> is the part that actually determines who may
907 run what.
908
909  root           ALL = (ALL) ALL
910  %wheel         ALL = (ALL) ALL
911
912 We let B<root> and any user in group B<wheel> run any command on any
913 host as any user.
914
915  FULLTIMERS     ALL = NOPASSWD: ALL
916
917 Full time sysadmins (B<millert>, B<mikef>, and B<dowdy>) may run any
918 command on any host without authenticating themselves.
919
920  PARTTIMERS     ALL = ALL
921
922 Part time sysadmins (B<bostley>, B<jwfox>, and B<crawl>) may run any
923 command on any host but they must authenticate themselves first
924 (since the entry lacks the C<NOPASSWD> tag).
925
926  jack           CSNETS = ALL
927
928 The user B<jack> may run any command on the machines in the I<CSNETS> alias
929 (the networks C<128.138.243.0>, C<128.138.204.0>, and C<128.138.242.0>).
930 Of those networks, only C<128.138.204.0> has an explicit netmask (in
931 CIDR notation) indicating it is a class C network.  For the other
932 networks in I<CSNETS>, the local machine's netmask will be used
933 during matching.
934
935  lisa           CUNETS = ALL
936
937 The user B<lisa> may run any command on any host in the I<CUNETS> alias
938 (the class B network C<128.138.0.0>).
939
940  operator       ALL = DUMPS, KILL, PRINTING, SHUTDOWN, HALT, REBOOT,\
941                 /usr/oper/bin/
942
943 The B<operator> user may run commands limited to simple maintenance.
944 Here, those are commands related to backups, killing processes, the
945 printing system, shutting down the system, and any commands in the
946 directory F</usr/oper/bin/>.
947
948  joe            ALL = /usr/bin/su operator
949
950 The user B<joe> may only su(1) to operator.
951
952  pete           HPPA = /usr/bin/passwd [A-z]*, !/usr/bin/passwd root
953
954 The user B<pete> is allowed to change anyone's password except for
955 root on the I<HPPA> machines.  Note that this assumes passwd(1)
956 does not take multiple usernames on the command line.
957
958  bob            SPARC = (OP) ALL : SGI = (OP) ALL
959
960 The user B<bob> may run anything on the I<SPARC> and I<SGI> machines
961 as any user listed in the I<OP> C<Runas_Alias> (B<root> and B<operator>).
962
963  jim            +biglab = ALL
964
965 The user B<jim> may run any command on machines in the I<biglab> netgroup.
966 B<Sudo> knows that "biglab" is a netgroup due to the '+' prefix.
967
968  +secretaries   ALL = PRINTING, /usr/bin/adduser, /usr/bin/rmuser
969
970 Users in the B<secretaries> netgroup need to help manage the printers
971 as well as add and remove users, so they are allowed to run those
972 commands on all machines.
973
974  fred           ALL = (DB) NOPASSWD: ALL
975
976 The user B<fred> can run commands as any user in the I<DB> C<Runas_Alias>
977 (B<oracle> or B<sybase>) without giving a password.
978
979  john           ALPHA = /usr/bin/su [!-]*, !/usr/bin/su *root*
980
981 On the I<ALPHA> machines, user B<john> may su to anyone except root
982 but he is not allowed to give su(1) any flags.
983
984  jen            ALL, !SERVERS = ALL
985
986 The user B<jen> may run any command on any machine except for those
987 in the I<SERVERS> C<Host_Alias> (master, mail, www and ns).
988
989  jill           SERVERS = /usr/bin/, !SU, !SHELLS
990
991 For any machine in the I<SERVERS> C<Host_Alias>, B<jill> may run
992 any commands in the directory /usr/bin/ except for those commands
993 belonging to the I<SU> and I<SHELLS> C<Cmnd_Aliases>.
994
995  steve          CSNETS = (operator) /usr/local/op_commands/
996
997 The user B<steve> may run any command in the directory /usr/local/op_commands/
998 but only as user operator.
999
1000  matt           valkyrie = KILL
1001
1002 On his personal workstation, valkyrie, B<matt> needs to be able to
1003 kill hung processes.
1004
1005  WEBMASTERS     www = (www) ALL, (root) /usr/bin/su www
1006
1007 On the host www, any user in the I<WEBMASTERS> C<User_Alias> (will,
1008 wendy, and wim), may run any command as user www (which owns the
1009 web pages) or simply su(1) to www.
1010
1011  ALL            CDROM = NOPASSWD: /sbin/umount /CDROM,\
1012                 /sbin/mount -o nosuid\,nodev /dev/cd0a /CDROM
1013
1014 Any user may mount or unmount a CD-ROM on the machines in the CDROM
1015 C<Host_Alias> (orion, perseus, hercules) without entering a password.
1016 This is a bit tedious for users to type, so it is a prime candidate
1017 for encapsulating in a shell script.
1018
1019 =head1 SECURITY NOTES
1020
1021 It is generally not effective to "subtract" commands from C<ALL>
1022 using the '!' operator.  A user can trivially circumvent this
1023 by copying the desired command to a different name and then
1024 executing that.  For example:
1025
1026     bill        ALL = ALL, !SU, !SHELLS
1027
1028 Doesn't really prevent B<bill> from running the commands listed in
1029 I<SU> or I<SHELLS> since he can simply copy those commands to a
1030 different name, or use a shell escape from an editor or other
1031 program.  Therefore, these kind of restrictions should be considered
1032 advisory at best (and reinforced by policy).
1033
1034 =head1 CAVEATS
1035
1036 The I<sudoers> file should B<always> be edited by the B<visudo>
1037 command which locks the file and does grammatical checking. It is
1038 imperative that I<sudoers> be free of syntax errors since B<sudo>
1039 will not run with a syntactically incorrect I<sudoers> file.
1040
1041 When using netgroups of machines (as opposed to users), if you
1042 store fully qualified hostnames in the netgroup (as is usually the
1043 case), you either need to have the machine's hostname be fully qualified
1044 as returned by the C<hostname> command or use the I<fqdn> option in
1045 I<sudoers>.
1046
1047 =head1 FILES
1048
1049  @sysconfdir@/sudoers           List of who can run what
1050  /etc/group             Local groups file
1051  /etc/netgroup          List of network groups
1052
1053 =head1 SEE ALSO
1054
1055 rsh(1), sudo(8), visudo(8), su(1), fnmatch(3).