Imported Upstream version 1.6.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 and C<USER> (in addition to the C<SUDO_*> variables).
442 Of these, only C<TERM> is copied unaltered from the old environment.
443 The other variables are set to default values (possibly modified
444 by the value of the I<set_logname> option).  If B<sudo> was compiled
445 with the C<SECURE_PATH> option, its value will be used for the C<PATH>
446 environment variable.
447 Other variables may be preserved with the I<env_keep> option.
448
449 =item use_loginclass
450
451 If set, B<sudo> will apply the defaults specified for the target user's
452 login class if one exists.  Only available if B<sudo> is configured with
453 the --with-logincap option.  This flag is I<off> by default.
454
455 =back
456
457 B<Integers>:
458
459 =over 12
460
461 =item passwd_tries
462
463 The number of tries a user gets to enter his/her password before
464 B<sudo> logs the failure and exits.  The default is C<@passwd_tries@>.
465
466 =back
467
468 B<Integers that can be used in a boolean context>:
469
470 =over 12
471
472 =item loglinelen
473
474 Number of characters per line for the file log.  This value is used
475 to decide when to wrap lines for nicer log files.  This has no
476 effect on the syslog log file, only the file log.  The default is
477 C<@loglen@> (use 0 or negate the option to disable word wrap).
478
479 =item timestamp_timeout
480
481 Number of minutes that can elapse before B<sudo> will ask for a
482 passwd again.  The default is C<@timeout@>.  Set this to C<0> to always
483 prompt for a password.
484 If set to a value less than C<0> the user's timestamp will never
485 expire.  This can be used to allow users to create or delete their
486 own timestamps via C<sudo -v> and C<sudo -k> respectively.
487
488 =item passwd_timeout
489
490 Number of minutes before the B<sudo> password prompt times out.
491 The default is C<@password_timeout@>, set this to C<0> for no password timeout.
492
493 =item umask
494
495 Umask to use when running the command.  Negate this option or set
496 it to 0777 to preserve the user's umask.  The default is C<@sudo_umask@>.
497
498 =back
499
500 B<Strings>:
501
502 =over 12
503
504 =item mailsub
505
506 Subject of the mail sent to the I<mailto> user. The escape C<%h>
507 will expand to the hostname of the machine.
508 Default is C<@mailsub@>.
509
510 =item badpass_message
511
512 Message that is displayed if a user enters an incorrect password.
513 The default is C<@badpass_message@> unless insults are enabled.
514
515 =item timestampdir
516
517 The directory in which B<sudo> stores its timestamp files.
518 The default is F<@timedir@>.
519
520 =item passprompt
521
522 The default prompt to use when asking for a password; can be overridden
523 via the B<-p> option or the C<SUDO_PROMPT> environment variable. Supports
524 two escapes: "%u" expands to the user's login name and "%h" expands
525 to the local hostname.  The default value is C<@passprompt@>.
526
527 =item runas_default
528
529 The default user to run commands as if the B<-u> flag is not specified
530 on the command line.  This defaults to C<@runas_default@>.
531
532 =item syslog_goodpri
533
534 Syslog priority to use when user authenticates successfully.
535 Defaults to C<@goodpri@>.
536
537 =item syslog_badpri
538
539 Syslog priority to use when user authenticates unsuccessfully.
540 Defaults to C<@badpri@>.
541
542 =item editor
543
544 A colon (':') separated list of editors allowed to be used with
545 B<visudo>.  B<visudo> will choose the editor that matches the user's
546 USER environment variable if possible, or the first editor in the
547 list that exists and is executable.  The default is the path to vi
548 on your system.
549
550 =back
551
552 B<Strings that can be used in a boolean context>:
553
554 =over 12
555
556 =item logfile
557
558 Path to the B<sudo> log file (not the syslog log file).  Setting a path
559 turns on logging to a file; negating this option turns it off.
560
561 =item syslog
562
563 Syslog facility if syslog is being used for logging (negate to
564 disable syslog logging).  Defaults to C<@logfac@>.
565
566 =item mailerpath
567
568 Path to mail program used to send warning mail.
569 Defaults to the path to sendmail found at configure time.
570
571 =item mailerflags
572
573 Flags to use when invoking mailer. Defaults to B<-t>.
574
575 =item mailto
576
577 Address to send warning and error mail to.  The address should
578 be enclosed in double quotes (C<">) to protect against sudo
579 interpreting the C<@> sign.  Defaults to C<@mailto@>.
580
581 =item exempt_group
582
583 Users in this group are exempt from password and PATH requirements.
584 This is not set by default.
585
586 =item verifypw
587
588 This option controls when a password will be required when a user runs
589 B<sudo> with the B<-v> flag.  It has the following possible values:
590
591 =over 8
592
593 =item all
594
595 All the user's I<sudoers> entries for the current host must have
596 the C<NOPASSWD> flag set to avoid entering a password.
597
598 =item any
599
600 At least one of the user's I<sudoers> entries for the current host
601 must have the C<NOPASSWD> flag set to avoid entering a password.
602
603 =item never
604
605 The user need never enter a password to use the B<-v> flag.
606
607 =item always
608
609 The user must always enter a password to use the B<-v> flag.
610
611 =back
612
613 The default value is `all'.
614
615 =item listpw
616
617 This option controls when a password will be required when a
618 user runs B<sudo> with the B<-l>.  It has the following possible values:
619
620 =over 8
621
622 =item all
623
624 All the user's I<sudoers> entries for the current host must have
625 the C<NOPASSWD> flag set to avoid entering a password.
626
627 =item any
628
629 At least one of the user's I<sudoers> entries for the current host
630 must have the C<NOPASSWD> flag set to avoid entering a password.
631
632 =item never
633
634 The user need never enter a password to use the B<-l> flag.
635
636 =item always
637
638 The user must always enter a password to use the B<-l> flag.
639
640 =back
641
642 The default value is `any'.
643
644 =back
645
646 B<Lists that can be used in a boolean context>:
647
648 =over 12
649
650 =item env_check
651
652 Environment variables to be removed from the user's environment if
653 the variable's value contains C<%> or C</> characters.  This can
654 be used to guard against printf-style format vulnerabilties in
655 poorly-written programs.  The argument may be a double-quoted,
656 space-separated list or a single value without double-quotes.  The
657 list can be replaced, added to, deleted from, or disabled by using
658 the C<=>, C<+=>, C<-=>, and C<!> operators respectively.  The default
659 list of environment variable to check is printed when B<sudo> is
660 run by root with the I<-V> option.
661
662 =item env_delete
663
664 Environment variables to be removed from the user's environment.
665 The argument may be a double-quoted, space-separated list or a
666 single value without double-quotes.  The list can be replaced, added
667 to, deleted from, or disabled by using the C<=>, C<+=>, C<-=>, and
668 C<!> operators respectively.  The default list of environment
669 variable to remove is printed when B<sudo> is run by root with the
670 I<-V> option.
671
672 =item env_keep
673
674 Environment variables to be preserved in the user's environment
675 when the I<env_reset> option is in effect.  This allows fine-grained
676 control over the environment B<sudo>-spawned processes will receive.
677 The argument may be a double-quoted, space-separated list or a
678 single value without double-quotes.  The list can be replaced, added
679 to, deleted from, or disabled by using the C<=>, C<+=>, C<-=>, and
680 C<!> operators respectively.  This list has no default members.
681
682 =back
683
684 When logging via syslog(3), B<sudo> accepts the following values for the syslog
685 facility (the value of the B<syslog> Parameter): B<authpriv> (if your OS
686 supports it), B<auth>, B<daemon>, B<user>, B<local0>, B<local1>, B<local2>,
687 B<local3>, B<local4>, B<local5>, B<local6>, and B<local7>.  The following
688 syslog priorities are supported: B<alert>, B<crit>, B<debug>, B<emerg>,
689 B<err>, B<info>, B<notice>, and B<warning>.
690
691 =head2 User Specification
692
693  User_Spec ::= User_list Host_List '=' Cmnd_Spec_List \
694                (':' User_Spec)*
695
696  Cmnd_Spec_List ::= Cmnd_Spec |
697                     Cmnd_Spec ',' Cmnd_Spec_List
698
699  Cmnd_Spec ::= Runas_Spec? ('NOPASSWD:' | 'PASSWD:')? Cmnd
700
701  Runas_Spec ::= '(' Runas_List ')'
702
703 A B<user specification> determines which commands a user may run
704 (and as what user) on specified hosts.  By default, commands are
705 run as B<root>, but this can be changed on a per-command basis.
706
707 Let's break that down into its constituent parts:
708
709 =head2 Runas_Spec
710
711 A C<Runas_Spec> is simply a C<Runas_List> (as defined above)
712 enclosed in a set of parentheses.  If you do not specify a
713 C<Runas_Spec> in the user specification, a default C<Runas_Spec>
714 of B<root> will be used.  A C<Runas_Spec> sets the default for
715 commands that follow it.  What this means is that for the entry:
716
717  dgb    boulder = (operator) /bin/ls, /bin/kill, /usr/bin/who
718
719 The user B<dgb> may run F</bin/ls>, F</bin/kill>, and
720 F</usr/bin/lprm> -- but only as B<operator>.  E.g.,
721
722     sudo -u operator /bin/ls.
723
724 It is also possible to override a C<Runas_Spec> later on in an
725 entry.  If we modify the entry like so:
726
727  dgb    boulder = (operator) /bin/ls, (root) /bin/kill, /usr/bin/lprm
728
729 Then user B<dgb> is now allowed to run F</bin/ls> as B<operator>,
730 but  F</bin/kill> and F</usr/bin/lprm> as B<root>.
731
732 =head2 NOPASSWD and PASSWD
733
734 By default, B<sudo> requires that a user authenticate him or herself
735 before running a command.  This behavior can be modified via the
736 C<NOPASSWD> tag.  Like a C<Runas_Spec>, the C<NOPASSWD> tag sets
737 a default for the commands that follow it in the C<Cmnd_Spec_List>.
738 Conversely, the C<PASSWD> tag can be used to reverse things.
739 For example:
740
741  ray    rushmore = NOPASSWD: /bin/kill, /bin/ls, /usr/bin/lprm
742
743 would allow the user B<ray> to run F</bin/kill>, F</bin/ls>, and
744 F</usr/bin/lprm> as root on the machine rushmore as B<root> without
745 authenticating himself.  If we only want B<ray> to be able to
746 run F</bin/kill> without a password the entry would be:
747
748  ray    rushmore = NOPASSWD: /bin/kill, PASSWD: /bin/ls, /usr/bin/lprm
749
750 Note, however, that the C<PASSWD> tag has no effect on users who are
751 in the group specified by the exempt_group option.
752
753 By default, if the C<NOPASSWD> tag is applied to any of the entries
754 for a user on the current host, he or she will be able to run
755 C<sudo -l> without a password.  Additionally, a user may only run
756 C<sudo -v> without a password if the C<NOPASSWD> tag is present
757 for all a user's entries that pertain to the current host.
758 This behavior may be overridden via the verifypw and listpw options.
759
760 =head2 Wildcards (aka meta characters):
761
762 B<sudo> allows shell-style I<wildcards> to be used in pathnames
763 as well as command line arguments in the I<sudoers> file.  Wildcard
764 matching is done via the B<POSIX> C<fnmatch(3)> routine.  Note that
765 these are I<not> regular expressions.
766
767 =over 8
768
769 =item C<*>
770
771 Matches any set of zero or more characters.
772
773 =item C<?>
774
775 Matches any single character.
776
777 =item C<[...]>
778
779 Matches any character in the specified range.
780
781 =item C<[!...]>
782
783 Matches any character B<not> in the specified range.
784
785 =item C<\x>
786
787 For any character "x", evaluates to "x".  This is used to
788 escape special characters such as: "*", "?", "[", and "}".
789
790 =back
791
792 Note that a forward slash ('/') will B<not> be matched by
793 wildcards used in the pathname.  When matching the command
794 line arguments, however, as slash B<does> get matched by
795 wildcards.  This is to make a path like:
796
797     /usr/bin/*
798
799 match C</usr/bin/who> but not C</usr/bin/X11/xterm>.
800
801 =head2 Exceptions to wildcard rules:
802
803 The following exceptions apply to the above rules:
804
805 =over 8
806
807 =item C<"">
808
809 If the empty string C<""> is the only command line argument in the
810 I<sudoers> entry it means that command is not allowed to be run
811 with B<any> arguments.
812
813 =back
814
815 =head2 Other special characters and reserved words:
816
817 The pound sign ('#') is used to indicate a comment (unless it
818 occurs in the context of a user name and is followed by one or
819 more digits, in which case it is treated as a uid).  Both the
820 comment character and any text after it, up to the end of the line,
821 are ignored.
822
823 The reserved word B<ALL> is a built in I<alias> that always causes
824 a match to succeed.  It can be used wherever one might otherwise
825 use a C<Cmnd_Alias>, C<User_Alias>, C<Runas_Alias>, or C<Host_Alias>.
826 You should not try to define your own I<alias> called B<ALL> as the
827 built in alias will be used in preference to your own.  Please note
828 that using B<ALL> can be dangerous since in a command context, it
829 allows the user to run B<any> command on the system.
830
831 An exclamation point ('!') can be used as a logical I<not> operator
832 both in an I<alias> and in front of a C<Cmnd>.  This allows one to
833 exclude certain values.  Note, however, that using a C<!> in
834 conjunction with the built in C<ALL> alias to allow a user to
835 run "all but a few" commands rarely works as intended (see SECURITY
836 NOTES below).
837
838 Long lines can be continued with a backslash ('\') as the last
839 character on the line.
840
841 Whitespace between elements in a list as well as special syntactic
842 characters in a I<User Specification> ('=', ':', '(', ')') is optional.
843
844 The following characters must be escaped with a backslash ('\') when
845 used as part of a word (e.g. a username or hostname):
846 '@', '!', '=', ':', ',', '(', ')', '\'.
847
848 =head1 EXAMPLES
849
850 Below are example I<sudoers> entries.  Admittedly, some of
851 these are a bit contrived.  First, we define our I<aliases>:
852
853  # User alias specification
854  User_Alias     FULLTIMERS = millert, mikef, dowdy
855  User_Alias     PARTTIMERS = bostley, jwfox, crawl
856  User_Alias     WEBMASTERS = will, wendy, wim
857
858  # Runas alias specification
859  Runas_Alias    OP = root, operator
860  Runas_Alias    DB = oracle, sybase
861
862  # Host alias specification
863  Host_Alias     SPARC = bigtime, eclipse, moet, anchor :\
864                 SGI = grolsch, dandelion, black :\
865                 ALPHA = widget, thalamus, foobar :\
866                 HPPA = boa, nag, python
867  Host_Alias     CUNETS = 128.138.0.0/255.255.0.0
868  Host_Alias     CSNETS = 128.138.243.0, 128.138.204.0/24, 128.138.242.0
869  Host_Alias     SERVERS = master, mail, www, ns
870  Host_Alias     CDROM = orion, perseus, hercules
871
872  # Cmnd alias specification
873  Cmnd_Alias     DUMPS = /usr/bin/mt, /usr/sbin/dump, /usr/sbin/rdump,\
874                         /usr/sbin/restore, /usr/sbin/rrestore
875  Cmnd_Alias     KILL = /usr/bin/kill
876  Cmnd_Alias     PRINTING = /usr/sbin/lpc, /usr/bin/lprm
877  Cmnd_Alias     SHUTDOWN = /usr/sbin/shutdown
878  Cmnd_Alias     HALT = /usr/sbin/halt, /usr/sbin/fasthalt
879  Cmnd_Alias     REBOOT = /usr/sbin/reboot, /usr/sbin/fastboot
880  Cmnd_Alias     SHELLS = /usr/bin/sh, /usr/bin/csh, /usr/bin/ksh, \
881                          /usr/local/bin/tcsh, /usr/bin/rsh, \
882                          /usr/local/bin/zsh
883  Cmnd_Alias     SU = /usr/bin/su
884
885 Here we override some of the compiled in default values.  We want
886 B<sudo> to log via syslog(3) using the I<auth> facility in all cases.
887 We don't want to subject the full time staff to the B<sudo> lecture,
888 and user B<millert> need not give a password.  In addition, on the
889 machines in the I<SERVERS> C<Host_Alias>, we keep an additional
890 local log file and make sure we log the year in each log line since
891 the log entries will be kept around for several years.
892
893  # Override built in defaults
894  Defaults               syslog=auth
895  Defaults:FULLTIMERS    !lecture
896  Defaults:millert       !authenticate
897  Defaults@SERVERS       log_year, logfile=/var/log/sudo.log
898
899 The I<User specification> is the part that actually determines who may
900 run what.
901
902  root           ALL = (ALL) ALL
903  %wheel         ALL = (ALL) ALL
904
905 We let B<root> and any user in group B<wheel> run any command on any
906 host as any user.
907
908  FULLTIMERS     ALL = NOPASSWD: ALL
909
910 Full time sysadmins (B<millert>, B<mikef>, and B<dowdy>) may run any
911 command on any host without authenticating themselves.
912
913  PARTTIMERS     ALL = ALL
914
915 Part time sysadmins (B<bostley>, B<jwfox>, and B<crawl>) may run any
916 command on any host but they must authenticate themselves first
917 (since the entry lacks the C<NOPASSWD> tag).
918
919  jack           CSNETS = ALL
920
921 The user B<jack> may run any command on the machines in the I<CSNETS> alias
922 (the networks C<128.138.243.0>, C<128.138.204.0>, and C<128.138.242.0>).
923 Of those networks, only C<128.138.204.0> has an explicit netmask (in
924 CIDR notation) indicating it is a class C network.  For the other
925 networks in I<CSNETS>, the local machine's netmask will be used
926 during matching.
927
928  lisa           CUNETS = ALL
929
930 The user B<lisa> may run any command on any host in the I<CUNETS> alias
931 (the class B network C<128.138.0.0>).
932
933  operator       ALL = DUMPS, KILL, PRINTING, SHUTDOWN, HALT, REBOOT,\
934                 /usr/oper/bin/
935
936 The B<operator> user may run commands limited to simple maintenance.
937 Here, those are commands related to backups, killing processes, the
938 printing system, shutting down the system, and any commands in the
939 directory F</usr/oper/bin/>.
940
941  joe            ALL = /usr/bin/su operator
942
943 The user B<joe> may only su(1) to operator.
944
945  pete           HPPA = /usr/bin/passwd [A-z]*, !/usr/bin/passwd root
946
947 The user B<pete> is allowed to change anyone's password except for
948 root on the I<HPPA> machines.  Note that this assumes passwd(1)
949 does not take multiple usernames on the command line.
950
951  bob            SPARC = (OP) ALL : SGI = (OP) ALL
952
953 The user B<bob> may run anything on the I<SPARC> and I<SGI> machines
954 as any user listed in the I<OP> C<Runas_Alias> (B<root> and B<operator>).
955
956  jim            +biglab = ALL
957
958 The user B<jim> may run any command on machines in the I<biglab> netgroup.
959 B<Sudo> knows that "biglab" is a netgroup due to the '+' prefix.
960
961  +secretaries   ALL = PRINTING, /usr/bin/adduser, /usr/bin/rmuser
962
963 Users in the B<secretaries> netgroup need to help manage the printers
964 as well as add and remove users, so they are allowed to run those
965 commands on all machines.
966
967  fred           ALL = (DB) NOPASSWD: ALL
968
969 The user B<fred> can run commands as any user in the I<DB> C<Runas_Alias>
970 (B<oracle> or B<sybase>) without giving a password.
971
972  john           ALPHA = /usr/bin/su [!-]*, !/usr/bin/su *root*
973
974 On the I<ALPHA> machines, user B<john> may su to anyone except root
975 but he is not allowed to give su(1) any flags.
976
977  jen            ALL, !SERVERS = ALL
978
979 The user B<jen> may run any command on any machine except for those
980 in the I<SERVERS> C<Host_Alias> (master, mail, www and ns).
981
982  jill           SERVERS = /usr/bin/, !SU, !SHELLS
983
984 For any machine in the I<SERVERS> C<Host_Alias>, B<jill> may run
985 any commands in the directory /usr/bin/ except for those commands
986 belonging to the I<SU> and I<SHELLS> C<Cmnd_Aliases>.
987
988  steve          CSNETS = (operator) /usr/local/op_commands/
989
990 The user B<steve> may run any command in the directory /usr/local/op_commands/
991 but only as user operator.
992
993  matt           valkyrie = KILL
994
995 On his personal workstation, valkyrie, B<matt> needs to be able to
996 kill hung processes.
997
998  WEBMASTERS     www = (www) ALL, (root) /usr/bin/su www
999
1000 On the host www, any user in the I<WEBMASTERS> C<User_Alias> (will,
1001 wendy, and wim), may run any command as user www (which owns the
1002 web pages) or simply su(1) to www.
1003
1004  ALL            CDROM = NOPASSWD: /sbin/umount /CDROM,\
1005                 /sbin/mount -o nosuid\,nodev /dev/cd0a /CDROM
1006
1007 Any user may mount or unmount a CD-ROM on the machines in the CDROM
1008 C<Host_Alias> (orion, perseus, hercules) without entering a password.
1009 This is a bit tedious for users to type, so it is a prime candidate
1010 for encapsulating in a shell script.
1011
1012 =head1 SECURITY NOTES
1013
1014 It is generally not effective to "subtract" commands from C<ALL>
1015 using the '!' operator.  A user can trivially circumvent this
1016 by copying the desired command to a different name and then
1017 executing that.  For example:
1018
1019     bill        ALL = ALL, !SU, !SHELLS
1020
1021 Doesn't really prevent B<bill> from running the commands listed in
1022 I<SU> or I<SHELLS> since he can simply copy those commands to a
1023 different name, or use a shell escape from an editor or other
1024 program.  Therefore, these kind of restrictions should be considered
1025 advisory at best (and reinforced by policy).
1026
1027 =head1 CAVEATS
1028
1029 The I<sudoers> file should B<always> be edited by the B<visudo>
1030 command which locks the file and does grammatical checking. It is
1031 imperative that I<sudoers> be free of syntax errors since B<sudo>
1032 will not run with a syntactically incorrect I<sudoers> file.
1033
1034 When using netgroups of machines (as opposed to users), if you
1035 store fully qualified hostnames in the netgroup (as is usually the
1036 case), you either need to have the machine's hostname be fully qualified
1037 as returned by the C<hostname> command or use the I<fqdn> option in
1038 I<sudoers>.
1039
1040 =head1 FILES
1041
1042  @sysconfdir@/sudoers           List of who can run what
1043  /etc/group             Local groups file
1044  /etc/netgroup          List of network groups
1045
1046 =head1 SEE ALSO
1047
1048 rsh(1), sudo(8), visudo(8), su(1), fnmatch(3).