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