[BACK]Return to sudoers.pod CVS log [TXT][DIR] Up to [local] / src / usr.bin / sudo

Annotation of src/usr.bin/sudo/sudoers.pod, Revision 1.11

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