]> granicus.if.org Git - sudo/blob - doc/sudoers.man.in
744b797207313cb3d6e24847501aaa0d5f7baeba
[sudo] / doc / sudoers.man.in
1 .\" Automatically generated from an mdoc input file.  Do not edit.
2 .\"
3 .\" Copyright (c) 1994-1996, 1998-2005, 2007-2019
4 .\"     Todd C. Miller <Todd.Miller@sudo.ws>
5 .\"
6 .\" Permission to use, copy, modify, and distribute this software for any
7 .\" purpose with or without fee is hereby granted, provided that the above
8 .\" copyright notice and this permission notice appear in all copies.
9 .\"
10 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 .\"
18 .\" Sponsored in part by the Defense Advanced Research Projects
19 .\" Agency (DARPA) and Air Force Research Laboratory, Air Force
20 .\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
21 .\"
22 .nr SL @SEMAN@
23 .nr BA @BAMAN@
24 .nr LC @LCMAN@
25 .nr PS @PSMAN@
26 .TH "SUDOERS" "@mansectform@" "March 4, 2019" "Sudo @PACKAGE_VERSION@" "File Formats Manual"
27 .nh
28 .if n .ad l
29 .SH "NAME"
30 \fBsudoers\fR
31 \- default sudo security policy plugin
32 .SH "DESCRIPTION"
33 The
34 \fBsudoers\fR
35 policy plugin determines a user's
36 \fBsudo\fR
37 privileges.
38 It is the default
39 \fBsudo\fR
40 policy plugin.
41 The policy is driven by
42 the
43 \fI@sysconfdir@/sudoers\fR
44 file or, optionally in LDAP.
45 The policy format is described in detail in the
46 \fISUDOERS FILE FORMAT\fR
47 section.
48 For information on storing
49 \fBsudoers\fR
50 policy information
51 in LDAP, please see
52 sudoers.ldap(@mansectform@).
53 .SS "Configuring sudo.conf for sudoers"
54 \fBsudo\fR
55 consults the
56 sudo.conf(@mansectform@)
57 file to determine which policy and I/O logging plugins to load.
58 If no
59 sudo.conf(@mansectform@)
60 file is present, or if it contains no
61 \fRPlugin\fR
62 lines,
63 \fBsudoers\fR
64 will be used for policy decisions and I/O logging.
65 To explicitly configure
66 sudo.conf(@mansectform@)
67 to use the
68 \fBsudoers\fR
69 plugin, the following configuration can be used.
70 .nf
71 .sp
72 .RS 6n
73 Plugin sudoers_policy sudoers.so
74 Plugin sudoers_io sudoers.so
75 .RE
76 .fi
77 .PP
78 Starting with
79 \fBsudo\fR
80 1.8.5, it is possible to specify optional arguments to the
81 \fBsudoers\fR
82 plugin in the
83 sudo.conf(@mansectform@)
84 file.
85 These arguments, if present, should be listed after the path to the plugin
86 (i.e., after
87 \fIsudoers.so\fR).
88 Multiple arguments may be specified, separated by white space.
89 For example:
90 .nf
91 .sp
92 .RS 6n
93 Plugin sudoers_policy sudoers.so sudoers_mode=0400
94 .RE
95 .fi
96 .PP
97 The following plugin arguments are supported:
98 .TP 10n
99 ldap_conf=pathname
100 The
101 \fIldap_conf\fR
102 argument can be used to override the default path to the
103 \fIldap.conf\fR
104 file.
105 .TP 10n
106 ldap_secret=pathname
107 The
108 \fIldap_secret\fR
109 argument can be used to override the default path to the
110 \fIldap.secret\fR
111 file.
112 .TP 10n
113 sudoers_file=pathname
114 The
115 \fIsudoers_file\fR
116 argument can be used to override the default path to the
117 \fIsudoers\fR
118 file.
119 .TP 10n
120 sudoers_uid=uid
121 The
122 \fIsudoers_uid\fR
123 argument can be used to override the default owner of the sudoers file.
124 It should be specified as a numeric user ID.
125 .TP 10n
126 sudoers_gid=gid
127 The
128 \fIsudoers_gid\fR
129 argument can be used to override the default group of the sudoers file.
130 It must be specified as a numeric group ID (not a group name).
131 .TP 10n
132 sudoers_mode=mode
133 The
134 \fIsudoers_mode\fR
135 argument can be used to override the default file mode for the sudoers file.
136 It should be specified as an octal value.
137 .PP
138 For more information on configuring
139 sudo.conf(@mansectform@),
140 please refer to its manual.
141 .SS "User Authentication"
142 The
143 \fBsudoers\fR
144 security policy requires that most users authenticate
145 themselves before they can use
146 \fBsudo\fR.
147 A password is not required
148 if the invoking user is root, if the target user is the same as the
149 invoking user, or if the policy has disabled authentication for the
150 user or command.
151 Unlike
152 su(1),
153 when
154 \fBsudoers\fR
155 requires
156 authentication, it validates the invoking user's credentials, not
157 the target user's (or root's) credentials.
158 This can be changed via
159 the
160 \fIrootpw\fR,
161 \fItargetpw\fR
162 and
163 \fIrunaspw\fR
164 flags, described later.
165 .PP
166 If a user who is not listed in the policy tries to run a command
167 via
168 \fBsudo\fR,
169 mail is sent to the proper authorities.
170 The address
171 used for such mail is configurable via the
172 \fImailto\fR
173 Defaults entry
174 (described later) and defaults to
175 \fR@mailto@\fR.
176 .PP
177 Note that no mail will be sent if an unauthorized user tries to run
178 \fBsudo\fR
179 with the
180 \fB\-l\fR
181 or
182 \fB\-v\fR
183 option unless there is an authentication error and
184 either the
185 \fImail_always\fR
186 or
187 \fImail_badpass\fR
188 flags are enabled.
189 This allows users to
190 determine for themselves whether or not they are allowed to use
191 \fBsudo\fR.
192 All attempts to run
193 \fBsudo\fR
194 (successful or not)
195 will be logged, regardless of whether or not mail is sent.
196 .PP
197 If
198 \fBsudo\fR
199 is run by root and the
200 \fRSUDO_USER\fR
201 environment variable
202 is set, the
203 \fBsudoers\fR
204 policy will use this value to determine who
205 the actual user is.
206 This can be used by a user to log commands
207 through sudo even when a root shell has been invoked.
208 It also
209 allows the
210 \fB\-e\fR
211 option to remain useful even when invoked via a
212 sudo-run script or program.
213 Note, however, that the
214 \fIsudoers\fR
215 file lookup is still done for root, not the user specified by
216 \fRSUDO_USER\fR.
217 .PP
218 \fBsudoers\fR
219 uses per-user time stamp files for credential caching.
220 Once a user has been authenticated, a record is written
221 containing the user ID that was used to authenticate, the
222 terminal session ID, the start time of the session leader
223 (or parent process) and a time stamp
224 (using a monotonic clock if one is available).
225 The user may then use
226 \fBsudo\fR
227 without a password for a short period of time
228 (\fR@timeout@\fR
229 minutes unless overridden by the
230 \fItimestamp_timeout\fR
231 option)
232 \&.
233 By default,
234 \fBsudoers\fR
235 uses a separate record for each terminal, which means that
236 a user's login sessions are authenticated separately.
237 The
238 \fItimestamp_type\fR
239 option can be used to select the type of time stamp record
240 \fBsudoers\fR
241 will use.
242 .SS "Logging"
243 \fBsudoers\fR
244 can log both successful and unsuccessful attempts (as well
245 as errors) to
246 syslog(3),
247 a log file, or both.
248 By default,
249 \fBsudoers\fR
250 will log via
251 syslog(3)
252 but this is changeable via the
253 \fIsyslog\fR
254 and
255 \fIlogfile\fR
256 Defaults settings.
257 See
258 \fILOG FORMAT\fR
259 for a description of the log file format.
260 .PP
261 \fBsudoers\fR
262 is also capable of running a command in a pseudo-tty and logging all
263 input and/or output.
264 The standard input, standard output and standard error can be logged
265 even when not associated with a terminal.
266 I/O logging is not on by default but can be enabled using
267 the
268 \fIlog_input\fR
269 and
270 \fIlog_output\fR
271 options as well as the
272 \fRLOG_INPUT\fR
273 and
274 \fRLOG_OUTPUT\fR
275 command tags.
276 See
277 \fII/O LOG FILES\fR
278 for details on how I/O log files are stored.
279 .SS "Command environment"
280 Since environment variables can influence program behavior,
281 \fBsudoers\fR
282 provides a means to restrict which variables from the user's
283 environment are inherited by the command to be run.
284 There are two
285 distinct ways
286 \fBsudoers\fR
287 can deal with environment variables.
288 .PP
289 By default, the
290 \fIenv_reset\fR
291 option is enabled.
292 This causes commands
293 to be executed with a new, minimal environment.
294 On AIX (and Linux
295 systems without PAM), the environment is initialized with the
296 contents of the
297 \fI/etc/environment\fR
298 file.
299 .if \n(LC \{\
300 On
301 BSD
302 systems, if the
303 \fIuse_loginclass\fR
304 option is enabled, the environment is initialized
305 based on the
306 \fIpath\fR
307 and
308 \fIsetenv\fR
309 settings in
310 \fI/etc/login.conf\fR.
311 .\}
312 The new environment contains the
313 \fRTERM\fR,
314 \fRPATH\fR,
315 \fRHOME\fR,
316 \fRMAIL\fR,
317 \fRSHELL\fR,
318 \fRLOGNAME\fR,
319 \fRUSER\fR
320 and
321 \fRSUDO_*\fR
322 variables
323 in addition to variables from the invoking process permitted by the
324 \fIenv_check\fR
325 and
326 \fIenv_keep\fR
327 options.
328 This is effectively a whitelist
329 for environment variables.
330 The environment variables
331 \fRLOGNAME\fR
332 and
333 \fRUSER\fR
334 are treated specially.
335 If one of them is preserved (or removed) from user's environment, the other
336 will be as well.
337 If
338 \fRLOGNAME\fR
339 and
340 \fRUSER\fR
341 are to be preserved but only one of them is present in the user's environment,
342 the other will be set to the same value.
343 This avoids an inconsistent environment where one of the variables
344 describing the user name is set to the invoking user and one is
345 set to the target user.
346 \fR()\fR
347 are removed unless both the name and value parts are matched by
348 \fIenv_keep\fR
349 or
350 \fIenv_check\fR,
351 as they may be interpreted as functions by the
352 \fBbash\fR
353 shell.
354 Prior to version 1.8.11, such variables were always removed.
355 .PP
356 If, however, the
357 \fIenv_reset\fR
358 option is disabled, any variables not
359 explicitly denied by the
360 \fIenv_check\fR
361 and
362 \fIenv_delete\fR
363 options are
364 inherited from the invoking process.
365 In this case,
366 \fIenv_check\fR
367 and
368 \fIenv_delete\fR
369 behave like a blacklist.
370 Prior to version 1.8.21, environment variables with a value beginning with
371 \fR()\fR
372 were always removed.
373 Beginning with version 1.8.21, a pattern in
374 \fIenv_delete\fR
375 is used to match
376 \fBbash\fR
377 shell functions instead.
378 Since it is not possible
379 to blacklist all potentially dangerous environment variables, use
380 of the default
381 \fIenv_reset\fR
382 behavior is encouraged.
383 .PP
384 Environment variables specified by
385 \fIenv_check\fR,
386 \fIenv_delete\fR,
387 or
388 \fIenv_keep\fR
389 may include one or more
390 \(oq*\(cq
391 characters which will match zero or more characters.
392 No other wildcard characters are supported.
393 .PP
394 By default, environment variables are matched by name.
395 However, if the pattern includes an equal sign
396 (\(oq=\&\(cq),
397 both the variables name and value must match.
398 For example, a
399 \fBbash\fR
400 shell function could be matched as follows:
401 .nf
402 .sp
403 .RS 4n
404 env_keep += "BASH_FUNC_my_func%%=()*"
405 .RE
406 .fi
407 .PP
408 Without the
409 \(lq\fR=()*\fR\(rq
410 suffix, this would not match, as
411 \fBbash\fR
412 shell functions are not preserved by default.
413 .PP
414 The complete list of environment variables that
415 \fBsudo\fR
416 allows or denies is contained in the output of
417 \(lq\fRsudo -V\fR\(rq
418 when run as root.
419 Please note that this list varies based on the operating system
420 \fBsudo\fR
421 is running on.
422 .PP
423 On systems that support PAM where the
424 \fBpam_env\fR
425 module is enabled for
426 \fBsudo\fR,
427 variables in the PAM environment may be merged in to the environment.
428 If a variable in the PAM environment is already present in the
429 user's environment, the value will only be overridden if the variable
430 was not preserved by
431 \fBsudoers\fR.
432 When
433 \fIenv_reset\fR
434 is enabled, variables preserved from the invoking user's environment
435 by the
436 \fIenv_keep\fR
437 list take precedence over those in the PAM environment.
438 When
439 \fIenv_reset\fR
440 is disabled, variables present the invoking user's environment
441 take precedence over those in the PAM environment unless they
442 match a pattern in the
443 \fIenv_delete\fR
444 list.
445 .PP
446 Note that the dynamic linker on most operating systems will remove
447 variables that can control dynamic linking from the environment of
448 setuid executables, including
449 \fBsudo\fR.
450 Depending on the operating
451 system this may include
452 \fR_RLD*\fR,
453 \fRDYLD_*\fR,
454 \fRLD_*\fR,
455 \fRLDR_*\fR,
456 \fRLIBPATH\fR,
457 \fRSHLIB_PATH\fR,
458 and others.
459 These type of variables are
460 removed from the environment before
461 \fBsudo\fR
462 even begins execution
463 and, as such, it is not possible for
464 \fBsudo\fR
465 to preserve them.
466 .PP
467 As a special case, if
468 \fBsudo\fR's
469 \fB\-i\fR
470 option (initial login) is
471 specified,
472 \fBsudoers\fR
473 will initialize the environment regardless
474 of the value of
475 \fIenv_reset\fR.
476 The
477 \fRDISPLAY\fR,
478 \fRPATH\fR
479 and
480 \fRTERM\fR
481 variables remain unchanged;
482 \fRHOME\fR,
483 \fRMAIL\fR,
484 \fRSHELL\fR,
485 \fRUSER\fR,
486 and
487 \fRLOGNAME\fR
488 are set based on the target user.
489 On AIX (and Linux
490 systems without PAM), the contents of
491 \fI/etc/environment\fR
492 are also
493 included.
494 .if \n(LC \{\
495 On
496 BSD
497 systems, if the
498 \fIuse_loginclass\fR
499 flag is
500 enabled, the
501 \fIpath\fR
502 and
503 \fIsetenv\fR
504 variables in
505 \fI/etc/login.conf\fR
506 are also applied.
507 .\}
508 All other environment variables are removed unless permitted by
509 \fIenv_keep\fR
510 or
511 \fIenv_check\fR,
512 described above.
513 .PP
514 Finally, the
515 \fIrestricted_env_file\fR
516 and
517 \fIenv_file\fR
518 files are applied, if present.
519 The variables in
520 \fIrestricted_env_file\fR
521 are applied first and are subject to the same restrictions as the
522 invoking user's environment, as detailed above.
523 The variables in
524 \fIenv_file\fR
525 are applied last and are not subject to these restrictions.
526 In both cases, variables present in the files will only be set to
527 their specified values if they would not conflict with an existing
528 environment variable.
529 .SH "SUDOERS FILE FORMAT"
530 The
531 \fIsudoers\fR
532 file is composed of two types of entries: aliases
533 (basically variables) and user specifications (which specify who
534 may run what).
535 .PP
536 When multiple entries match for a user, they are applied in order.
537 Where there are multiple matches, the last match is used (which is
538 not necessarily the most specific match).
539 .PP
540 The
541 \fIsudoers\fR
542 file grammar will be described below in Extended Backus-Naur
543 Form (EBNF).
544 Don't despair if you are unfamiliar with EBNF; it is fairly simple,
545 and the definitions below are annotated.
546 .SS "Quick guide to EBNF"
547 EBNF is a concise and exact way of describing the grammar of a language.
548 Each EBNF definition is made up of
549 \fIproduction rules\fR.
550 E.g.,
551 .PP
552 \fRsymbol ::= definition\fR | \fRalternate1\fR | \fRalternate2 ...\fR
553 .PP
554 Each
555 \fIproduction rule\fR
556 references others and thus makes up a
557 grammar for the language.
558 EBNF also contains the following
559 operators, which many readers will recognize from regular
560 expressions.
561 Do not, however, confuse them with
562 \(lqwildcard\(rq
563 characters, which have different meanings.
564 .TP 6n
565 \fR\&?\fR
566 Means that the preceding symbol (or group of symbols) is optional.
567 That is, it may appear once or not at all.
568 .TP 6n
569 \fR*\fR
570 Means that the preceding symbol (or group of symbols) may appear
571 zero or more times.
572 .TP 6n
573 \fR+\fR
574 Means that the preceding symbol (or group of symbols) may appear
575 one or more times.
576 .PP
577 Parentheses may be used to group symbols together.
578 For clarity,
579 we will use single quotes
580 ('')
581 to designate what is a verbatim character string (as opposed to a symbol name).
582 .SS "Aliases"
583 There are four kinds of aliases:
584 \fRUser_Alias\fR,
585 \fRRunas_Alias\fR,
586 \fRHost_Alias\fR
587 and
588 \fRCmnd_Alias\fR.
589 .nf
590 .sp
591 .RS 0n
592 Alias ::= 'User_Alias'  User_Alias_Spec (':' User_Alias_Spec)* |
593           'Runas_Alias' Runas_Alias_Spec (':' Runas_Alias_Spec)* |
594           'Host_Alias'  Host_Alias_Spec (':' Host_Alias_Spec)* |
595           'Cmnd_Alias'  Cmnd_Alias_Spec (':' Cmnd_Alias_Spec)*
596
597 User_Alias ::= NAME
598
599 User_Alias_Spec ::= User_Alias '=' User_List
600
601 Runas_Alias ::= NAME
602
603 Runas_Alias_Spec ::= Runas_Alias '=' Runas_List
604
605 Host_Alias ::= NAME
606
607 Host_Alias_Spec ::= Host_Alias '=' Host_List
608
609 Cmnd_Alias ::= NAME
610
611 Cmnd_Alias_Spec ::= Cmnd_Alias '=' Cmnd_List
612
613 NAME ::= [A-Z]([A-Z][0-9]_)*
614 .RE
615 .fi
616 .PP
617 Each
618 \fIalias\fR
619 definition is of the form
620 .nf
621 .sp
622 .RS 0n
623 Alias_Type NAME = item1, item2, ...
624 .RE
625 .fi
626 .PP
627 where
628 \fIAlias_Type\fR
629 is one of
630 \fRUser_Alias\fR,
631 \fRRunas_Alias\fR,
632 \fRHost_Alias\fR,
633 or
634 \fRCmnd_Alias\fR.
635 A
636 \fRNAME\fR
637 is a string of uppercase letters, numbers,
638 and underscore characters
639 (\(oq_\(cq).
640 A
641 \fRNAME\fR
642 \fBmust\fR
643 start with an
644 uppercase letter.
645 It is possible to put several alias definitions
646 of the same type on a single line, joined by a colon
647 (\(oq:\&\(cq).
648 E.g.,
649 .nf
650 .sp
651 .RS 0n
652 Alias_Type NAME = item1, item2, item3 : NAME = item4, item5
653 .RE
654 .fi
655 .PP
656 It is a syntax error to redefine an existing
657 \fIalias\fR.
658 It is possible to use the same name for
659 \fIaliases\fR
660 of different types, but this is not recommended.
661 .PP
662 The definitions of what constitutes a valid
663 \fIalias\fR
664 member follow.
665 .nf
666 .sp
667 .RS 0n
668 User_List ::= User |
669               User ',' User_List
670
671 User ::= '!'* user name |
672          '!'* #uid |
673          '!'* %group |
674          '!'* %#gid |
675          '!'* +netgroup |
676          '!'* %:nonunix_group |
677          '!'* %:#nonunix_gid |
678          '!'* User_Alias
679 .RE
680 .fi
681 .PP
682 A
683 \fRUser_List\fR
684 is made up of one or more user names, user IDs
685 (prefixed with
686 \(oq#\(cq),
687 system group names and IDs (prefixed with
688 \(oq%\(cq
689 and
690 \(oq%#\(cq
691 respectively), netgroups (prefixed with
692 \(oq+\(cq),
693 non-Unix group names and IDs (prefixed with
694 \(oq%:\(cq
695 and
696 \(oq%:#\(cq
697 respectively) and
698 \fRUser_Alias\fRes.
699 Each list item may be prefixed with zero or more
700 \(oq\&!\(cq
701 operators.
702 An odd number of
703 \(oq\&!\(cq
704 operators negate the value of
705 the item; an even number just cancel each other out.
706 User netgroups are matched using the user and domain members only;
707 the host member is not used when matching.
708 .PP
709 A
710 \fRuser name\fR,
711 \fRuid\fR,
712 \fRgroup\fR,
713 \fRgid\fR,
714 \fRnetgroup\fR,
715 \fRnonunix_group\fR
716 or
717 \fRnonunix_gid\fR
718 may be enclosed in double quotes to avoid the
719 need for escaping special characters.
720 Alternately, special characters
721 may be specified in escaped hex mode, e.g., \ex20 for space.
722 When
723 using double quotes, any prefix characters must be included inside
724 the quotes.
725 .PP
726 The actual
727 \fRnonunix_group\fR
728 and
729 \fRnonunix_gid\fR
730 syntax depends on
731 the underlying group provider plugin.
732 For instance, the QAS AD plugin supports the following formats:
733 .TP 3n
734 \fB\(bu\fR
735 Group in the same domain: "%:Group Name"
736 .TP 3n
737 \fB\(bu\fR
738 Group in any domain: "%:Group Name@FULLY.QUALIFIED.DOMAIN"
739 .TP 3n
740 \fB\(bu\fR
741 Group SID: "%:S-1-2-34-5678901234-5678901234-5678901234-567"
742 .PP
743 See
744 \fIGROUP PROVIDER PLUGINS\fR
745 for more information.
746 .PP
747 Note that quotes around group names are optional.
748 Unquoted strings must use a backslash
749 (\(oq\e\(cq)
750 to escape spaces and special characters.
751 See
752 \fIOther special characters and reserved words\fR
753 for a list of
754 characters that need to be escaped.
755 .nf
756 .sp
757 .RS 0n
758 Runas_List ::= Runas_Member |
759                Runas_Member ',' Runas_List
760
761 Runas_Member ::= '!'* user name |
762                  '!'* #uid |
763                  '!'* %group |
764                  '!'* %#gid |
765                  '!'* %:nonunix_group |
766                  '!'* %:#nonunix_gid |
767                  '!'* +netgroup |
768                  '!'* Runas_Alias
769 .RE
770 .fi
771 .PP
772 A
773 \fRRunas_List\fR
774 is similar to a
775 \fRUser_List\fR
776 except that instead
777 of
778 \fRUser_Alias\fRes
779 it can contain
780 \fRRunas_Alias\fRes.
781 Note that
782 user names and groups are matched as strings.
783 In other words, two
784 users (groups) with the same uid (gid) are considered to be distinct.
785 If you wish to match all user names with the same uid (e.g.,
786 root and toor), you can use a uid instead (#0 in the example given).
787 .nf
788 .sp
789 .RS 0n
790 Host_List ::= Host |
791               Host ',' Host_List
792
793 Host ::= '!'* host name |
794          '!'* ip_addr |
795          '!'* network(/netmask)? |
796          '!'* +netgroup |
797          '!'* Host_Alias
798 .RE
799 .fi
800 .PP
801 A
802 \fRHost_List\fR
803 is made up of one or more host names, IP addresses,
804 network numbers, netgroups (prefixed with
805 \(oq+\(cq)
806 and other aliases.
807 Again, the value of an item may be negated with the
808 \(oq\&!\(cq
809 operator.
810 Host netgroups are matched using the host (both qualified and unqualified)
811 and domain members only; the user member is not used when matching.
812 If you specify a network number without a netmask,
813 \fBsudo\fR
814 will query each of the local host's network interfaces and,
815 if the network number corresponds to one of the hosts's network
816 interfaces, will use the netmask of that interface.
817 The netmask may be specified either in standard IP address notation
818 (e.g., 255.255.255.0 or ffff:ffff:ffff:ffff::),
819 or CIDR notation (number of bits, e.g., 24 or 64).
820 A host name may include shell-style wildcards (see the
821 \fIWildcards\fR
822 section below),
823 but unless the
824 \fRhost name\fR
825 command on your machine returns the fully
826 qualified host name, you'll need to use the
827 \fIfqdn\fR
828 option for wildcards to be useful.
829 Note that
830 \fBsudo\fR
831 only inspects actual network interfaces; this means that IP address
832 127.0.0.1 (localhost) will never match.
833 Also, the host name
834 \(lqlocalhost\(rq
835 will only match if that is the actual host name, which is usually
836 only the case for non-networked systems.
837 .nf
838 .sp
839 .RS 0n
840 digest ::= [A-Fa-f0-9]+ |
841            [A-Za-z0-9\e+/=]+
842
843 Digest_Spec ::= "sha224" ':' digest |
844                 "sha256" ':' digest |
845                 "sha384" ':' digest |
846                 "sha512" ':' digest
847
848 Cmnd_List ::= Cmnd |
849               Cmnd ',' Cmnd_List
850
851 command name ::= file name |
852                  file name args |
853                  file name '""'
854
855 Cmnd ::= Digest_Spec? '!'* command name |
856          '!'* directory |
857          '!'* "sudoedit" |
858          '!'* Cmnd_Alias
859 .RE
860 .fi
861 .PP
862 A
863 \fRCmnd_List\fR
864 is a list of one or more command names, directories, and other aliases.
865 A command name is a fully qualified file name which may include
866 shell-style wildcards (see the
867 \fIWildcards\fR
868 section below).
869 A simple file name allows the user to run the command with any
870 arguments he/she wishes.
871 However, you may also specify command line arguments (including
872 wildcards).
873 Alternately, you can specify
874 \fR\&""\fR
875 to indicate that the command
876 may only be run
877 \fBwithout\fR
878 command line arguments.
879 A directory is a
880 fully qualified path name ending in a
881 \(oq/\(cq.
882 When you specify a directory in a
883 \fRCmnd_List\fR,
884 the user will be able to run any file within that directory
885 (but not in any sub-directories therein).
886 .PP
887 If a
888 \fRCmnd\fR
889 has associated command line arguments, then the arguments
890 in the
891 \fRCmnd\fR
892 must match exactly those given by the user on the command line
893 (or match the wildcards if there are any).
894 Note that the following characters must be escaped with a
895 \(oq\e\(cq
896 if they are used in command arguments:
897 \(oq,\&\(cq,
898 \(oq:\&\(cq,
899 \(oq=\&\(cq,
900 \(oq\e\(cq.
901 The built-in command
902 \(lq\fRsudoedit\fR\(rq
903 is used to permit a user to run
904 \fBsudo\fR
905 with the
906 \fB\-e\fR
907 option (or as
908 \fBsudoedit\fR).
909 It may take command line arguments just as a normal command does.
910 Note that
911 \(lq\fRsudoedit\fR\(rq
912 is a command built into
913 \fBsudo\fR
914 itself and must be specified in the
915 \fIsudoers\fR
916 file without a leading path.
917 .PP
918 If a
919 \fRcommand name\fR
920 is prefixed with a
921 \fRDigest_Spec\fR,
922 the command will only match successfully if it can be verified
923 using the specified SHA-2 digest.
924 The following digest formats are supported: sha224, sha256, sha384 and sha512.
925 The string may be specified in either hex or base64 format
926 (base64 is more compact).
927 There are several utilities capable of generating SHA-2 digests in hex
928 format such as openssl, shasum, sha224sum, sha256sum, sha384sum, sha512sum.
929 .PP
930 For example, using openssl:
931 .nf
932 .sp
933 .RS 0n
934 $ openssl dgst -sha224 /bin/ls
935 SHA224(/bin/ls)= 118187da8364d490b4a7debbf483004e8f3e053ec954309de2c41a25
936 .RE
937 .fi
938 .PP
939 It is also possible to use openssl to generate base64 output:
940 .nf
941 .sp
942 .RS 0n
943 $ openssl dgst -binary -sha224 /bin/ls | openssl base64
944 EYGH2oNk1JC0p9679IMATo8+BT7JVDCd4sQaJQ==
945 .RE
946 .fi
947 .PP
948 Warning, if the user has write access to the command itself (directly or via a
949 \fBsudo\fR
950 command), it may be possible for the user to replace the command after the
951 digest check has been performed but before the command is executed.
952 A similar race condition exists on systems that lack the
953 fexecve(2)
954 system call when the directory in which the command is located
955 is writable by the user.
956 See the description of the
957 \fIfdexec\fR
958 setting for more information on how
959 \fBsudo\fR
960 executes commands that have an associated digest.
961 .PP
962 Command digests are only supported by version 1.8.7 or higher.
963 .SS "Defaults"
964 Certain configuration options may be changed from their default
965 values at run-time via one or more
966 \fRDefault_Entry\fR
967 lines.
968 These may affect all users on any host, all users on a specific host, a
969 specific user, a specific command, or commands being run as a specific user.
970 Note that per-command entries may not include command line arguments.
971 If you need to specify arguments, define a
972 \fRCmnd_Alias\fR
973 and reference
974 that instead.
975 .nf
976 .sp
977 .RS 0n
978 Default_Type ::= 'Defaults' |
979                  'Defaults' '@' Host_List |
980                  'Defaults' ':' User_List |
981                  'Defaults' '!' Cmnd_List |
982                  'Defaults' '>' Runas_List
983
984 Default_Entry ::= Default_Type Parameter_List
985
986 Parameter_List ::= Parameter |
987                    Parameter ',' Parameter_List
988
989 Parameter ::= Parameter '=' Value |
990               Parameter '+=' Value |
991               Parameter '-=' Value |
992               '!'* Parameter
993 .RE
994 .fi
995 .PP
996 Parameters may be
997 \fBflags\fR,
998 \fBinteger\fR
999 values,
1000 \fBstrings\fR,
1001 or
1002 \fBlists\fR.
1003 Flags are implicitly boolean and can be turned off via the
1004 \(oq\&!\(cq
1005 operator.
1006 Some integer, string and list parameters may also be
1007 used in a boolean context to disable them.
1008 Values may be enclosed
1009 in double quotes
1010 (\&"")
1011 when they contain multiple words.
1012 Special characters may be escaped with a backslash
1013 (\(oq\e\(cq).
1014 .PP
1015 Lists have two additional assignment operators,
1016 \fR+=\fR
1017 and
1018 \fR-=\fR.
1019 These operators are used to add to and delete from a list respectively.
1020 It is not an error to use the
1021 \fR-=\fR
1022 operator to remove an element
1023 that does not exist in a list.
1024 .PP
1025 Defaults entries are parsed in the following order: generic, host,
1026 user and runas Defaults first, then command defaults.
1027 If there are multiple Defaults settings of the same type, the last
1028 matching setting is used.
1029 The following Defaults settings are parsed before all others since
1030 they may affect subsequent entries:
1031 \fIfqdn\fR,
1032 \fIgroup_plugin\fR,
1033 \fIrunas_default\fR,
1034 \fIsudoers_locale\fR.
1035 .PP
1036 See
1037 \fISUDOERS OPTIONS\fR
1038 for a list of supported Defaults parameters.
1039 .SS "User specification"
1040 .nf
1041 .RS 0n
1042 User_Spec ::= User_List Host_List '=' Cmnd_Spec_List \e
1043               (':' Host_List '=' Cmnd_Spec_List)*
1044
1045 Cmnd_Spec_List ::= Cmnd_Spec |
1046                    Cmnd_Spec ',' Cmnd_Spec_List
1047
1048 Cmnd_Spec ::= Runas_Spec? Option_Spec* Tag_Spec* Cmnd
1049
1050 Runas_Spec ::= '(' Runas_List? (':' Runas_List)? ')'
1051
1052 .ie \n(SL \{\
1053 .ie \n(PS Option_Spec ::= (SELinux_Spec | Solaris_Priv_Spec | Date_Spec | Timeout_Spec)
1054 .el Option_Spec ::= (SELinux_Spec | Date_Spec | Timeout_Spec)
1055 .\}
1056 .el \{\
1057 .ie \n(PS Option_Spec ::= (Solaris_Priv_Spec | Date_Spec | Timeout_Spec)
1058 .el Option_Spec ::= (Date_Spec | Timeout_Spec)
1059 .\}
1060
1061 .if \n(SL \{\
1062 SELinux_Spec ::= ('ROLE=role' | 'TYPE=type')
1063
1064 .\}
1065 .if \n(PS \{\
1066 Solaris_Priv_Spec ::= ('PRIVS=privset' | 'LIMITPRIVS=privset')
1067
1068 .\}
1069 Date_Spec ::= ('NOTBEFORE=timestamp' | 'NOTAFTER=timestamp')
1070
1071 Timeout_Spec ::= 'TIMEOUT=timeout'
1072
1073 Tag_Spec ::= ('EXEC:' | 'NOEXEC:' | 'FOLLOW:' | 'NOFOLLOW' |
1074               'LOG_INPUT:' | 'NOLOG_INPUT:' | 'LOG_OUTPUT:' |
1075               'NOLOG_OUTPUT:' | 'MAIL:' | 'NOMAIL:' | 'PASSWD:' |
1076               'NOPASSWD:' | 'SETENV:' | 'NOSETENV:')
1077 .RE
1078 .fi
1079 .PP
1080 A
1081 \fBuser specification\fR
1082 determines which commands a user may run
1083 (and as what user) on specified hosts.
1084 By default, commands are
1085 run as
1086 \fBroot\fR,
1087 but this can be changed on a per-command basis.
1088 .PP
1089 The basic structure of a user specification is
1090 \(lqwho where = (as_whom) what\(rq.
1091 Let's break that down into its constituent parts:
1092 .SS "Runas_Spec"
1093 A
1094 \fRRunas_Spec\fR
1095 determines the user and/or the group that a command
1096 may be run as.
1097 A fully-specified
1098 \fRRunas_Spec\fR
1099 consists of two
1100 \fRRunas_List\fRs
1101 (as defined above) separated by a colon
1102 (\(oq:\&\(cq)
1103 and enclosed in a set of parentheses.
1104 The first
1105 \fRRunas_List\fR
1106 indicates
1107 which users the command may be run as via
1108 \fBsudo\fR's
1109 \fB\-u\fR
1110 option.
1111 The second defines a list of groups that can be specified via
1112 \fBsudo\fR's
1113 \fB\-g\fR
1114 option in addition to any of the target user's groups.
1115 If both
1116 \fRRunas_List\fRs
1117 are specified, the command may be run with any combination of users
1118 and groups listed in their respective
1119 \fRRunas_List\fRs.
1120 If only the first is specified, the command may be run as any user
1121 in the list but no
1122 \fB\-g\fR
1123 option
1124 may be specified.
1125 If the first
1126 \fRRunas_List\fR
1127 is empty but the
1128 second is specified, the command may be run as the invoking user
1129 with the group set to any listed in the
1130 \fRRunas_List\fR.
1131 If both
1132 \fRRunas_List\fRs
1133 are empty, the command may only be run as the invoking user.
1134 If no
1135 \fRRunas_Spec\fR
1136 is specified the command may be run as
1137 \fBroot\fR
1138 and
1139 no group may be specified.
1140 .PP
1141 A
1142 \fRRunas_Spec\fR
1143 sets the default for the commands that follow it.
1144 What this means is that for the entry:
1145 .nf
1146 .sp
1147 .RS 0n
1148 dgb     boulder = (operator) /bin/ls, /bin/kill, /usr/bin/lprm
1149 .RE
1150 .fi
1151 .PP
1152 The user
1153 \fBdgb\fR
1154 may run
1155 \fI/bin/ls\fR,
1156 \fI/bin/kill\fR,
1157 and
1158 \fI/usr/bin/lprm\fR
1159 on the host
1160 boulder\(embut
1161 only as
1162 \fBoperator\fR.
1163 E.g.,
1164 .nf
1165 .sp
1166 .RS 0n
1167 $ sudo -u operator /bin/ls
1168 .RE
1169 .fi
1170 .PP
1171 It is also possible to override a
1172 \fRRunas_Spec\fR
1173 later on in an entry.
1174 If we modify the entry like so:
1175 .nf
1176 .sp
1177 .RS 0n
1178 dgb     boulder = (operator) /bin/ls, (root) /bin/kill, /usr/bin/lprm
1179 .RE
1180 .fi
1181 .PP
1182 Then user
1183 \fBdgb\fR
1184 is now allowed to run
1185 \fI/bin/ls\fR
1186 as
1187 \fBoperator\fR,
1188 but
1189 \fI/bin/kill\fR
1190 and
1191 \fI/usr/bin/lprm\fR
1192 as
1193 \fBroot\fR.
1194 .PP
1195 We can extend this to allow
1196 \fBdgb\fR
1197 to run
1198 \fR/bin/ls\fR
1199 with either
1200 the user or group set to
1201 \fBoperator\fR:
1202 .nf
1203 .sp
1204 .RS 0n
1205 dgb     boulder = (operator : operator) /bin/ls, (root) /bin/kill,\e
1206         /usr/bin/lprm
1207 .RE
1208 .fi
1209 .PP
1210 Note that while the group portion of the
1211 \fRRunas_Spec\fR
1212 permits the
1213 user to run as command with that group, it does not force the user
1214 to do so.
1215 If no group is specified on the command line, the command
1216 will run with the group listed in the target user's password database
1217 entry.
1218 The following would all be permitted by the sudoers entry above:
1219 .nf
1220 .sp
1221 .RS 0n
1222 $ sudo -u operator /bin/ls
1223 $ sudo -u operator -g operator /bin/ls
1224 $ sudo -g operator /bin/ls
1225 .RE
1226 .fi
1227 .PP
1228 In the following example, user
1229 \fBtcm\fR
1230 may run commands that access
1231 a modem device file with the dialer group.
1232 .nf
1233 .sp
1234 .RS 0n
1235 tcm     boulder = (:dialer) /usr/bin/tip, /usr/bin/cu,\e
1236         /usr/local/bin/minicom
1237 .RE
1238 .fi
1239 .PP
1240 Note that in this example only the group will be set, the command
1241 still runs as user
1242 \fBtcm\fR.
1243 E.g.\&
1244 .nf
1245 .sp
1246 .RS 0n
1247 $ sudo -g dialer /usr/bin/cu
1248 .RE
1249 .fi
1250 .PP
1251 Multiple users and groups may be present in a
1252 \fRRunas_Spec\fR,
1253 in which case the user may select any combination of users and groups via the
1254 \fB\-u\fR
1255 and
1256 \fB\-g\fR
1257 options.
1258 In this example:
1259 .nf
1260 .sp
1261 .RS 0n
1262 alan    ALL = (root, bin : operator, system) ALL
1263 .RE
1264 .fi
1265 .PP
1266 user
1267 \fBalan\fR
1268 may run any command as either user root or bin,
1269 optionally setting the group to operator or system.
1270 .SS "Option_Spec"
1271 A
1272 \fRCmnd\fR
1273 may have zero or more options associated with it.
1274 Options may consist of
1275 .if \n(SL \{\
1276 SELinux roles and/or types,
1277 .\}
1278 .if \n(PS \{\
1279 Solaris privileges sets,
1280 .\}
1281 start and/or end dates and command timeouts.
1282 Once an option is set for a
1283 \fRCmnd\fR,
1284 subsequent
1285 \fRCmnd\fRs
1286 in the
1287 \fRCmnd_Spec_List\fR,
1288 inherit that option unless it is overridden by another option.
1289 .if \n(SL \{\
1290 .SS "SELinux_Spec"
1291 On systems with SELinux support,
1292 \fIsudoers\fR
1293 file entries may optionally have an SELinux role and/or type associated
1294 with a command.
1295 If a role or
1296 type is specified with the command it will override any default values
1297 specified in
1298 \fIsudoers\fR.
1299 A role or type specified on the command line,
1300 however, will supersede the values in
1301 \fIsudoers\fR.
1302 .\}
1303 .if \n(PS \{\
1304 .SS "Solaris_Priv_Spec"
1305 On Solaris systems,
1306 \fIsudoers\fR
1307 file entries may optionally specify Solaris privilege set and/or limit
1308 privilege set associated with a command.
1309 If privileges or limit privileges are specified with the command
1310 it will override any default values specified in
1311 \fIsudoers\fR.
1312 .PP
1313 A privilege set is a comma-separated list of privilege names.
1314 The
1315 ppriv(1)
1316 command can be used to list all privileges known to the system.
1317 For example:
1318 .nf
1319 .sp
1320 .RS 0n
1321 $ ppriv -l
1322 .RE
1323 .fi
1324 .PP
1325 In addition, there are several
1326 \(lqspecial\(rq
1327 privilege strings:
1328 .TP 10n
1329 none
1330 the empty set
1331 .TP 10n
1332 all
1333 the set of all privileges
1334 .TP 10n
1335 zone
1336 the set of all privileges available in the current zone
1337 .TP 10n
1338 basic
1339 the default set of privileges normal users are granted at login time
1340 .PP
1341 Privileges can be excluded from a set by prefixing the privilege
1342 name with either an
1343 \(oq\&!\(cq
1344 or
1345 \(oq\-\(cq
1346 character.
1347 .\}
1348 .SS "Date_Spec"
1349 \fBsudoers\fR
1350 rules can be specified with a start and end date via the
1351 \fRNOTBEFORE\fR
1352 and
1353 \fRNOTAFTER\fR
1354 settings.
1355 The time stamp must be specified in
1356 \fIGeneralized Time\fR
1357 as defined by RFC 4517.
1358 The format is effectively
1359 \fRyyyymmddHHMMSSZ\fR
1360 where the minutes and seconds are optional.
1361 The
1362 \(oqZ\(cq
1363 suffix indicates that the time stamp is in Coordinated Universal Time (UTC).
1364 It is also possible to specify a timezone offset from UTC in hours
1365 and minutes instead of a
1366 \(oqZ\(cq.
1367 For example,
1368 \(oq-0500\(cq
1369 would correspond to Eastern Standard time in the US.
1370 As an extension, if no
1371 \(oqZ\(cq
1372 or timezone offset is specified, local time will be used.
1373 .PP
1374 The following are all valid time stamps:
1375 .nf
1376 .sp
1377 .RS 4n
1378 20170214083000Z
1379 2017021408Z
1380 20160315220000-0500
1381 20151201235900
1382 .RE
1383 .fi
1384 .SS "Timeout_Spec"
1385 A command may have a timeout associated with it.
1386 If the timeout expires before the command has exited, the
1387 command will be terminated.
1388 The timeout may be specified in combinations of days, hours,
1389 minutes and seconds with a single-letter case-insensitive suffix
1390 that indicates the unit of time.
1391 For example, a timeout of 7 days, 8 hours, 30 minutes and
1392 10 seconds would be written as
1393 \fR7d8h30m10s\fR.
1394 If a number is specified without a unit, seconds are assumed.
1395 Any of the days, minutes, hours or seconds may be omitted.
1396 The order must be from largest to smallest unit and a unit
1397 may not be specified more than once.
1398 .PP
1399 The following are all
1400 \fIvalid\fR
1401 timeout values:
1402 \fR7d8h30m10s\fR,
1403 \fR14d\fR,
1404 \fR8h30m\fR,
1405 \fR600s\fR,
1406 \fR3600\fR.
1407 The following are
1408 \fIinvalid\fR
1409 timeout values:
1410 \fR12m2w1d\fR,
1411 \fR30s10m4h\fR,
1412 \fR1d2d3h\fR.
1413 .PP
1414 This option is only supported by version 1.8.20 or higher.
1415 .SS "Tag_Spec"
1416 A command may have zero or more tags associated with it.
1417 The following tag values are supported:
1418 \fREXEC\fR,
1419 \fRNOEXEC\fR,
1420 \fRFOLLOW\fR,
1421 \fRNOFOLLOW\fR,
1422 \fRLOG_INPUT\fR,
1423 \fRNOLOG_INPUT\fR,
1424 \fRLOG_OUTPUT\fR,
1425 \fRNOLOG_OUTPUT\fR,
1426 \fRMAIL\fR,
1427 \fRNOMAIL\fR,
1428 \fRPASSWD\fR,
1429 \fRNOPASSWD\fR,
1430 \fRSETENV\fR,
1431 and
1432 \fRNOSETENV\fR.
1433 Once a tag is set on a
1434 \fRCmnd\fR,
1435 subsequent
1436 \fRCmnd\fRs
1437 in the
1438 \fRCmnd_Spec_List\fR,
1439 inherit the tag unless it is overridden by the opposite tag (in other words,
1440 \fRPASSWD\fR
1441 overrides
1442 \fRNOPASSWD\fR
1443 and
1444 \fRNOEXEC\fR
1445 overrides
1446 \fREXEC\fR).
1447 .TP 2n
1448 \fIEXEC\fR and \fINOEXEC\fR
1449 .sp
1450 If
1451 \fBsudo\fR
1452 has been compiled with
1453 \fInoexec\fR
1454 support and the underlying operating system supports it, the
1455 \fRNOEXEC\fR
1456 tag can be used to prevent a dynamically-linked executable from
1457 running further commands itself.
1458 .sp
1459 In the following example, user
1460 \fBaaron\fR
1461 may run
1462 \fI/usr/bin/more\fR
1463 and
1464 \fI/usr/bin/vi\fR
1465 but shell escapes will be disabled.
1466 .nf
1467 .sp
1468 .RS 2n
1469 aaron   shanty = NOEXEC: /usr/bin/more, /usr/bin/vi
1470 .RE
1471 .fi
1472 .RS 2n
1473 .sp
1474 See the
1475 \fIPreventing shell escapes\fR
1476 section below for more details on how
1477 \fRNOEXEC\fR
1478 works and whether or not it will work on your system.
1479 .RE
1480 .TP 2n
1481 \fIFOLLOW\fR and \fINOFOLLOW\fR
1482 Starting with version 1.8.15,
1483 \fBsudoedit\fR
1484 will not open a file that is a symbolic link unless the
1485 \fIsudoedit_follow\fR
1486 option is enabled.
1487 The
1488 \fIFOLLOW\fR
1489 and
1490 \fINOFOLLOW\fR
1491 tags override the value of
1492 \fIsudoedit_follow\fR
1493 and can be used to permit (or deny) the editing of symbolic links
1494 on a per-command basis.
1495 These tags are only effective for the
1496 \fIsudoedit\fR
1497 command and are ignored for all other commands.
1498 .TP 2n
1499 \fILOG_INPUT\fR and \fINOLOG_INPUT\fR
1500 .sp
1501 These tags override the value of the
1502 \fIlog_input\fR
1503 option on a per-command basis.
1504 For more information, see the description of
1505 \fIlog_input\fR
1506 in the
1507 \fISUDOERS OPTIONS\fR
1508 section below.
1509 .TP 2n
1510 \fILOG_OUTPUT\fR and \fINOLOG_OUTPUT\fR
1511 .sp
1512 These tags override the value of the
1513 \fIlog_output\fR
1514 option on a per-command basis.
1515 For more information, see the description of
1516 \fIlog_output\fR
1517 in the
1518 \fISUDOERS OPTIONS\fR
1519 section below.
1520 .TP 2n
1521 \fIMAIL\fR and \fINOMAIL\fR
1522 .sp
1523 These tags provide fine-grained control over whether
1524 mail will be sent when a user runs a command by
1525 overriding the value of the
1526 \fImail_all_cmnds\fR
1527 option on a per-command basis.
1528 They have no effect when
1529 \fBsudo\fR
1530 is run with the
1531 \fB\-l\fR
1532 or
1533 \fB\-v\fR
1534 options.
1535 A
1536 \fINOMAIL\fR
1537 tag will also override the
1538 \fImail_always\fR
1539 and
1540 \fImail_no_perms\fR
1541 options.
1542 For more information, see the descriptions of
1543 \fImail_all_cmnds\fR,
1544 \fImail_always\fR,
1545 and
1546 \fImail_no_perms\fR
1547 in the
1548 \fISUDOERS OPTIONS\fR
1549 section below.
1550 .TP 2n
1551 \fIPASSWD\fR and \fINOPASSWD\fR
1552 .sp
1553 By default,
1554 \fBsudo\fR
1555 requires that a user authenticate him or herself
1556 before running a command.
1557 This behavior can be modified via the
1558 \fRNOPASSWD\fR
1559 tag.
1560 Like a
1561 \fRRunas_Spec\fR,
1562 the
1563 \fRNOPASSWD\fR
1564 tag sets
1565 a default for the commands that follow it in the
1566 \fRCmnd_Spec_List\fR.
1567 Conversely, the
1568 \fRPASSWD\fR
1569 tag can be used to reverse things.
1570 For example:
1571 .nf
1572 .sp
1573 .RS 2n
1574 ray     rushmore = NOPASSWD: /bin/kill, /bin/ls, /usr/bin/lprm
1575 .RE
1576 .fi
1577 .RS 2n
1578 .sp
1579 would allow the user
1580 \fBray\fR
1581 to run
1582 \fI/bin/kill\fR,
1583 \fI/bin/ls\fR,
1584 and
1585 \fI/usr/bin/lprm\fR
1586 as
1587 \fBroot\fR
1588 on the machine rushmore without authenticating himself.
1589 If we only want
1590 \fBray\fR
1591 to be able to
1592 run
1593 \fI/bin/kill\fR
1594 without a password the entry would be:
1595 .nf
1596 .sp
1597 .RS 2n
1598 ray     rushmore = NOPASSWD: /bin/kill, PASSWD: /bin/ls, /usr/bin/lprm
1599 .RE
1600 .fi
1601 .sp
1602 Note, however, that the
1603 \fRPASSWD\fR
1604 tag has no effect on users who are in the group specified by the
1605 \fIexempt_group\fR
1606 option.
1607 .sp
1608 By default, if the
1609 \fRNOPASSWD\fR
1610 tag is applied to any of the entries for a user on the current host,
1611 he or she will be able to run
1612 \(lq\fRsudo -l\fR\(rq
1613 without a password.
1614 Additionally, a user may only run
1615 \(lq\fRsudo -v\fR\(rq
1616 without a password if the
1617 \fRNOPASSWD\fR
1618 tag is present for all a user's entries that pertain to the current host.
1619 This behavior may be overridden via the
1620 \fIverifypw\fR
1621 and
1622 \fIlistpw\fR
1623 options.
1624 .RE
1625 .TP 2n
1626 \fISETENV\fR and \fINOSETENV\fR
1627 .sp
1628 These tags override the value of the
1629 \fIsetenv\fR
1630 option on a per-command basis.
1631 Note that if
1632 \fRSETENV\fR
1633 has been set for a command, the user may disable the
1634 \fIenv_reset\fR
1635 option from the command line via the
1636 \fB\-E\fR
1637 option.
1638 Additionally, environment variables set on the command
1639 line are not subject to the restrictions imposed by
1640 \fIenv_check\fR,
1641 \fIenv_delete\fR,
1642 or
1643 \fIenv_keep\fR.
1644 As such, only trusted users should be allowed to set variables in this manner.
1645 If the command matched is
1646 \fBALL\fR,
1647 the
1648 \fRSETENV\fR
1649 tag is implied for that command; this default may be overridden by use of the
1650 \fRNOSETENV\fR
1651 tag.
1652 .SS "Wildcards"
1653 \fBsudo\fR
1654 allows shell-style
1655 \fIwildcards\fR
1656 (aka meta or glob characters)
1657 to be used in host names, path names and command line arguments in the
1658 \fIsudoers\fR
1659 file.
1660 Wildcard matching is done via the
1661 glob(3)
1662 and
1663 fnmatch(3)
1664 functions as specified by
1665 IEEE Std 1003.1 (\(lqPOSIX.1\(rq).
1666 .TP 10n
1667 \fR*\fR
1668 Matches any set of zero or more characters (including white space).
1669 .TP 10n
1670 \fR\&?\fR
1671 Matches any single character (including white space).
1672 .TP 10n
1673 \fR[...]\fR
1674 Matches any character in the specified range.
1675 .TP 10n
1676 \fR[!...]\fR
1677 Matches any character
1678 \fInot\fR
1679 in the specified range.
1680 .TP 10n
1681 \fR\ex\fR
1682 For any character
1683 \(oqx\(cq,
1684 evaluates to
1685 \(oqx\(cq.
1686 This is used to escape special characters such as:
1687 \(oq*\(cq,
1688 \(oq\&?\(cq,
1689 \(oq[\&\(cq,
1690 and
1691 \(oq]\&\(cq.
1692 .PP
1693 \fBNote that these are not regular expressions.\fR
1694 Unlike a regular expression there is no way to match one or more
1695 characters within a range.
1696 .PP
1697 Character classes may be used if your system's
1698 glob(3)
1699 and
1700 fnmatch(3)
1701 functions support them.
1702 However, because the
1703 \(oq:\&\(cq
1704 character has special meaning in
1705 \fIsudoers\fR,
1706 it must be
1707 escaped.
1708 For example:
1709 .nf
1710 .sp
1711 .RS 4n
1712 /bin/ls [[\e:\&alpha\e:\&]]*
1713 .RE
1714 .fi
1715 .PP
1716 Would match any file name beginning with a letter.
1717 .PP
1718 Note that a forward slash
1719 (\(oq/\(cq)
1720 will
1721 \fInot\fR
1722 be matched by
1723 wildcards used in the file name portion of the command.
1724 This is to make a path like:
1725 .nf
1726 .sp
1727 .RS 4n
1728 /usr/bin/*
1729 .RE
1730 .fi
1731 .PP
1732 match
1733 \fI/usr/bin/who\fR
1734 but not
1735 \fI/usr/bin/X11/xterm\fR.
1736 .PP
1737 When matching the command line arguments, however, a slash
1738 \fIdoes\fR
1739 get matched by wildcards since command line arguments may contain
1740 arbitrary strings and not just path names.
1741 .PP
1742 \fBWildcards in command line arguments should be used with care.\fR
1743 .br
1744 Command line arguments are matched as a single, concatenated string.
1745 This mean a wildcard character such as
1746 \(oq\&?\(cq
1747 or
1748 \(oq*\(cq
1749 will match across word boundaries, which may be unexpected.
1750 For example, while a sudoers entry like:
1751 .nf
1752 .sp
1753 .RS 4n
1754 %operator ALL = /bin/cat /var/log/messages*
1755 .RE
1756 .fi
1757 .PP
1758 will allow command like:
1759 .nf
1760 .sp
1761 .RS 4n
1762 $ sudo cat /var/log/messages.1
1763 .RE
1764 .fi
1765 .PP
1766 It will also allow:
1767 .nf
1768 .sp
1769 .RS 4n
1770 $ sudo cat /var/log/messages /etc/shadow
1771 .RE
1772 .fi
1773 .PP
1774 which is probably not what was intended.
1775 In most cases it is better to do command line processing
1776 outside of the
1777 \fIsudoers\fR
1778 file in a scripting language.
1779 .SS "Exceptions to wildcard rules"
1780 The following exceptions apply to the above rules:
1781 .TP 10n
1782 \fR\&""\fR
1783 If the empty string
1784 \fR\&""\fR
1785 is the only command line argument in the
1786 \fIsudoers\fR
1787 file entry it means that command is not allowed to be run with
1788 \fIany\fR
1789 arguments.
1790 .TP 10n
1791 sudoedit
1792 Command line arguments to the
1793 \fIsudoedit\fR
1794 built-in command should always be path names, so a forward slash
1795 (\(oq/\(cq)
1796 will not be matched by a wildcard.
1797 .SS "Including other files from within sudoers"
1798 It is possible to include other
1799 \fIsudoers\fR
1800 files from within the
1801 \fIsudoers\fR
1802 file currently being parsed using the
1803 \fR#include\fR
1804 and
1805 \fR#includedir\fR
1806 directives.
1807 .PP
1808 This can be used, for example, to keep a site-wide
1809 \fIsudoers\fR
1810 file in addition to a local, per-machine file.
1811 For the sake of this example the site-wide
1812 \fIsudoers\fR
1813 file will be
1814 \fI/etc/sudoers\fR
1815 and the per-machine one will be
1816 \fI/etc/sudoers.local\fR.
1817 To include
1818 \fI/etc/sudoers.local\fR
1819 from within
1820 \fI/etc/sudoers\fR
1821 we would use the
1822 following line in
1823 \fI/etc/sudoers\fR:
1824 .nf
1825 .sp
1826 .RS 4n
1827 #include /etc/sudoers.local
1828 .RE
1829 .fi
1830 .PP
1831 When
1832 \fBsudo\fR
1833 reaches this line it will suspend processing of the current file
1834 (\fI/etc/sudoers\fR)
1835 and switch to
1836 \fI/etc/sudoers.local\fR.
1837 Upon reaching the end of
1838 \fI/etc/sudoers.local\fR,
1839 the rest of
1840 \fI/etc/sudoers\fR
1841 will be processed.
1842 Files that are included may themselves include other files.
1843 A hard limit of 128 nested include files is enforced to prevent include
1844 file loops.
1845 .PP
1846 If the path to the include file is not fully-qualified (does not
1847 begin with a
1848 \(oq/\(cq),
1849 it must be located in the same directory as the sudoers file it was
1850 included from.
1851 For example, if
1852 \fI/etc/sudoers\fR
1853 contains the line:
1854 .nf
1855 .sp
1856 .RS 4n
1857 \fR#include sudoers.local\fR
1858 .RE
1859 .fi
1860 .PP
1861 the file that will be included is
1862 \fI/etc/sudoers.local\fR.
1863 .PP
1864 The file name may also include the
1865 \fR%h\fR
1866 escape, signifying the short form of the host name.
1867 In other words, if the machine's host name is
1868 \(lqxerxes\(rq,
1869 then
1870 .nf
1871 .sp
1872 .RS 4n
1873 #include /etc/sudoers.%h
1874 .RE
1875 .fi
1876 .PP
1877 will cause
1878 \fBsudo\fR
1879 to include the file
1880 \fI/etc/sudoers.xerxes\fR.
1881 .PP
1882 The
1883 \fR#includedir\fR
1884 directive can be used to create a
1885 \fIsudoers.d\fR
1886 directory that the system package manager can drop
1887 \fIsudoers\fR
1888 file rules into as part of package installation.
1889 For example, given:
1890 .nf
1891 .sp
1892 .RS 4n
1893 #includedir /etc/sudoers.d
1894 .RE
1895 .fi
1896 .PP
1897 \fBsudo\fR
1898 will suspend processing of the current file and read each file in
1899 \fI/etc/sudoers.d\fR,
1900 skipping file names that end in
1901 \(oq~\(cq
1902 or contain a
1903 \(oq.\&\(cq
1904 character to avoid causing problems with package manager or editor
1905 temporary/backup files.
1906 Files are parsed in sorted lexical order.
1907 That is,
1908 \fI/etc/sudoers.d/01_first\fR
1909 will be parsed before
1910 \fI/etc/sudoers.d/10_second\fR.
1911 Be aware that because the sorting is lexical, not numeric,
1912 \fI/etc/sudoers.d/1_whoops\fR
1913 would be loaded
1914 \fIafter\fR
1915 \fI/etc/sudoers.d/10_second\fR.
1916 Using a consistent number of leading zeroes in the file names can be used
1917 to avoid such problems.
1918 After parsing the files in the directory, control returns to the
1919 file that contained the
1920 \fR#includedir\fR
1921 directive.
1922 .PP
1923 Note that unlike files included via
1924 \fR#include\fR,
1925 \fBvisudo\fR
1926 will not edit the files in a
1927 \fR#includedir\fR
1928 directory unless one of them contains a syntax error.
1929 It is still possible to run
1930 \fBvisudo\fR
1931 with the
1932 \fB\-f\fR
1933 flag to edit the files directly, but this will not catch the
1934 redefinition of an
1935 \fIalias\fR
1936 that is also present in a different file.
1937 .SS "Other special characters and reserved words"
1938 The pound sign
1939 (\(oq#\(cq)
1940 is used to indicate a comment (unless it is part of a #include
1941 directive or unless it occurs in the context of a user name and is
1942 followed by one or more digits, in which case it is treated as a
1943 uid).
1944 Both the comment character and any text after it, up to the end of
1945 the line, are ignored.
1946 .PP
1947 The reserved word
1948 \fBALL\fR
1949 is a built-in
1950 \fIalias\fR
1951 that always causes a match to succeed.
1952 It can be used wherever one might otherwise use a
1953 \fRCmnd_Alias\fR,
1954 \fRUser_Alias\fR,
1955 \fRRunas_Alias\fR,
1956 or
1957 \fRHost_Alias\fR.
1958 You should not try to define your own
1959 \fIalias\fR
1960 called
1961 \fBALL\fR
1962 as the built-in alias will be used in preference to your own.
1963 Please note that using
1964 \fBALL\fR
1965 can be dangerous since in a command context, it allows the user to run
1966 \fIany\fR
1967 command on the system.
1968 .PP
1969 An exclamation point
1970 (\(oq\&!\(cq)
1971 can be used as a logical
1972 \fInot\fR
1973 operator in a list or
1974 \fIalias\fR
1975 as well as in front of a
1976 \fRCmnd\fR.
1977 This allows one to exclude certain values.
1978 For the
1979 \(oq\&!\(cq
1980 operator to be effective, there must be something for it to exclude.
1981 For example, to match all users except for root one would use:
1982 .nf
1983 .sp
1984 .RS 4n
1985 ALL,!root
1986 .RE
1987 .fi
1988 .PP
1989 If the
1990 \fBALL\fR,
1991 is omitted, as in:
1992 .nf
1993 .sp
1994 .RS 4n
1995 !root
1996 .RE
1997 .fi
1998 .PP
1999 it would explicitly deny root but not match any other users.
2000 This is different from a true
2001 \(lqnegation\(rq
2002 operator.
2003 .PP
2004 Note, however, that using a
2005 \(oq\&!\(cq
2006 in conjunction with the built-in
2007 \fBALL\fR
2008 alias to allow a user to run
2009 \(lqall but a few\(rq
2010 commands rarely works as intended (see
2011 \fISECURITY NOTES\fR
2012 below).
2013 .PP
2014 Long lines can be continued with a backslash
2015 (\(oq\e\(cq)
2016 as the last character on the line.
2017 .PP
2018 White space between elements in a list as well as special syntactic
2019 characters in a
2020 \fIUser Specification\fR
2021 (\(oq=\&\(cq,
2022 \(oq:\&\(cq,
2023 \(oq(\&\(cq,
2024 \(oq)\&\(cq)
2025 is optional.
2026 .PP
2027 The following characters must be escaped with a backslash
2028 (\(oq\e\(cq)
2029 when used as part of a word (e.g., a user name or host name):
2030 \(oq\&!\(cq,
2031 \(oq=\&\(cq,
2032 \(oq:\&\(cq,
2033 \(oq,\&\(cq,
2034 \(oq(\&\(cq,
2035 \(oq)\&\(cq,
2036 \(oq\e\(cq.
2037 .SH "SUDOERS OPTIONS"
2038 \fBsudo\fR's
2039 behavior can be modified by
2040 \fRDefault_Entry\fR
2041 lines, as explained earlier.
2042 A list of all supported Defaults parameters, grouped by type, are listed below.
2043 .PP
2044 \fBBoolean Flags\fR:
2045 .TP 18n
2046 always_query_group_plugin
2047 If a
2048 \fIgroup_plugin\fR
2049 is configured, use it to resolve groups of the form %group as long
2050 as there is not also a system group of the same name.
2051 Normally, only groups of the form %:group are passed to the
2052 \fIgroup_plugin\fR.
2053 This flag is
2054 \fIoff\fR
2055 by default.
2056 .TP 18n
2057 always_set_home
2058 If enabled,
2059 \fBsudo\fR
2060 will set the
2061 \fRHOME\fR
2062 environment variable to the home directory of the target user
2063 (which is root unless the
2064 \fB\-u\fR
2065 option is used).
2066 This effectively means that the
2067 \fB\-H\fR
2068 option is always implied.
2069 Note that by default,
2070 \fRHOME\fR
2071 will be set to the home directory of the target user when the
2072 \fIenv_reset\fR
2073 option is enabled, so
2074 \fIalways_set_home\fR
2075 only has an effect for configurations where either
2076 \fIenv_reset\fR
2077 is disabled or
2078 \fRHOME\fR
2079 is present in the
2080 \fIenv_keep\fR
2081 list.
2082 This flag is
2083 \fIoff\fR
2084 by default.
2085 .TP 18n
2086 authenticate
2087 If set, users must authenticate themselves via a password (or other
2088 means of authentication) before they may run commands.
2089 This default may be overridden via the
2090 \fRPASSWD\fR
2091 and
2092 \fRNOPASSWD\fR
2093 tags.
2094 This flag is
2095 \fIon\fR
2096 by default.
2097 .TP 18n
2098 case_insensitive_group
2099 If enabled, group names in
2100 \fIsudoers\fR
2101 will be matched in a case insensitive manner.
2102 This may be necessary when users are stored in LDAP or AD.
2103 This flag is
2104 \fIon\fR
2105 by default.
2106 .TP 18n
2107 case_insensitive_user
2108 If enabled, user names in
2109 \fIsudoers\fR
2110 will be matched in a case insensitive manner.
2111 This may be necessary when groups are stored in LDAP or AD.
2112 This flag is
2113 \fIon\fR
2114 by default.
2115 .TP 18n
2116 closefrom_override
2117 If set, the user may use
2118 \fBsudo\fR's
2119 \fB\-C\fR
2120 option which overrides the default starting point at which
2121 \fBsudo\fR
2122 begins closing open file descriptors.
2123 This flag is
2124 \fIoff\fR
2125 by default.
2126 .TP 18n
2127 compress_io
2128 If set, and
2129 \fBsudo\fR
2130 is configured to log a command's input or output,
2131 the I/O logs will be compressed using
2132 \fBzlib\fR.
2133 This flag is
2134 \fIon\fR
2135 by default when
2136 \fBsudo\fR
2137 is compiled with
2138 \fBzlib\fR
2139 support.
2140 .TP 18n
2141 exec_background
2142 By default,
2143 \fBsudo\fR
2144 runs a command as the foreground process as long as
2145 \fBsudo\fR
2146 itself is running in the foreground.
2147 When the
2148 \fIexec_background\fR
2149 flag is enabled and the command is being run in a pty (due to I/O logging
2150 or the
2151 \fIuse_pty\fR
2152 flag), the command will be run as a background process.
2153 Attempts to read from the controlling terminal (or to change terminal
2154 settings) will result in the command being suspended with the
2155 \fRSIGTTIN\fR
2156 signal (or
2157 \fRSIGTTOU\fR
2158 in the case of terminal settings).
2159 If this happens when
2160 \fBsudo\fR
2161 is a foreground process, the command will be granted the controlling terminal
2162 and resumed in the foreground with no user intervention required.
2163 The advantage of initially running the command in the background is that
2164 \fBsudo\fR
2165 need not read from the terminal unless the command explicitly requests it.
2166 Otherwise, any terminal input must be passed to the command, whether it
2167 has required it or not (the kernel buffers terminals so it is not possible
2168 to tell whether the command really wants the input).
2169 This is different from historic
2170 \fIsudo\fR
2171 behavior or when the command is not being run in a pty.
2172 .sp
2173 For this to work seamlessly, the operating system must support the
2174 automatic restarting of system calls.
2175 Unfortunately, not all operating systems do this by default,
2176 and even those that do may have bugs.
2177 For example, macOS fails to restart the
2178 \fBtcgetattr\fR()
2179 and
2180 \fBtcsetattr\fR()
2181 system calls (this is a bug in macOS).
2182 Furthermore, because this behavior depends on the command stopping with the
2183 \fRSIGTTIN\fR
2184 or
2185 \fRSIGTTOU\fR
2186 signals, programs that catch these signals and suspend themselves
2187 with a different signal (usually
2188 \fRSIGTOP\fR)
2189 will not be automatically foregrounded.
2190 Some versions of the linux
2191 su(1)
2192 command behave this way.
2193 This flag is
2194 \fIoff\fR
2195 by default.
2196 .sp
2197 This setting is only supported by version 1.8.7 or higher.
2198 It has no effect unless I/O logging is enabled or the
2199 \fIuse_pty\fR
2200 flag is enabled.
2201 .TP 18n
2202 env_editor
2203 If set,
2204 \fBvisudo\fR
2205 will use the value of the
2206 \fRSUDO_EDITOR\fR,
2207 \fRVISUAL\fR
2208 or
2209 \fREDITOR\fR
2210 environment variables before falling back on the default editor list.
2211 Note that this may create a security hole as it allows the user to
2212 run any arbitrary command as root without logging.
2213 A safer alternative is to place a colon-separated list of editors
2214 in the
2215 \fIeditor\fR
2216 variable.
2217 \fBvisudo\fR
2218 will then only use
2219 \fRSUDO_EDITOR\fR,
2220 \fRVISUAL\fR
2221 or
2222 \fREDITOR\fR
2223 if they match a value specified in
2224 \fIeditor\fR.
2225 If the
2226 \fIenv_reset\fR
2227 flag is enabled, the
2228 \fRSUDO_EDITOR\fR,
2229 \fRVISUAL\fR
2230 and/or
2231 \fREDITOR\fR
2232 environment variables must be present in the
2233 \fIenv_keep\fR
2234 list for the
2235 \fIenv_editor\fR
2236 flag to function when
2237 \fBvisudo\fR
2238 is invoked via
2239 \fBsudo\fR.
2240 This flag is
2241 \fI@env_editor@\fR
2242 by default.
2243 .TP 18n
2244 env_reset
2245 If set,
2246 \fBsudo\fR
2247 will run the command in a minimal environment containing the
2248 \fRTERM\fR,
2249 \fRPATH\fR,
2250 \fRHOME\fR,
2251 \fRMAIL\fR,
2252 \fRSHELL\fR,
2253 \fRLOGNAME\fR,
2254 \fRUSER\fR
2255 and
2256 \fRSUDO_*\fR
2257 variables.
2258 Any variables in the caller's environment or in the file specified
2259 by the
2260 \fIrestricted_env_file\fR
2261 option that match the
2262 \fRenv_keep\fR
2263 and
2264 \fRenv_check\fR
2265 lists are then added, followed by any variables present in the file
2266 specified by the
2267 \fIenv_file\fR
2268 option (if any).
2269 The contents of the
2270 \fRenv_keep\fR
2271 and
2272 \fRenv_check\fR
2273 lists, as modified by global Defaults parameters in
2274 \fIsudoers\fR,
2275 are displayed when
2276 \fBsudo\fR
2277 is run by root with the
2278 \fB\-V\fR
2279 option.
2280 If the
2281 \fIsecure_path\fR
2282 option is set, its value will be used for the
2283 \fRPATH\fR
2284 environment variable.
2285 This flag is
2286 \fI@env_reset@\fR
2287 by default.
2288 .TP 18n
2289 fast_glob
2290 Normally,
2291 \fBsudo\fR
2292 uses the
2293 glob(3)
2294 function to do shell-style globbing when matching path names.
2295 However, since it accesses the file system,
2296 glob(3)
2297 can take a long time to complete for some patterns, especially
2298 when the pattern references a network file system that is mounted
2299 on demand (auto mounted).
2300 The
2301 \fIfast_glob\fR
2302 option causes
2303 \fBsudo\fR
2304 to use the
2305 fnmatch(3)
2306 function, which does not access the file system to do its matching.
2307 The disadvantage of
2308 \fIfast_glob\fR
2309 is that it is unable to match relative path names such as
2310 \fI./ls\fR
2311 or
2312 \fI../bin/ls\fR.
2313 This has security implications when path names that include globbing
2314 characters are used with the negation operator,
2315 \(oq!\&\(cq,
2316 as such rules can be trivially bypassed.
2317 As such, this option should not be used when the
2318 \fIsudoers\fR
2319 file contains rules that contain negated path names which include globbing
2320 characters.
2321 This flag is
2322 \fIoff\fR
2323 by default.
2324 .TP 18n
2325 fqdn
2326 Set this flag if you want to put fully qualified host names in the
2327 \fIsudoers\fR
2328 file when the local host name (as returned by the
2329 \fRhostname\fR
2330 command) does not contain the domain name.
2331 In other words, instead of myhost you would use myhost.mydomain.edu.
2332 You may still use the short form if you wish (and even mix the two).
2333 This option is only effective when the
2334 \(lqcanonical\(rq
2335 host name, as returned by the
2336 \fBgetaddrinfo\fR()
2337 or
2338 \fBgethostbyname\fR()
2339 function, is a fully-qualified domain name.
2340 This is usually the case when the system is configured to use DNS
2341 for host name resolution.
2342 .sp
2343 If the system is configured to use the
2344 \fI/etc/hosts\fR
2345 file in preference to DNS, the
2346 \(lqcanonical\(rq
2347 host name may not be fully-qualified.
2348 The order that sources are queried for host name resolution
2349 is usually specified in the
2350 \fI@nsswitch_conf@\fR,
2351 \fI@netsvc_conf@\fR,
2352 \fI/etc/host.conf\fR,
2353 or, in some cases,
2354 \fI/etc/resolv.conf\fR
2355 file.
2356 In the
2357 \fI/etc/hosts\fR
2358 file, the first host name of the entry is considered to be the
2359 \(lqcanonical\(rq
2360 name; subsequent names are aliases that are not used by
2361 \fBsudoers\fR.
2362 For example, the following hosts file line for the machine
2363 \(lqxyzzy\(rq
2364 has the fully-qualified domain name as the
2365 \(lqcanonical\(rq
2366 host name, and the short version as an alias.
2367 .sp
2368 .RS 24n
2369 192.168.1.1 xyzzy.sudo.ws xyzzy
2370 .RE
2371 .RS 18n
2372 .sp
2373 If the machine's hosts file entry is not formatted properly, the
2374 \fIfqdn\fR
2375 option will not be effective if it is queried before DNS.
2376 .sp
2377 Beware that when using DNS for host name resolution, turning on
2378 \fIfqdn\fR
2379 requires
2380 \fBsudoers\fR
2381 to make DNS lookups which renders
2382 \fBsudo\fR
2383 unusable if DNS stops working (for example if the machine is disconnected
2384 from the network).
2385 Also note that just like with the hosts file, you must use the
2386 \(lqcanonical\(rq
2387 name as DNS knows it.
2388 That is, you may not use a host alias
2389 (\fRCNAME\fR
2390 entry)
2391 due to performance issues and the fact that there is no way to get all
2392 aliases from DNS.
2393 .sp
2394 This flag is
2395 \fI@fqdn@\fR
2396 by default.
2397 .RE
2398 .TP 18n
2399 ignore_audit_errors
2400 Allow commands to be run even if
2401 \fBsudoers\fR
2402 cannot write to the audit log.
2403 If enabled, an audit log write failure is not treated as a fatal error.
2404 If disabled, a command may only be run after the audit event is successfully
2405 written.
2406 This flag is only effective on systems for which
2407 \fBsudoers\fR
2408 supports audit logging, including
2409 FreeBSD,
2410 Linux, macOS and Solaris.
2411 This flag is
2412 \fIon\fR
2413 by default.
2414 .TP 18n
2415 ignore_dot
2416 If set,
2417 \fBsudo\fR
2418 will ignore "." or "" (both denoting current directory) in the
2419 \fRPATH\fR
2420 environment variable; the
2421 \fRPATH\fR
2422 itself is not modified.
2423 This flag is
2424 \fI@ignore_dot@\fR
2425 by default.
2426 .TP 18n
2427 ignore_iolog_errors
2428 Allow commands to be run even if
2429 \fBsudoers\fR
2430 cannot write to the I/O log.
2431 If enabled, an I/O log write failure is not treated as a fatal error.
2432 If disabled, the command will be terminated if the I/O log cannot be written to.
2433 This flag is
2434 \fIoff\fR
2435 by default.
2436 .TP 18n
2437 ignore_logfile_errors
2438 Allow commands to be run even if
2439 \fBsudoers\fR
2440 cannot write to the log file.
2441 If enabled, a log file write failure is not treated as a fatal error.
2442 If disabled, a command may only be run after the log file entry is successfully
2443 written.
2444 This flag only has an effect when
2445 \fBsudoers\fR
2446 is configured to use file-based logging via the
2447 \fIlogfile\fR
2448 option.
2449 This flag is
2450 \fIon\fR
2451 by default.
2452 .TP 18n
2453 ignore_local_sudoers
2454 If set via LDAP, parsing of
2455 \fI@sysconfdir@/sudoers\fR
2456 will be skipped.
2457 This is intended for Enterprises that wish to prevent the usage of local
2458 sudoers files so that only LDAP is used.
2459 This thwarts the efforts of rogue operators who would attempt to add roles to
2460 \fI@sysconfdir@/sudoers\fR.
2461 When this option is present,
2462 \fI@sysconfdir@/sudoers\fR
2463 does not even need to exist.
2464 Since this option tells
2465 \fBsudo\fR
2466 how to behave when no specific LDAP entries have been matched, this
2467 sudoOption is only meaningful for the
2468 \fRcn=defaults\fR
2469 section.
2470 This flag is
2471 \fIoff\fR
2472 by default.
2473 .TP 18n
2474 ignore_unknown_defaults
2475 If set,
2476 \fBsudo\fR
2477 will not produce a warning if it encounters an unknown Defaults entry
2478 in the
2479 \fIsudoers\fR
2480 file or an unknown sudoOption in LDAP.
2481 This flag is
2482 \fIoff\fR
2483 by default.
2484 .TP 18n
2485 insults
2486 If set,
2487 \fBsudo\fR
2488 will insult users when they enter an incorrect password.
2489 This flag is
2490 \fI@insults@\fR
2491 by default.
2492 .TP 18n
2493 log_host
2494 If set, the host name will be logged in the (non-syslog)
2495 \fBsudo\fR
2496 log file.
2497 This flag is
2498 \fIoff\fR
2499 by default.
2500 .TP 18n
2501 log_input
2502 If set,
2503 \fBsudo\fR
2504 will run the command in a pseudo-tty and log all user input.
2505 If the standard input is not connected to the user's tty, due to
2506 I/O redirection or because the command is part of a pipeline, that
2507 input is also captured and stored in a separate log file.
2508 Anything sent to the standard input will be consumed, regardless of
2509 whether or not the command run via
2510 \fBsudo\fR
2511 is actually reading the standard input.
2512 This may have unexpected results when using
2513 \fBsudo\fR
2514 in a shell script that expects to process the standard input.
2515 For more information about I/O logging, see the
2516 \fII/O LOG FILES\fR
2517 section.
2518 This flag is
2519 \fIoff\fR
2520 by default.
2521 .TP 18n
2522 log_output
2523 If set,
2524 \fBsudo\fR
2525 will run the command in a pseudo-tty and log all output that is sent
2526 to the screen, similar to the
2527 script(1)
2528 command.
2529 For more information about I/O logging, see the
2530 \fII/O LOG FILES\fR
2531 section.
2532 This flag is
2533 \fIoff\fR
2534 by default.
2535 .TP 18n
2536 log_year
2537 If set, the four-digit year will be logged in the (non-syslog)
2538 \fBsudo\fR
2539 log file.
2540 This flag is
2541 \fIoff\fR
2542 by default.
2543 .TP 18n
2544 long_otp_prompt
2545 When validating with a One Time Password (OTP) scheme such as
2546 \fBS/Key\fR
2547 or
2548 \fBOPIE\fR,
2549 a two-line prompt is used to make it easier
2550 to cut and paste the challenge to a local window.
2551 It's not as pretty as the default but some people find it more convenient.
2552 This flag is
2553 \fI@long_otp_prompt@\fR
2554 by default.
2555 .TP 18n
2556 mail_all_cmnds
2557 Send mail to the
2558 \fImailto\fR
2559 user every time a user attempts to run a command via
2560 \fBsudo\fR
2561 (this includes
2562 \fBsudoedit\fR).
2563 No mail will be sent if the user runs
2564 \fBsudo\fR
2565 with the
2566 \fB\-l\fR
2567 or
2568 \fB\-v\fR
2569 option unless there is an authentication error and the
2570 \fImail_badpass\fR
2571 flag is also set.
2572 This flag is
2573 \fIoff\fR
2574 by default.
2575 .TP 18n
2576 mail_always
2577 Send mail to the
2578 \fImailto\fR
2579 user every time a user runs
2580 \fBsudo\fR.
2581 This flag is
2582 \fIoff\fR
2583 by default.
2584 .TP 18n
2585 mail_badpass
2586 Send mail to the
2587 \fImailto\fR
2588 user if the user running
2589 \fBsudo\fR
2590 does not enter the correct password.
2591 If the command the user is attempting to run is not permitted by
2592 \fBsudoers\fR
2593 and one of the
2594 \fImail_all_cmnds\fR,
2595 \fImail_always\fR,
2596 \fImail_no_host\fR,
2597 \fImail_no_perms\fR
2598 or
2599 \fImail_no_user\fR
2600 flags are set, this flag will have no effect.
2601 This flag is
2602 \fIoff\fR
2603 by default.
2604 .TP 18n
2605 mail_no_host
2606 If set, mail will be sent to the
2607 \fImailto\fR
2608 user if the invoking user exists in the
2609 \fIsudoers\fR
2610 file, but is not allowed to run commands on the current host.
2611 This flag is
2612 \fI@mail_no_host@\fR
2613 by default.
2614 .TP 18n
2615 mail_no_perms
2616 If set, mail will be sent to the
2617 \fImailto\fR
2618 user if the invoking user is allowed to use
2619 \fBsudo\fR
2620 but the command they are trying is not listed in their
2621 \fIsudoers\fR
2622 file entry or is explicitly denied.
2623 This flag is
2624 \fI@mail_no_perms@\fR
2625 by default.
2626 .TP 18n
2627 mail_no_user
2628 If set, mail will be sent to the
2629 \fImailto\fR
2630 user if the invoking user is not in the
2631 \fIsudoers\fR
2632 file.
2633 This flag is
2634 \fI@mail_no_user@\fR
2635 by default.
2636 .TP 18n
2637 match_group_by_gid
2638 By default,
2639 \fBsudoers\fR
2640 will look up each group the user is a member of by group ID to
2641 determine the group name (this is only done once).
2642 The resulting list of the user's group names is used when matching
2643 groups listed in the
2644 \fIsudoers\fR
2645 file.
2646 This works well on systems where the number of groups listed in the
2647 \fIsudoers\fR
2648 file is larger than the number of groups a typical user belongs to.
2649 On systems where group lookups are slow, where users may belong
2650 to a large number of groups, and where the number of groups listed
2651 in the
2652 \fIsudoers\fR
2653 file is relatively small, it may be prohibitively expensive and
2654 running commands via
2655 \fBsudo\fR
2656 may take longer than normal.
2657 On such systems it may be faster to use the
2658 \fImatch_group_by_gid\fR
2659 flag to avoid resolving the user's group IDs to group names.
2660 In this case,
2661 \fBsudoers\fR
2662 must look up any group name listed in the
2663 \fIsudoers\fR
2664 file and use the group ID instead of the group name when determining
2665 whether the user is a member of the group.
2666 .sp
2667 Note that if
2668 \fImatch_group_by_gid\fR
2669 is enabled, group database lookups performed by
2670 \fBsudoers\fR
2671 will be keyed by group name as opposed to group ID.
2672 On systems where there are multiple sources for the group database,
2673 it is possible to have conflicting group names or group IDs in the local
2674 \fI/etc/group\fR
2675 file and the remote group database.
2676 On such systems, enabling or disabling
2677 \fImatch_group_by_gid\fR
2678 can be used to choose whether group database queries are performed
2679 by name (enabled) or ID (disabled), which may aid in working around
2680 group entry conflicts.
2681 .sp
2682 The
2683 \fImatch_group_by_gid\fR
2684 flag has no effect when
2685 \fIsudoers\fR
2686 data is stored in LDAP.
2687 This flag is
2688 \fIoff\fR
2689 by default.
2690 .sp
2691 This setting is only supported by version 1.8.18 or higher.
2692 .TP 18n
2693 netgroup_tuple
2694 If set, netgroup lookups will be performed using the full netgroup
2695 tuple: host name, user name and domain (if one is set).
2696 Historically,
2697 \fBsudo\fR
2698 only matched the user name and domain for netgroups used in a
2699 \fRUser_List\fR
2700 and only matched the host name and domain for netgroups used in a
2701 \fRHost_List\fR.
2702 This flag is
2703 \fIoff\fR
2704 by default.
2705 .TP 18n
2706 noexec
2707 If set, all commands run via
2708 \fBsudo\fR
2709 will behave as if the
2710 \fRNOEXEC\fR
2711 tag has been set, unless overridden by an
2712 \fREXEC\fR
2713 tag.
2714 See the description of
2715 \fIEXEC and NOEXEC\fR
2716 above as well as the
2717 \fIPreventing shell escapes\fR
2718 section at the end of this manual.
2719 This flag is
2720 \fIoff\fR
2721 by default.
2722 .TP 18n
2723 pam_session
2724 On systems that use PAM for authentication,
2725 \fBsudo\fR
2726 will create a new PAM session for the command to be run in.
2727 Disabling
2728 \fIpam_session\fR
2729 may be needed on older PAM implementations or on operating systems where
2730 opening a PAM session changes the utmp or wtmp files.
2731 If PAM session support is disabled, resource limits may not be updated
2732 for the command being run.
2733 If
2734 \fIpam_session\fR,
2735 \fIpam_setcred\fR,
2736 and
2737 \fIuse_pty\fR
2738 are disabled and I/O logging has not been configured,
2739 \fBsudo\fR
2740 will execute the command directly instead of running it as a child
2741 process.
2742 This flag is
2743 \fI@pam_session@\fR
2744 by default.
2745 .sp
2746 This setting is only supported by version 1.8.7 or higher.
2747 .TP 18n
2748 pam_setcred
2749 On systems that use PAM for authentication,
2750 \fBsudo\fR
2751 will attempt to establish credentials for the target user by default,
2752 if supported by the underlying authentication system.
2753 One example of a credential is a Kerberos ticket.
2754 If
2755 \fIpam_session\fR,
2756 \fIpam_setcred\fR,
2757 and
2758 \fIuse_pty\fR
2759 are disabled and I/O logging has not been configured,
2760 \fBsudo\fR
2761 will execute the command directly instead of running it as a child
2762 process.
2763 This flag is
2764 \fIon\fR
2765 by default.
2766 .sp
2767 This setting is only supported by version 1.8.8 or higher.
2768 .TP 18n
2769 passprompt_override
2770 If set, the prompt specified by
2771 \fIpassprompt\fR
2772 or the
2773 \fRSUDO_PROMPT\fR
2774 environment variable will always be used and will replace the
2775 prompt provided by a PAM module or other authentication method.
2776 This flag is
2777 \fIoff\fR
2778 by default.
2779 .TP 18n
2780 path_info
2781 Normally,
2782 \fBsudo\fR
2783 will tell the user when a command could not be
2784 found in their
2785 \fRPATH\fR
2786 environment variable.
2787 Some sites may wish to disable this as it could be used to gather
2788 information on the location of executables that the normal user does
2789 not have access to.
2790 The disadvantage is that if the executable is simply not in the user's
2791 \fRPATH\fR,
2792 \fBsudo\fR
2793 will tell the user that they are not allowed to run it, which can be confusing.
2794 This flag is
2795 \fI@path_info@\fR
2796 by default.
2797 .TP 18n
2798 preserve_groups
2799 By default,
2800 \fBsudo\fR
2801 will initialize the group vector to the list of groups the target user is in.
2802 When
2803 \fIpreserve_groups\fR
2804 is set, the user's existing group vector is left unaltered.
2805 The real and effective group IDs, however, are still set to match the
2806 target user.
2807 This flag is
2808 \fIoff\fR
2809 by default.
2810 .TP 18n
2811 pwfeedback
2812 By default,
2813 \fBsudo\fR
2814 reads the password like most other Unix programs,
2815 by turning off echo until the user hits the return (or enter) key.
2816 Some users become confused by this as it appears to them that
2817 \fBsudo\fR
2818 has hung at this point.
2819 When
2820 \fIpwfeedback\fR
2821 is set,
2822 \fBsudo\fR
2823 will provide visual feedback when the user presses a key.
2824 Note that this does have a security impact as an onlooker may be able to
2825 determine the length of the password being entered.
2826 This flag is
2827 \fIoff\fR
2828 by default.
2829 .TP 18n
2830 requiretty
2831 If set,
2832 \fBsudo\fR
2833 will only run when the user is logged in to a real tty.
2834 When this flag is set,
2835 \fBsudo\fR
2836 can only be run from a login session and not via other means such as
2837 cron(@mansectsu@)
2838 or cgi-bin scripts.
2839 This flag is
2840 \fIoff\fR
2841 by default.
2842 .TP 18n
2843 root_sudo
2844 If set, root is allowed to run
2845 \fBsudo\fR
2846 too.
2847 Disabling this prevents users from
2848 \(lqchaining\(rq
2849 \fBsudo\fR
2850 commands to get a root shell by doing something like
2851 \(lq\fRsudo sudo /bin/sh\fR\(rq.
2852 Note, however, that turning off
2853 \fIroot_sudo\fR
2854 will also prevent root from running
2855 \fBsudoedit\fR.
2856 Disabling
2857 \fIroot_sudo\fR
2858 provides no real additional security; it exists purely for historical reasons.
2859 This flag is
2860 \fI@root_sudo@\fR
2861 by default.
2862 .TP 18n
2863 rootpw
2864 If set,
2865 \fBsudo\fR
2866 will prompt for the root password instead of the password of the invoking user
2867 when running a command or editing a file.
2868 This flag is
2869 \fIoff\fR
2870 by default.
2871 .TP 18n
2872 runaspw
2873 If set,
2874 \fBsudo\fR
2875 will prompt for the password of the user defined by the
2876 \fIrunas_default\fR
2877 option (defaults to
2878 \fR@runas_default@\fR)
2879 instead of the password of the invoking user
2880 when running a command or editing a file.
2881 This flag is
2882 \fIoff\fR
2883 by default.
2884 .TP 18n
2885 set_home
2886 If enabled and
2887 \fBsudo\fR
2888 is invoked with the
2889 \fB\-s\fR
2890 option the
2891 \fRHOME\fR
2892 environment variable will be set to the home directory of the target
2893 user (which is root unless the
2894 \fB\-u\fR
2895 option is used).
2896 This effectively makes the
2897 \fB\-s\fR
2898 option imply
2899 \fB\-H\fR.
2900 Note that
2901 \fRHOME\fR
2902 is already set when the
2903 \fIenv_reset\fR
2904 option is enabled, so
2905 \fIset_home\fR
2906 is only effective for configurations where either
2907 \fIenv_reset\fR
2908 is disabled
2909 or
2910 \fRHOME\fR
2911 is present in the
2912 \fIenv_keep\fR
2913 list.
2914 This flag is
2915 \fIoff\fR
2916 by default.
2917 .TP 18n
2918 set_logname
2919 Normally,
2920 \fBsudo\fR
2921 will set the
2922 \fRLOGNAME\fR
2923 and
2924 \fRUSER\fR
2925 environment variables to the name of the target user (usually root unless the
2926 \fB\-u\fR
2927 option is given).
2928 However, since some programs (including the RCS revision control system) use
2929 \fRLOGNAME\fR
2930 to determine the real identity of the user, it may be desirable to
2931 change this behavior.
2932 This can be done by negating the set_logname option.
2933 Note that
2934 \fIset_logname\fR
2935 will have no effect
2936 if the
2937 \fIenv_reset\fR
2938 option has not been disabled and the
2939 \fIenv_keep\fR
2940 list contains
2941 \fRLOGNAME\fR
2942 or
2943 \fRUSER\fR.
2944 This flag is
2945 \fIon\fR
2946 by default.
2947 .TP 18n
2948 set_utmp
2949 When enabled,
2950 \fBsudo\fR
2951 will create an entry in the utmp (or utmpx) file when a pseudo-tty
2952 is allocated.
2953 A pseudo-tty is allocated by
2954 \fBsudo\fR
2955 when the
2956 \fIlog_input\fR,
2957 \fIlog_output\fR
2958 or
2959 \fIuse_pty\fR
2960 flags are enabled.
2961 By default, the new entry will be a copy of the user's existing utmp
2962 entry (if any), with the tty, time, type and pid fields updated.
2963 This flag is
2964 \fIon\fR
2965 by default.
2966 .TP 18n
2967 setenv
2968 Allow the user to disable the
2969 \fIenv_reset\fR
2970 option from the command line via the
2971 \fB\-E\fR
2972 option.
2973 Additionally, environment variables set via the command line are
2974 not subject to the restrictions imposed by
2975 \fIenv_check\fR,
2976 \fIenv_delete\fR,
2977 or
2978 \fIenv_keep\fR.
2979 As such, only trusted users should be allowed to set variables in this manner.
2980 This flag is
2981 \fIoff\fR
2982 by default.
2983 .TP 18n
2984 shell_noargs
2985 If set and
2986 \fBsudo\fR
2987 is invoked with no arguments it acts as if the
2988 \fB\-s\fR
2989 option had been given.
2990 That is, it runs a shell as root (the shell is determined by the
2991 \fRSHELL\fR
2992 environment variable if it is set, falling back on the shell listed
2993 in the invoking user's /etc/passwd entry if not).
2994 This flag is
2995 \fIoff\fR
2996 by default.
2997 .TP 18n
2998 stay_setuid
2999 Normally, when
3000 \fBsudo\fR
3001 executes a command the real and effective UIDs are set to the target
3002 user (root by default).
3003 This option changes that behavior such that the real UID is left
3004 as the invoking user's UID.
3005 In other words, this makes
3006 \fBsudo\fR
3007 act as a setuid wrapper.
3008 This can be useful on systems that disable some potentially
3009 dangerous functionality when a program is run setuid.
3010 This option is only effective on systems that support either the
3011 setreuid(2)
3012 or
3013 setresuid(2)
3014 system call.
3015 This flag is
3016 \fIoff\fR
3017 by default.
3018 .TP 18n
3019 sudoedit_checkdir
3020 .br
3021 If set,
3022 \fBsudoedit\fR
3023 will check all directory components of the path to be edited for writability
3024 by the invoking user.
3025 Symbolic links will not be followed in writable directories and
3026 \fBsudoedit\fR
3027 will refuse to edit a file located in a writable directory.
3028 These restrictions are not enforced when
3029 \fBsudoedit\fR
3030 is run by root.
3031 On some systems, if all directory components of the path to be edited
3032 are not readable by the target user,
3033 \fBsudoedit\fR
3034 will be unable to edit the file.
3035 This flag is
3036 \fIon\fR
3037 by default.
3038 .sp
3039 This setting was first introduced in version 1.8.15 but initially
3040 suffered from a race condition.
3041 The check for symbolic links in writable intermediate directories
3042 was added in version 1.8.16.
3043 .TP 18n
3044 sudoedit_follow
3045 By default,
3046 \fBsudoedit\fR
3047 will not follow symbolic links when opening files.
3048 The
3049 \fIsudoedit_follow\fR
3050 option can be enabled to allow
3051 \fBsudoedit\fR
3052 to open symbolic links.
3053 It may be overridden on a per-command basis by the
3054 \fIFOLLOW\fR
3055 and
3056 \fINOFOLLOW\fR
3057 tags.
3058 This flag is
3059 \fIoff\fR
3060 by default.
3061 .sp
3062 This setting is only supported by version 1.8.15 or higher.
3063 .TP 18n
3064 syslog_pid
3065 When logging via
3066 syslog(3),
3067 include the process ID in the log entry.
3068 This flag is
3069 \fIoff\fR
3070 by default.
3071 .sp
3072 This setting is only supported by version 1.8.21 or higher.
3073 .TP 18n
3074 targetpw
3075 If set,
3076 \fBsudo\fR
3077 will prompt for the password of the user specified
3078 by the
3079 \fB\-u\fR
3080 option (defaults to
3081 \fRroot\fR)
3082 instead of the password of the invoking user
3083 when running a command or editing a file.
3084 Note that this flag precludes the use of a uid not listed in the passwd
3085 database as an argument to the
3086 \fB\-u\fR
3087 option.
3088 This flag is
3089 \fIoff\fR
3090 by default.
3091 .TP 18n
3092 tty_tickets
3093 If set, users must authenticate on a per-tty basis.
3094 With this flag enabled,
3095 \fBsudo\fR
3096 will use a separate record in the time stamp file for each terminal.
3097 If disabled, a single record is used for all login sessions.
3098 .sp
3099 This option has been superseded by the
3100 \fItimestamp_type\fR
3101 option.
3102 .TP 18n
3103 umask_override
3104 If set,
3105 \fBsudo\fR
3106 will set the umask as specified in the
3107 \fIsudoers\fR
3108 file without modification.
3109 This makes it possible to specify a umask in the
3110 \fIsudoers\fR
3111 file that is more permissive than the user's own umask and matches
3112 historical behavior.
3113 If
3114 \fIumask_override\fR
3115 is not set,
3116 \fBsudo\fR
3117 will set the umask to be the union of the user's umask and what is specified in
3118 \fIsudoers\fR.
3119 This flag is
3120 \fI@umask_override@\fR
3121 by default.
3122 .if \n(BA \{\
3123 .TP 18n
3124 use_loginclass
3125 If set,
3126 \fBsudo\fR
3127 will apply the defaults specified for the target user's login class
3128 if one exists.
3129 Only available if
3130 \fBsudo\fR
3131 is configured with the
3132 \fR--with-logincap\fR
3133 option.
3134 This flag is
3135 \fIoff\fR
3136 by default.
3137 .\}
3138 .TP 18n
3139 use_netgroups
3140 If set, netgroups (prefixed with
3141 \(oq+\(cq),
3142 may be used in place of a user or host.
3143 For LDAP-based sudoers, netgroup support requires an expensive
3144 sub-string match on the server unless the
3145 \fBNETGROUP_BASE\fR
3146 directive is present in the
3147 \fI@ldap_conf@\fR
3148 file.
3149 If netgroups are not needed, this option can be disabled to reduce the
3150 load on the LDAP server.
3151 This flag is
3152 \fIon\fR
3153 by default.
3154 .TP 18n
3155 use_pty
3156 If set, and
3157 \fBsudo\fR
3158 is running in a terminal, the command will be run in a pseudo-pty
3159 (even if no I/O logging is being done).
3160 If the
3161 \fBsudo\fR
3162 process is not attached to a terminal,
3163 \fIuse_pty\fR
3164 has no effect.
3165 .sp
3166 A malicious program run under
3167 \fBsudo\fR
3168 may be capable of injecting commands into the user's
3169 terminal or running a background process that retains access to the
3170 user's terminal device even after the main program has finished
3171 executing.
3172 By running the command in a separate pseudo-pty, this attack is
3173 no longer possible.
3174 This flag is
3175 \fIoff\fR
3176 by default.
3177 .TP 18n
3178 user_command_timeouts
3179 If set, the user may specify a timeout on the command line.
3180 If the timeout expires before the command has exited, the
3181 command will be terminated.
3182 If a timeout is specified both in the
3183 \fIsudoers\fR
3184 file and on the command line, the smaller of the two timeouts will be used.
3185 See the
3186 \fRTimeout_Spec\fR
3187 section for a description of the timeout syntax.
3188 This flag is
3189 \fIoff\fR
3190 by default.
3191 .sp
3192 This setting is only supported by version 1.8.20 or higher.
3193 .TP 18n
3194 utmp_runas
3195 If set,
3196 \fBsudo\fR
3197 will store the name of the runas user when updating the utmp (or utmpx) file.
3198 By default,
3199 \fBsudo\fR
3200 stores the name of the invoking user.
3201 This flag is
3202 \fIoff\fR
3203 by default.
3204 .TP 18n
3205 visiblepw
3206 By default,
3207 \fBsudo\fR
3208 will refuse to run if the user must enter a password but it is not
3209 possible to disable echo on the terminal.
3210 If the
3211 \fIvisiblepw\fR
3212 flag is set,
3213 \fBsudo\fR
3214 will prompt for a password even when it would be visible on the screen.
3215 This makes it possible to run things like
3216 \(lq\fRssh somehost sudo ls\fR\(rq
3217 since by default,
3218 ssh(1)
3219 does
3220 not allocate a tty when running a command.
3221 This flag is
3222 \fIoff\fR
3223 by default.
3224 .PP
3225 \fBIntegers\fR:
3226 .TP 18n
3227 closefrom
3228 Before it executes a command,
3229 \fBsudo\fR
3230 will close all open file descriptors other than standard input,
3231 standard output and standard error (ie: file descriptors 0-2).
3232 The
3233 \fIclosefrom\fR
3234 option can be used to specify a different file descriptor at which
3235 to start closing.
3236 The default is
3237 \fR3\fR.
3238 .TP 18n
3239 command_timeout
3240 The maximum amount of time a command is allowed to run before
3241 it is terminated.
3242 See the
3243 \fRTimeout_Spec\fR
3244 section for a description of the timeout syntax.
3245 .sp
3246 This setting is only supported by version 1.8.20 or higher.
3247 .TP 18n
3248 maxseq
3249 The maximum sequence number that will be substituted for the
3250 \(lq\fR%{seq}\fR\(rq
3251 escape in the I/O log file (see the
3252 \fIiolog_dir\fR
3253 description below for more information).
3254 While the value substituted for
3255 \(lq\fR%{seq}\fR\(rq
3256 is in base 36,
3257 \fImaxseq\fR
3258 itself should be expressed in decimal.
3259 Values larger than 2176782336 (which corresponds to the
3260 base 36 sequence number
3261 \(lqZZZZZZ\(rq)
3262 will be silently truncated to 2176782336.
3263 The default value is 2176782336.
3264 .sp
3265 Once the local sequence number reaches the value of
3266 \fImaxseq\fR,
3267 it will
3268 \(lqroll over\(rq
3269 to zero, after which
3270 \fBsudoers\fR
3271 will truncate and re-use any existing I/O log path names.
3272 .sp
3273 This setting is only supported by version 1.8.7 or higher.
3274 .TP 18n
3275 passwd_tries
3276 The number of tries a user gets to enter his/her password before
3277 \fBsudo\fR
3278 logs the failure and exits.
3279 The default is
3280 \fR@passwd_tries@\fR.
3281 .TP 18n
3282 syslog_maxlen
3283 On many systems,
3284 syslog(3)
3285 has a relatively small log buffer.
3286 IETF RFC 5424 states that syslog servers must support messages of
3287 at least 480 bytes and should support messages up to 2048 bytes.
3288 By default,
3289 \fBsudoers\fR
3290 creates log messages up to 980 bytes which corresponds to the
3291 historic
3292 BSD
3293 syslog implementation which used a 1024 byte buffer
3294 to store the message, date, hostname and program name.
3295 To prevent syslog messages from being truncated,
3296 \fBsudoers\fR
3297 will split up log messages that are larger than
3298 \fIsyslog_maxlen\fR
3299 bytes.
3300 When a message is split, additional parts will include the string
3301 \(lq(command continued)\(rq
3302 after the user name and before the continued command line arguments.
3303 .sp
3304 This setting is only supported by version 1.8.19 or higher.
3305 .PP
3306 \fBIntegers that can be used in a boolean context\fR:
3307 .TP 18n
3308 loglinelen
3309 Number of characters per line for the file log.
3310 This value is used to decide when to wrap lines for nicer log files.
3311 This has no effect on the syslog log file, only the file log.
3312 The default is
3313 \fR@loglen@\fR
3314 (use 0 or negate the option to disable word wrap).
3315 .TP 18n
3316 passwd_timeout
3317 Number of minutes before the
3318 \fBsudo\fR
3319 password prompt times out, or
3320 \fR0\fR
3321 for no timeout.
3322 The timeout may include a fractional component
3323 if minute granularity is insufficient, for example
3324 \fR2.5\fR.
3325 The
3326 default is
3327 \fR@password_timeout@\fR.
3328 .TP 18n
3329 timestamp_timeout
3330 .br
3331 Number of minutes that can elapse before
3332 \fBsudo\fR
3333 will ask for a passwd again.
3334 The timeout may include a fractional component if
3335 minute granularity is insufficient, for example
3336 \fR2.5\fR.
3337 The default is
3338 \fR@timeout@\fR.
3339 Set this to
3340 \fR0\fR
3341 to always prompt for a password.
3342 If set to a value less than
3343 \fR0\fR
3344 the user's time stamp will not expire until the system is rebooted.
3345 This can be used to allow users to create or delete their own time stamps via
3346 \(lq\fRsudo -v\fR\(rq
3347 and
3348 \(lq\fRsudo -k\fR\(rq
3349 respectively.
3350 .TP 18n
3351 umask
3352 Umask to use when running the command.
3353 Negate this option or set it to 0777 to preserve the user's umask.
3354 The actual umask that is used will be the union of the user's umask
3355 and the value of the
3356 \fIumask\fR
3357 option, which defaults to
3358 \fR@sudo_umask@\fR.
3359 This guarantees
3360 that
3361 \fBsudo\fR
3362 never lowers the umask when running a command.
3363 Note: on systems that use PAM, the default PAM configuration may specify
3364 its own umask which will override the value set in
3365 \fIsudoers\fR.
3366 .PP
3367 \fBStrings\fR:
3368 .TP 18n
3369 authfail_message
3370 Message that is displayed after a user fails to authenticate.
3371 The message may include the
3372 \(oq%d\(cq
3373 escape which will expand to the number of failed password attempts.
3374 If set, it overrides the default message,
3375 \fR%d incorrect password attempt(s)\fR.
3376 .TP 18n
3377 badpass_message
3378 Message that is displayed if a user enters an incorrect password.
3379 The default is
3380 \fR@badpass_message@\fR
3381 unless insults are enabled.
3382 .TP 18n
3383 editor
3384 A colon
3385 (\(oq:\&\(cq)
3386 separated list of editors path names used by
3387 \fBsudoedit\fR
3388 and
3389 \fBvisudo\fR.
3390 For
3391 \fBsudoedit\fR,
3392 this list is used to find an editor when none of the
3393 \fRSUDO_EDITOR\fR,
3394 \fRVISUAL\fR
3395 or
3396 \fREDITOR\fR
3397 environment variables are set to an editor that exists and is executable.
3398 For
3399 \fBvisudo\fR,
3400 it is used as a white list of allowed editors;
3401 \fBvisudo\fR
3402 will choose the editor that matches the user's
3403 \fRSUDO_EDITOR\fR,
3404 \fRVISUAL\fR
3405 or
3406 \fREDITOR\fR
3407 environment variable if possible, or the first editor in the
3408 list that exists and is executable if not.
3409 Unless invoked as
3410 \fBsudoedit\fR,
3411 \fBsudo\fR
3412 does not preserve the
3413 \fRSUDO_EDITOR\fR,
3414 \fRVISUAL\fR
3415 and
3416 \fREDITOR\fR
3417 environment variables by default, even when the
3418 \fIenv_reset\fR
3419 option is enabled.
3420 The default is
3421 \fI@editor@\fR.
3422 .TP 18n
3423 iolog_dir
3424 The top-level directory to use when constructing the path name for
3425 the input/output log directory.
3426 Only used if the
3427 \fIlog_input\fR
3428 or
3429 \fIlog_output\fR
3430 options are enabled or when the
3431 \fRLOG_INPUT\fR
3432 or
3433 \fRLOG_OUTPUT\fR
3434 tags are present for a command.
3435 The session sequence number, if any, is stored in the directory.
3436 The default is
3437 \fI@iolog_dir@\fR.
3438 .sp
3439 The following percent
3440 (\(oq%\(cq)
3441 escape sequences are supported:
3442 .PP
3443 .RS 18n
3444 .PD 0
3445 .TP 6n
3446 \fR%{seq}\fR
3447 expanded to a monotonically increasing base-36 sequence number, such as 0100A5,
3448 where every two digits are used to form a new directory, e.g.,
3449 \fI01/00/A5\fR
3450 .PD
3451 .TP 6n
3452 \fR%{user}\fR
3453 expanded to the invoking user's login name
3454 .TP 6n
3455 \fR%{group}\fR
3456 expanded to the name of the invoking user's real group ID
3457 .TP 6n
3458 \fR%{runas_user}\fR
3459 expanded to the login name of the user the command will
3460 be run as (e.g., root)
3461 .TP 6n
3462 \fR%{runas_group}\fR
3463 expanded to the group name of the user the command will
3464 be run as (e.g., wheel)
3465 .TP 6n
3466 \fR%{hostname}\fR
3467 expanded to the local host name without the domain name
3468 .TP 6n
3469 \fR%{command}\fR
3470 expanded to the base name of the command being run
3471 .PP
3472 In addition, any escape sequences supported by the system's
3473 strftime(3)
3474 function will be expanded.
3475 .sp
3476 To include a literal
3477 \(oq%\(cq
3478 character, the string
3479 \(oq%%\(cq
3480 should be used.
3481 .RE
3482 .TP 18n
3483 iolog_file
3484 The path name, relative to
3485 \fIiolog_dir\fR,
3486 in which to store input/output logs when the
3487 \fIlog_input\fR
3488 or
3489 \fIlog_output\fR
3490 options are enabled or when the
3491 \fRLOG_INPUT\fR
3492 or
3493 \fRLOG_OUTPUT\fR
3494 tags are present for a command.
3495 Note that
3496 \fIiolog_file\fR
3497 may contain directory components.
3498 The default is
3499 \(lq\fR%{seq}\fR\(rq.
3500 .sp
3501 See the
3502 \fIiolog_dir\fR
3503 option above for a list of supported percent
3504 (\(oq%\(cq)
3505 escape sequences.
3506 .sp
3507 In addition to the escape sequences, path names that end in six or
3508 more
3509 \fRX\fRs
3510 will have the
3511 \fRX\fRs
3512 replaced with a unique combination of digits and letters, similar to the
3513 mktemp(3)
3514 function.
3515 .sp
3516 If the path created by concatenating
3517 \fIiolog_dir\fR
3518 and
3519 \fIiolog_file\fR
3520 already exists, the existing I/O log file will be truncated and
3521 overwritten unless
3522 \fIiolog_file\fR
3523 ends in six or
3524 more
3525 \fRX\fRs.
3526 .TP 18n
3527 iolog_flush
3528 If set,
3529 \fBsudo\fR
3530 will flush I/O log data to disk after each write instead of buffering it.
3531 This makes it possible to view the logs in real-time as the program
3532 is executing but may significantly reduce the effectiveness of I/O
3533 log compression.
3534 This flag is
3535 \fIoff\fR
3536 by default.
3537 .sp
3538 This setting is only supported by version 1.8.20 or higher.
3539 .TP 18n
3540 iolog_group
3541 The group name to look up when setting the group ID on new I/O log
3542 files and directories.
3543 If
3544 \fIiolog_group\fR
3545 is not set,
3546 the primary group ID of the user specified by
3547 \fIiolog_user\fR
3548 is used.
3549 If neither
3550 \fIiolog_group\fR
3551 nor
3552 \fIiolog_user\fR
3553 are set, I/O log files and directories are created with group ID 0.
3554 .sp
3555 This setting is only supported by version 1.8.19 or higher.
3556 .TP 18n
3557 iolog_mode
3558 The file mode to use when creating I/O log files.
3559 Mode bits for read and write permissions for owner, group or other
3560 are honored, everything else is ignored.
3561 The file permissions will always include the owner read and
3562 write bits, even if they are not present in the specified mode.
3563 When creating I/O log directories, search (execute) bits are added
3564 to match the read and write bits specified by
3565 \fIiolog_mode\fR.
3566 Defaults to 0600 (read and write by user only).
3567 .sp
3568 This setting is only supported by version 1.8.19 or higher.
3569 .TP 18n
3570 iolog_user
3571 The user name to look up when setting the user and group IDs on new
3572 I/O log files and directories.
3573 If
3574 \fIiolog_group\fR
3575 is set, it will be used instead of the user's primary group ID.
3576 By default, I/O log files and directories are created with user and
3577 group ID 0.
3578 .sp
3579 This setting can be useful when the I/O logs are stored on a Network
3580 File System (NFS) share.
3581 Having a dedicated user own the I/O log files means that
3582 \fBsudoers\fR
3583 does not write to the log files as user ID 0, which is usually
3584 not permitted by NFS.
3585 .sp
3586 This setting is only supported by version 1.8.19 or higher.
3587 .TP 18n
3588 lecture_status_dir
3589 The directory in which
3590 \fBsudo\fR
3591 stores per-user lecture status files.
3592 Once a user has received the lecture, a zero-length file is
3593 created in this directory so that
3594 \fBsudo\fR
3595 will not lecture the user again.
3596 This directory should
3597 \fInot\fR
3598 be cleared when the system reboots.
3599 The default is
3600 \fI@vardir@/lectured\fR.
3601 .if \n(PS \{\
3602 .TP 18n
3603 limitprivs
3604 The default Solaris limit privileges to use when constructing a new
3605 privilege set for a command.
3606 This bounds all privileges of the executing process.
3607 The default limit privileges may be overridden on a per-command basis in
3608 \fIsudoers\fR.
3609 This option is only available if
3610 \fBsudoers\fR
3611 is built on Solaris 10 or higher.
3612 .\}
3613 .TP 18n
3614 mailsub
3615 Subject of the mail sent to the
3616 \fImailto\fR
3617 user.
3618 The escape
3619 \fR%h\fR
3620 will expand to the host name of the machine.
3621 Default is
3622 \(lq\fR@mailsub@\fR\(rq.
3623 .TP 18n
3624 noexec_file
3625 As of
3626 \fBsudo\fR
3627 version 1.8.1 this option is no longer supported.
3628 The path to the noexec file should now be set in the
3629 sudo.conf(@mansectform@)
3630 file.
3631 .TP 18n
3632 pam_login_service
3633 .br
3634 On systems that use PAM for authentication, this is the service
3635 name used when the
3636 \fB\-i\fR
3637 option is specified.
3638 The default value is
3639 \(lq\fR@pam_login_service@\fR\(rq.
3640 See the description of
3641 \fIpam_service\fR
3642 for more information.
3643 .sp
3644 This setting is only supported by version 1.8.8 or higher.
3645 .TP 18n
3646 pam_service
3647 On systems that use PAM for authentication, the service name
3648 specifies the PAM policy to apply.
3649 This usually corresponds to an entry in the
3650 \fIpam.conf\fR
3651 file or a file in the
3652 \fI/etc/pam.d\fR
3653 directory.
3654 The default value is
3655 \(lq\fRsudo\fR\(rq.
3656 .sp
3657 This setting is only supported by version 1.8.8 or higher.
3658 .TP 18n
3659 passprompt
3660 The default prompt to use when asking for a password; can be overridden via the
3661 \fB\-p\fR
3662 option or the
3663 \fRSUDO_PROMPT\fR
3664 environment variable.
3665 The following percent
3666 (\(oq%\(cq)
3667 escape sequences are supported:
3668 .PP
3669 .RS 18n
3670 .PD 0
3671 .TP 6n
3672 \fR%H\fR
3673 expanded to the local host name including the domain name
3674 (only if the machine's host name is fully qualified or the
3675 \fIfqdn\fR
3676 option is set)
3677 .PD
3678 .TP 6n
3679 \fR%h\fR
3680 expanded to the local host name without the domain name
3681 .TP 6n
3682 \fR%p\fR
3683 expanded to the user whose password is being asked for (respects the
3684 \fIrootpw\fR,
3685 \fItargetpw\fR
3686 and
3687 \fIrunaspw\fR
3688 flags in
3689 \fIsudoers\fR)
3690 .TP 6n
3691 \fR\&%U\fR
3692 expanded to the login name of the user the command will
3693 be run as (defaults to root)
3694 .TP 6n
3695 \fR%u\fR
3696 expanded to the invoking user's login name
3697 .TP 6n
3698 \fR%%\fR
3699 two consecutive
3700 \fR%\fR
3701 characters are collapsed into a single
3702 \fR%\fR
3703 character
3704 .PP
3705 On systems that use PAM for authentication,
3706 \fIpassprompt\fR
3707 will only be used if the prompt provided by the PAM module matches the string
3708 \(lqPassword: \(rq
3709 or
3710 \(lqusername's Password: \(rq.
3711 This ensures that the
3712 \fIpassprompt\fR
3713 setting does not interfere with challenge-response style authentication.
3714 The
3715 \fIpassprompt_override\fR
3716 flag can be used to change this behavior.
3717 .sp
3718 The default value is
3719 \(lq\fR@passprompt@\fR\(rq.
3720 .RE
3721 .if \n(PS \{\
3722 .TP 18n
3723 privs
3724 The default Solaris privileges to use when constructing a new
3725 privilege set for a command.
3726 This is passed to the executing process via the inherited privilege set,
3727 but is bounded by the limit privileges.
3728 If the
3729 \fIprivs\fR
3730 option is specified but the
3731 \fIlimitprivs\fR
3732 option is not, the limit privileges of the executing process is set to
3733 \fIprivs\fR.
3734 The default privileges may be overridden on a per-command basis in
3735 \fIsudoers\fR.
3736 This option is only available if
3737 \fBsudoers\fR
3738 is built on Solaris 10 or higher.
3739 .\}
3740 .if \n(SL \{\
3741 .TP 18n
3742 role
3743 The default SELinux role to use when constructing a new security
3744 context to run the command.
3745 The default role may be overridden on a per-command basis in the
3746 \fIsudoers\fR
3747 file or via command line options.
3748 This option is only available when
3749 \fBsudo\fR
3750 is built with SELinux support.
3751 .\}
3752 .TP 18n
3753 runas_default
3754 The default user to run commands as if the
3755 \fB\-u\fR
3756 option is not specified on the command line.
3757 This defaults to
3758 \fR@runas_default@\fR.
3759 .TP 18n
3760 sudoers_locale
3761 Locale to use when parsing the sudoers file, logging commands, and
3762 sending email.
3763 Note that changing the locale may affect how sudoers is interpreted.
3764 Defaults to
3765 \(lq\fRC\fR\(rq.
3766 .TP 18n
3767 timestamp_type
3768 \fBsudoers\fR
3769 uses per-user time stamp files for credential caching.
3770 The
3771 \fItimestamp_type\fR
3772 option can be used to specify the type of time stamp record used.
3773 It has the following possible values:
3774 .PP
3775 .RS 18n
3776 .PD 0
3777 .TP 8n
3778 global
3779 A single time stamp record is used for all of a user's login sessions,
3780 regardless of the terminal or parent process ID.
3781 An additional record is used to serialize password prompts when
3782 \fBsudo\fR
3783 is used multiple times in a pipeline, but this does not affect authentication.
3784 .PD
3785 .TP 8n
3786 ppid
3787 A single time stamp record is used for all processes with the same parent
3788 process ID (usually the shell).
3789 Commands run from the same shell (or other common parent process)
3790 will not require a password for
3791 \fItimestamp_timeout\fR
3792 minutes
3793 (\fR@timeout@\fR
3794 by default)
3795 \&.
3796 Commands run via
3797 \fBsudo\fR
3798 with a different parent process ID, for example from a shell script,
3799 will be authenticated separately.
3800 .TP 8n
3801 tty
3802 One time stamp record is used for each terminal,
3803 which means that a user's login sessions are authenticated separately.
3804 If no terminal is present, the behavior is the same as
3805 \fIppid\fR.
3806 Commands run from the same terminal will not require a password for
3807 \fItimestamp_timeout\fR
3808 minutes
3809 (\fR@timeout@\fR
3810 by default)
3811 \&.
3812 .TP 8n
3813 kernel
3814 The time stamp is stored in the kernel as an attribute of the terminal
3815 device.
3816 If no terminal is present, the behavior is the same as
3817 \fIppid\fR.
3818 Negative
3819 \fItimestamp_timeout\fR
3820 values are not supported and positive values are limited to a maximum
3821 of 60 minutes.
3822 This is currently only supported on
3823 OpenBSD.
3824 .PP
3825 The default value is
3826 \fI@timestamp_type@\fR.
3827 .sp
3828 This setting is only supported by version 1.8.21 or higher.
3829 .RE
3830 .TP 18n
3831 timestampdir
3832 The directory in which
3833 \fBsudo\fR
3834 stores its time stamp files.
3835 This directory should be cleared when the system reboots.
3836 The default is
3837 \fI@rundir@/ts\fR.
3838 .TP 18n
3839 timestampowner
3840 The owner of the lecture status directory, time stamp directory and all
3841 files stored therein.
3842 The default is
3843 \fRroot\fR.
3844 .if \n(SL \{\
3845 .TP 18n
3846 type
3847 The default SELinux type to use when constructing a new security
3848 context to run the command.
3849 The default type may be overridden on a per-command basis in the
3850 \fIsudoers\fR
3851 file or via command line options.
3852 This option is only available when
3853 \fBsudo\fR
3854 is built with SELinux support.
3855 .PP
3856 \fBStrings that can be used in a boolean context\fR:
3857 .TP 14n
3858 env_file
3859 The
3860 \fIenv_file\fR
3861 option specifies the fully qualified path to a file containing variables
3862 to be set in the environment of the program being run.
3863 Entries in this file should either be of the form
3864 \(lq\fRVARIABLE=value\fR\(rq
3865 or
3866 \(lq\fRexport VARIABLE=value\fR\(rq.
3867 The value may optionally be surrounded by single or double quotes.
3868 Variables in this file are only added if the variable does not already
3869 exist in the environment.
3870 This file is considered to be part of the security policy,
3871 its contents are not subject to other
3872 \fBsudo\fR
3873 environment restrictions such as
3874 \fIenv_keep\fR
3875 and
3876 \fIenv_check\fR.
3877 .TP 14n
3878 exempt_group
3879 Users in this group are exempt from password and PATH requirements.
3880 The group name specified should not include a
3881 \fR%\fR
3882 prefix.
3883 This is not set by default.
3884 .TP 14n
3885 fdexec
3886 Determines whether
3887 \fBsudo\fR
3888 will execute a command by its path or by an open file descriptor.
3889 It has the following possible values:
3890 .PP
3891 .RS 14n
3892 .PD 0
3893 .TP 8n
3894 always
3895 Always execute by file descriptor.
3896 .PD
3897 .TP 8n
3898 never
3899 Never execute by file descriptor.
3900 .TP 8n
3901 digest_only
3902 Only execute by file descriptor if the command has an associated digest
3903 in the
3904 \fIsudoers\fR
3905 file.
3906 .PP
3907 The default value is
3908 \fIdigest_only\fR.
3909 This avoids a time of check versus time of use race condition when
3910 the command is located in a directory writable by the invoking user.
3911 .sp
3912 Note that
3913 \fIfdexec\fR
3914 will change the first element of the argument vector for scripts
3915 ($0 in the shell) due to the way the kernel runs script interpreters.
3916 Instead of being a normal path, it will refer to a file descriptor.
3917 For example,
3918 \fI/dev/fd/4\fR
3919 on Solaris and
3920 \fI/proc/self/fd/4\fR
3921 on Linux.
3922 A workaround is to use the
3923 \fRSUDO_COMMAND\fR
3924 environment variable instead.
3925 .sp
3926 The
3927 \fIfdexec\fR
3928 setting is only used when the command is matched by path name.
3929 It has no effect if the command is matched by the built-in
3930 \fBALL\fR
3931 alias.
3932 .sp
3933 This setting is only supported by version 1.8.20 or higher.
3934 If the operating system does not support the
3935 fexecve(2)
3936 system call, this setting has no effect.
3937 .RE
3938 .TP 14n
3939 group_plugin
3940 A string containing a
3941 \fBsudoers\fR
3942 group plugin with optional arguments.
3943 The string should consist of the plugin
3944 path, either fully-qualified or relative to the
3945 \fI@PLUGINDIR@\fR
3946 directory, followed by any configuration arguments the plugin requires.
3947 These arguments (if any) will be passed to the plugin's initialization function.
3948 If arguments are present, the string must be enclosed in double quotes
3949 (\&"").
3950 .sp
3951 For more information see
3952 \fIGROUP PROVIDER PLUGINS\fR.
3953 .TP 14n
3954 lecture
3955 This option controls when a short lecture will be printed along with
3956 the password prompt.
3957 It has the following possible values:
3958 .PP
3959 .RS 14n
3960 .PD 0
3961 .TP 8n
3962 always
3963 Always lecture the user.
3964 .PD
3965 .TP 8n
3966 never
3967 Never lecture the user.
3968 .TP 8n
3969 once
3970 Only lecture the user the first time they run
3971 \fBsudo\fR.
3972 .PP
3973 If no value is specified, a value of
3974 \fIonce\fR
3975 is implied.
3976 Negating the option results in a value of
3977 \fInever\fR
3978 being used.
3979 The default value is
3980 \fI@lecture@\fR.
3981 .RE
3982 .TP 14n
3983 lecture_file
3984 Path to a file containing an alternate
3985 \fBsudo\fR
3986 lecture that will be used in place of the standard lecture if the named
3987 file exists.
3988 By default,
3989 \fBsudo\fR
3990 uses a built-in lecture.
3991 .TP 14n
3992 listpw
3993 This option controls when a password will be required when a user runs
3994 \fBsudo\fR
3995 with the
3996 \fB\-l\fR
3997 option.
3998 It has the following possible values:
3999 .PP
4000 .RS 14n
4001 .PD 0
4002 .TP 10n
4003 all
4004 All the user's
4005 \fIsudoers\fR
4006 file entries for the current host must have
4007 the
4008 \fRNOPASSWD\fR
4009 flag set to avoid entering a password.
4010 .PD
4011 .TP 10n
4012 always
4013 The user must always enter a password to use the
4014 \fB\-l\fR
4015 option.
4016 .TP 10n
4017 any
4018 At least one of the user's
4019 \fIsudoers\fR
4020 file entries for the current host
4021 must have the
4022 \fRNOPASSWD\fR
4023 flag set to avoid entering a password.
4024 .TP 10n
4025 never
4026 The user need never enter a password to use the
4027 \fB\-l\fR
4028 option.
4029 .PP
4030 If no value is specified, a value of
4031 \fIany\fR
4032 is implied.
4033 Negating the option results in a value of
4034 \fInever\fR
4035 being used.
4036 The default value is
4037 \fIany\fR.
4038 .RE
4039 .TP 14n
4040 logfile
4041 Path to the
4042 \fBsudo\fR
4043 log file (not the syslog log file).
4044 Setting a path turns on logging to a file;
4045 negating this option turns it off.
4046 By default,
4047 \fBsudo\fR
4048 logs via syslog.
4049 .TP 14n
4050 mailerflags
4051 Flags to use when invoking mailer.
4052 Defaults to
4053 \fB\-t\fR.
4054 .TP 14n
4055 mailerpath
4056 Path to mail program used to send warning mail.
4057 Defaults to the path to sendmail found at configure time.
4058 .TP 14n
4059 mailfrom
4060 Address to use for the
4061 \(lqfrom\(rq
4062 address when sending warning and error mail.
4063 The address should be enclosed in double quotes
4064 (\&"")
4065 to protect against
4066 \fBsudo\fR
4067 interpreting the
4068 \fR@\fR
4069 sign.
4070 Defaults to the name of the user running
4071 \fBsudo\fR.
4072 .TP 14n
4073 mailto
4074 Address to send warning and error mail to.
4075 The address should be enclosed in double quotes
4076 (\&"")
4077 to protect against
4078 \fBsudo\fR
4079 interpreting the
4080 \fR@\fR
4081 sign.
4082 Defaults to
4083 \fR@mailto@\fR.
4084 .TP 14n
4085 restricted_env_file
4086 The
4087 \fIrestricted_env_file\fR
4088 option specifies the fully qualified path to a file containing variables
4089 to be set in the environment of the program being run.
4090 Entries in this file should either be of the form
4091 \(lq\fRVARIABLE=value\fR\(rq
4092 or
4093 \(lq\fRexport VARIABLE=value\fR\(rq.
4094 The value may optionally be surrounded by single or double quotes.
4095 Variables in this file are only added if the variable does not already
4096 exist in the environment.
4097 Unlike
4098 \fIenv_file\fR,
4099 the file's contents are not trusted and are processed in a manner
4100 similar to that of the invoking user's environment.
4101 If
4102 \fIenv_reset\fR
4103 is enabled, variables in the file will only be added if they are
4104 matched by either the
4105 \fIenv_check\fR
4106 or
4107 \fIenv_keep\fR
4108 list.
4109 If
4110 \fIenv_reset\fR
4111 is disabled, variables in the file are added as long as they
4112 are not matched by the
4113 \fIenv_delete\fR
4114 list.
4115 In either case, the contents of
4116 \fIrestricted_env_file\fR
4117 are processed before the contents of
4118 \fIenv_file\fR.
4119 .TP 14n
4120 secure_path
4121 Path used for every command run from
4122 \fBsudo\fR.
4123 If you don't trust the
4124 people running
4125 \fBsudo\fR
4126 to have a sane
4127 \fRPATH\fR
4128 environment variable you may want to use this.
4129 Another use is if you want to have the
4130 \(lqroot path\(rq
4131 be separate from the
4132 \(lquser path\(rq.
4133 Users in the group specified by the
4134 \fIexempt_group\fR
4135 option are not affected by
4136 \fIsecure_path\fR.
4137 This option is @secure_path@ by default.
4138 .TP 14n
4139 syslog
4140 Syslog facility if syslog is being used for logging (negate to
4141 disable syslog logging).
4142 Defaults to
4143 \fR@logfac@\fR.
4144 .sp
4145 The following syslog facilities are supported:
4146 \fBauthpriv\fR
4147 (if your
4148 OS supports it),
4149 \fBauth\fR,
4150 \fBdaemon\fR,
4151 \fBuser\fR,
4152 \fBlocal0\fR,
4153 \fBlocal1\fR,
4154 \fBlocal2\fR,
4155 \fBlocal3\fR,
4156 \fBlocal4\fR,
4157 \fBlocal5\fR,
4158 \fBlocal6\fR,
4159 and
4160 \fBlocal7\fR.
4161 .TP 14n
4162 syslog_badpri
4163 .br
4164 Syslog priority to use when the user is not allowed to run a command or
4165 when authentication is unsuccessful.
4166 Defaults to
4167 \fR@badpri@\fR.
4168 .sp
4169 The following syslog priorities are supported:
4170 \fBalert\fR,
4171 \fBcrit\fR,
4172 \fBdebug\fR,
4173 \fBemerg\fR,
4174 \fBerr\fR,
4175 \fBinfo\fR,
4176 \fBnotice\fR,
4177 \fBwarning\fR,
4178 and
4179 \fBnone\fR.
4180 Negating the option or setting it to a value of
4181 \fBnone\fR
4182 will disable logging of unsuccessful commands.
4183 .TP 14n
4184 syslog_goodpri
4185 Syslog priority to use when the user is allowed to run a command and
4186 authentication is successful.
4187 Defaults to
4188 \fR@goodpri@\fR.
4189 .sp
4190 See
4191 \fIsyslog_badpri\fR
4192 for the list of supported syslog priorities.
4193 Negating the option or setting it to a value of
4194 \fBnone\fR
4195 will disable logging of successful commands.
4196 .TP 14n
4197 verifypw
4198 This option controls when a password will be required when a user runs
4199 \fBsudo\fR
4200 with the
4201 \fB\-v\fR
4202 option.
4203 It has the following possible values:
4204 .PP
4205 .RS 14n
4206 .PD 0
4207 .TP 8n
4208 all
4209 All the user's
4210 \fIsudoers\fR
4211 file entries for the current host must have the
4212 \fRNOPASSWD\fR
4213 flag set to avoid entering a password.
4214 .PD
4215 .TP 8n
4216 always
4217 The user must always enter a password to use the
4218 \fB\-v\fR
4219 option.
4220 .TP 8n
4221 any
4222 At least one of the user's
4223 \fIsudoers\fR
4224 file entries for the current host must have the
4225 \fRNOPASSWD\fR
4226 flag set to avoid entering a password.
4227 .TP 8n
4228 never
4229 The user need never enter a password to use the
4230 \fB\-v\fR
4231 option.
4232 .PP
4233 If no value is specified, a value of
4234 \fIall\fR
4235 is implied.
4236 Negating the option results in a value of
4237 \fInever\fR
4238 being used.
4239 The default value is
4240 \fIall\fR.
4241 .RE
4242 .PP
4243 \fBLists that can be used in a boolean context\fR:
4244 .\}
4245 .TP 18n
4246 env_check
4247 Environment variables to be removed from the user's environment
4248 unless they are considered
4249 \(lqsafe\(rq.
4250 For all variables except
4251 \fRTZ\fR,
4252 \(lqsafe\(rq
4253 means that the variable's value does not contain any
4254 \(oq%\(cq
4255 or
4256 \(oq/\(cq
4257 characters.
4258 This can be used to guard against printf-style format vulnerabilities
4259 in poorly-written programs.
4260 The
4261 \fRTZ\fR
4262 variable is considered unsafe if any of the following are true:
4263 .PP
4264 .RS 18n
4265 .PD 0
4266 .TP 3n
4267 \fB\(bu\fR
4268 It consists of a fully-qualified path name,
4269 optionally prefixed with a colon
4270 (\(oq:\&\(cq),
4271 that does not match the location of the
4272 \fIzoneinfo\fR
4273 directory.
4274 .PD
4275 .TP 3n
4276 \fB\(bu\fR
4277 It contains a
4278 \fI..\fR
4279 path element.
4280 .TP 3n
4281 \fB\(bu\fR
4282 It contains white space or non-printable characters.
4283 .TP 3n
4284 \fB\(bu\fR
4285 It is longer than the value of
4286 \fRPATH_MAX\fR.
4287 .PP
4288 The argument may be a double-quoted, space-separated list or a
4289 single value without double-quotes.
4290 The list can be replaced, added to, deleted from, or disabled by using
4291 the
4292 \fR=\fR,
4293 \fR+=\fR,
4294 \fR-=\fR,
4295 and
4296 \fR\&!\fR
4297 operators respectively.
4298 Regardless of whether the
4299 \fRenv_reset\fR
4300 option is enabled or disabled, variables specified by
4301 \fRenv_check\fR
4302 will be preserved in the environment if they pass the aforementioned check.
4303 The global list of environment variables to check is displayed when
4304 \fBsudo\fR
4305 is run by root with
4306 the
4307 \fB\-V\fR
4308 option.
4309 .RE
4310 .TP 18n
4311 env_delete
4312 Environment variables to be removed from the user's environment when the
4313 \fIenv_reset\fR
4314 option is not in effect.
4315 The argument may be a double-quoted, space-separated list or a
4316 single value without double-quotes.
4317 The list can be replaced, added to, deleted from, or disabled by using the
4318 \fR=\fR,
4319 \fR+=\fR,
4320 \fR-=\fR,
4321 and
4322 \fR\&!\fR
4323 operators respectively.
4324 The global list of environment variables to remove is displayed when
4325 \fBsudo\fR
4326 is run by root with the
4327 \fB\-V\fR
4328 option.
4329 Note that many operating systems will remove potentially dangerous
4330 variables from the environment of any setuid process (such as
4331 \fBsudo\fR).
4332 .TP 18n
4333 env_keep
4334 Environment variables to be preserved in the user's environment when the
4335 \fIenv_reset\fR
4336 option is in effect.
4337 This allows fine-grained control over the environment
4338 \fBsudo\fR-spawned
4339 processes will receive.
4340 The argument may be a double-quoted, space-separated list or a
4341 single value without double-quotes.
4342 The list can be replaced, added to, deleted from, or disabled by using the
4343 \fR=\fR,
4344 \fR+=\fR,
4345 \fR-=\fR,
4346 and
4347 \fR\&!\fR
4348 operators respectively.
4349 The global list of variables to keep
4350 is displayed when
4351 \fBsudo\fR
4352 is run by root with the
4353 \fB\-V\fR
4354 option.
4355 .SH "GROUP PROVIDER PLUGINS"
4356 The
4357 \fBsudoers\fR
4358 plugin supports its own plugin interface to allow non-Unix
4359 group lookups which can query a group source other
4360 than the standard Unix group database.
4361 This can be used to implement support for the
4362 \fRnonunix_group\fR
4363 syntax described earlier.
4364 .PP
4365 Group provider plugins are specified via the
4366 \fIgroup_plugin\fR
4367 Defaults setting.
4368 The argument to
4369 \fIgroup_plugin\fR
4370 should consist of the plugin path, either fully-qualified or relative to the
4371 \fI@PLUGINDIR@\fR
4372 directory, followed by any configuration options the plugin requires.
4373 These options (if specified) will be passed to the plugin's initialization
4374 function.
4375 If options are present, the string must be enclosed in double quotes
4376 (\&"").
4377 .PP
4378 The following group provider plugins are installed by default:
4379 .TP 10n
4380 group_file
4381 The
4382 \fIgroup_file\fR
4383 plugin supports an alternate group file that uses the same syntax as the
4384 \fI/etc/group\fR
4385 file.
4386 The path to the group file should be specified as an option
4387 to the plugin.
4388 For example, if the group file to be used is
4389 \fI/etc/sudo-group\fR:
4390 .nf
4391 .sp
4392 .RS 10n
4393 Defaults group_plugin="group_file.so /etc/sudo-group"
4394 .RE
4395 .fi
4396 .TP 10n
4397 system_group
4398 The
4399 \fIsystem_group\fR
4400 plugin supports group lookups via the standard C library functions
4401 \fBgetgrnam\fR()
4402 and
4403 \fBgetgrid\fR().
4404 This plugin can be used in instances where the user belongs to
4405 groups not present in the user's supplemental group vector.
4406 This plugin takes no options:
4407 .nf
4408 .sp
4409 .RS 10n
4410 Defaults group_plugin=system_group.so
4411 .RE
4412 .fi
4413 .PP
4414 The group provider plugin API is described in detail in
4415 sudo_plugin(@mansectform@).
4416 .SH "LOG FORMAT"
4417 \fBsudoers\fR
4418 can log events using either
4419 syslog(3)
4420 or a simple log file.
4421 The log format is almost identical in both cases.
4422 .SS "Accepted command log entries"
4423 Commands that sudo runs are logged using the following format (split
4424 into multiple lines for readability):
4425 .nf
4426 .sp
4427 .RS 4n
4428 date hostname progname: username : TTY=ttyname ; PWD=cwd ; \e
4429     USER=runasuser ; GROUP=runasgroup ; TSID=logid ; \e
4430     ENV=env_vars COMMAND=command
4431 .RE
4432 .fi
4433 .PP
4434 Where the fields are as follows:
4435 .TP 14n
4436 date
4437 The date the command was run.
4438 Typically, this is in the format
4439 \(lqMMM, DD, HH:MM:SS\(rq.
4440 If logging via
4441 syslog(3),
4442 the actual date format is controlled by the syslog daemon.
4443 If logging to a file and the
4444 \fIlog_year\fR
4445 option is enabled,
4446 the date will also include the year.
4447 .TP 14n
4448 hostname
4449 The name of the host
4450 \fBsudo\fR
4451 was run on.
4452 This field is only present when logging via
4453 syslog(3).
4454 .TP 14n
4455 progname
4456 The name of the program, usually
4457 \fIsudo\fR
4458 or
4459 \fIsudoedit\fR.
4460 This field is only present when logging via
4461 syslog(3).
4462 .TP 14n
4463 username
4464 The login name of the user who ran
4465 \fBsudo\fR.
4466 .TP 14n
4467 ttyname
4468 The short name of the terminal (e.g.,
4469 \(lqconsole\(rq,
4470 \(lqtty01\(rq,
4471 or
4472 \(lqpts/0\(rq)
4473 \fBsudo\fR
4474 was run on, or
4475 \(lqunknown\(rq
4476 if there was no terminal present.
4477 .TP 14n
4478 cwd
4479 The current working directory that
4480 \fBsudo\fR
4481 was run in.
4482 .TP 14n
4483 runasuser
4484 The user the command was run as.
4485 .TP 14n
4486 runasgroup
4487 The group the command was run as if one was specified on the command line.
4488 .TP 14n
4489 logid
4490 An I/O log identifier that can be used to replay the command's output.
4491 This is only present when the
4492 \fIlog_input\fR
4493 or
4494 \fIlog_output\fR
4495 option is enabled.
4496 .TP 14n
4497 env_vars
4498 A list of environment variables specified on the command line,
4499 if specified.
4500 .TP 14n
4501 command
4502 The actual command that was executed.
4503 .PP
4504 Messages are logged using the locale specified by
4505 \fIsudoers_locale\fR,
4506 which defaults to the
4507 \(lq\fRC\fR\(rq
4508 locale.
4509 .SS "Denied command log entries"
4510 If the user is not allowed to run the command, the reason for the denial
4511 will follow the user name.
4512 Possible reasons include:
4513 .TP 3n
4514 user NOT in sudoers
4515 The user is not listed in the
4516 \fIsudoers\fR
4517 file.
4518 .TP 3n
4519 user NOT authorized on host
4520 The user is listed in the
4521 \fIsudoers\fR
4522 file but is not allowed to run commands on the host.
4523 .TP 3n
4524 command not allowed
4525 The user is listed in the
4526 \fIsudoers\fR
4527 file for the host but they are not allowed to run the specified command.
4528 .TP 3n
4529 3 incorrect password attempts
4530 The user failed to enter their password after 3 tries.
4531 The actual number of tries will vary based on the number of
4532 failed attempts and the value of the
4533 \fIpasswd_tries\fR
4534 option.
4535 .TP 3n
4536 a password is required
4537 \fBsudo\fR's
4538 \fB\-n\fR
4539 option was specified but a password was required.
4540 .TP 3n
4541 sorry, you are not allowed to set the following environment variables
4542 The user specified environment variables on the command line that
4543 were not allowed by
4544 \fIsudoers\fR.
4545 .SS "Error log entries"
4546 If an error occurs,
4547 \fBsudoers\fR
4548 will log a message and, in most cases, send a message to the
4549 administrator via email.
4550 Possible errors include:
4551 .TP 3n
4552 parse error in @sysconfdir@/sudoers near line N
4553 \fBsudoers\fR
4554 encountered an error when parsing the specified file.
4555 In some cases, the actual error may be one line above or below the
4556 line number listed, depending on the type of error.
4557 .TP 3n
4558 problem with defaults entries
4559 The
4560 \fIsudoers\fR
4561 file contains one or more unknown Defaults settings.
4562 This does not prevent
4563 \fBsudo\fR
4564 from running, but the
4565 \fIsudoers\fR
4566 file should be checked using
4567 \fBvisudo\fR.
4568 .TP 3n
4569 timestamp owner (username): \&No such user
4570 The time stamp directory owner, as specified by the
4571 \fItimestampowner\fR
4572 setting, could not be found in the password database.
4573 .TP 3n
4574 unable to open/read @sysconfdir@/sudoers
4575 The
4576 \fIsudoers\fR
4577 file could not be opened for reading.
4578 This can happen when the
4579 \fIsudoers\fR
4580 file is located on a remote file system that maps user ID 0 to
4581 a different value.
4582 Normally,
4583 \fBsudoers\fR
4584 tries to open the
4585 \fIsudoers\fR
4586 file using group permissions to avoid this problem.
4587 Consider either changing the ownership of
4588 \fI@sysconfdir@/sudoers\fR
4589 or adding an argument like
4590 \(lqsudoers_uid=N\(rq
4591 (where
4592 \(oqN\(cq
4593 is the user ID that owns the
4594 \fIsudoers\fR
4595 file) to the end of the
4596 \fBsudoers\fR
4597 \fRPlugin\fR
4598 line in the
4599 sudo.conf(@mansectform@)
4600 file.
4601 .TP 3n
4602 unable to stat @sysconfdir@/sudoers
4603 The
4604 \fI@sysconfdir@/sudoers\fR
4605 file is missing.
4606 .TP 3n
4607 @sysconfdir@/sudoers is not a regular file
4608 The
4609 \fI@sysconfdir@/sudoers\fR
4610 file exists but is not a regular file or symbolic link.
4611 .TP 3n
4612 @sysconfdir@/sudoers is owned by uid N, should be 0
4613 The
4614 \fIsudoers\fR
4615 file has the wrong owner.
4616 If you wish to change the
4617 \fIsudoers\fR
4618 file owner, please add
4619 \(lqsudoers_uid=N\(rq
4620 (where
4621 \(oqN\(cq
4622 is the user ID that owns the
4623 \fIsudoers\fR
4624 file) to the
4625 \fBsudoers\fR
4626 \fRPlugin\fR
4627 line in the
4628 sudo.conf(@mansectform@)
4629 file.
4630 .TP 3n
4631 @sysconfdir@/sudoers is world writable
4632 The permissions on the
4633 \fIsudoers\fR
4634 file allow all users to write to it.
4635 The
4636 \fIsudoers\fR
4637 file must not be world-writable, the default file mode
4638 is 0440 (readable by owner and group, writable by none).
4639 The default mode may be changed via the
4640 \(lqsudoers_mode\(rq
4641 option to the
4642 \fBsudoers\fR
4643 \fRPlugin\fR
4644 line in the
4645 sudo.conf(@mansectform@)
4646 file.
4647 .TP 3n
4648 @sysconfdir@/sudoers is owned by gid N, should be 1
4649 The
4650 \fIsudoers\fR
4651 file has the wrong group ownership.
4652 If you wish to change the
4653 \fIsudoers\fR
4654 file group ownership, please add
4655 \(lqsudoers_gid=N\(rq
4656 (where
4657 \(oqN\(cq
4658 is the group ID that owns the
4659 \fIsudoers\fR
4660 file) to the
4661 \fBsudoers\fR
4662 \fRPlugin\fR
4663 line in the
4664 sudo.conf(@mansectform@)
4665 file.
4666 .TP 3n
4667 unable to open @rundir@/ts/username
4668 \fBsudoers\fR
4669 was unable to read or create the user's time stamp file.
4670 This can happen when
4671 \fItimestampowner\fR
4672 is set to a user other than root and the mode on
4673 \fI@rundir@\fR
4674 is not searchable by group or other.
4675 The default mode for
4676 \fI@rundir@\fR
4677 is 0711.
4678 .TP 3n
4679 unable to write to @rundir@/ts/username
4680 \fBsudoers\fR
4681 was unable to write to the user's time stamp file.
4682 .TP 3n
4683 @rundir@/ts is owned by uid X, should be Y
4684 The time stamp directory is owned by a user other than
4685 \fItimestampowner\fR.
4686 This can occur when the value of
4687 \fItimestampowner\fR
4688 has been changed.
4689 \fBsudoers\fR
4690 will ignore the time stamp directory until the owner is corrected.
4691 .TP 3n
4692 @rundir@/ts is group writable
4693 The time stamp directory is group-writable; it should be writable only by
4694 \fItimestampowner\fR.
4695 The default mode for the time stamp directory is 0700.
4696 \fBsudoers\fR
4697 will ignore the time stamp directory until the mode is corrected.
4698 .SS "Notes on logging via syslog"
4699 By default,
4700 \fBsudoers\fR
4701 logs messages via
4702 syslog(3).
4703 The
4704 \fIdate\fR,
4705 \fIhostname\fR,
4706 and
4707 \fIprogname\fR
4708 fields are added by the system's
4709 \fBsyslog\fR()
4710 function, not
4711 \fBsudoers\fR
4712 itself.
4713 As such, they may vary in format on different systems.
4714 .PP
4715 The maximum size of syslog messages varies from system to system.
4716 The
4717 \fIsyslog_maxlen\fR
4718 setting can be used to change the maximum syslog message size
4719 from the default value of 980 bytes.
4720 For more information, see the description of
4721 \fIsyslog_maxlen\fR.
4722 .SS "Notes on logging to a file"
4723 If the
4724 \fIlogfile\fR
4725 option is set,
4726 \fBsudoers\fR
4727 will log to a local file, such as
4728 \fI/var/log/sudo\fR.
4729 When logging to a file,
4730 \fBsudoers\fR
4731 uses a format similar to
4732 syslog(3),
4733 with a few important differences:
4734 .TP 5n
4735 1.\&
4736 The
4737 \fIprogname\fR
4738 and
4739 \fIhostname\fR
4740 fields are not present.
4741 .TP 5n
4742 2.\&
4743 If the
4744 \fIlog_year\fR
4745 option is enabled,
4746 the date will also include the year.
4747 .TP 5n
4748 3.\&
4749 Lines that are longer than
4750 \fIloglinelen\fR
4751 characters (80 by default) are word-wrapped and continued on the
4752 next line with a four character indent.
4753 This makes entries easier to read for a human being, but makes it
4754 more difficult to use
4755 grep(1)
4756 on the log files.
4757 If the
4758 \fIloglinelen\fR
4759 option is set to 0 (or negated with a
4760 \(oq\&!\(cq),
4761 word wrap will be disabled.
4762 .SH "I/O LOG FILES"
4763 When I/O logging is enabled,
4764 \fBsudo\fR
4765 will run the command in a pseudo-tty and log all user input and/or output,
4766 depending on which options are enabled.
4767 I/O is logged to the directory specified by the
4768 \fIiolog_dir\fR
4769 option
4770 (\fI@iolog_dir@\fR
4771 by default)
4772 using a unique session ID that is included in the
4773 \fBsudo\fR
4774 log line, prefixed with
4775 \(lq\fRTSID=\fR\(rq.
4776 The
4777 \fIiolog_file\fR
4778 option may be used to control the format of the session ID.
4779 .PP
4780 Each I/O log is stored in a separate directory that contains the
4781 following files:
4782 .TP 10n
4783 \fIlog\fR
4784 a text file containing the time the command was run, the name of the user
4785 who ran
4786 \fBsudo\fR,
4787 the name of the target user, the name of the target group (optional),
4788 the terminal that
4789 \fBsudo\fR
4790 was run from, the number of rows and columns of the terminal,
4791 the working directory the command was run from and the path name of
4792 the command itself (with arguments if present)
4793 .TP 10n
4794 \fItiming\fR
4795 a log of the amount of time between, and the number of bytes in, each
4796 I/O log entry (used for session playback)
4797 .TP 10n
4798 \fIttyin\fR
4799 input from the user's tty (what the user types)
4800 .TP 10n
4801 \fIstdin\fR
4802 input from a pipe or file
4803 .TP 10n
4804 \fIttyout\fR
4805 output from the pseudo-tty (what the command writes to the screen)
4806 .TP 10n
4807 \fIstdout\fR
4808 standard output to a pipe or redirected to a file
4809 .TP 10n
4810 \fIstderr\fR
4811 standard error to a pipe or redirected to a file
4812 .PP
4813 All files other than
4814 \fIlog\fR
4815 are compressed in gzip format unless the
4816 \fIcompress_io\fR
4817 flag has been disabled.
4818 Due to buffering, it is not normally possible to display the I/O logs in
4819 real-time as the program is executing
4820 The I/O log data will not be complete until the program run by
4821 \fBsudo\fR
4822 has exited or has been terminated by a signal.
4823 The
4824 \fIiolog_flush\fR
4825 flag can be used to disable buffering, in which case I/O log data
4826 is written to disk as soon as it is available.
4827 The output portion of an I/O log file can be viewed with the
4828 sudoreplay(@mansectsu@)
4829 utility, which can also be used to list or search the available logs.
4830 .PP
4831 Note that user input may contain sensitive information such as
4832 passwords (even if they are not echoed to the screen), which will
4833 be stored in the log file unencrypted.
4834 In most cases, logging the command output via
4835 \fIlog_output\fR
4836 or
4837 \fRLOG_OUTPUT\fR
4838 is all that is required.
4839 .PP
4840 Since each session's I/O logs are stored in a separate directory,
4841 traditional log rotation utilities cannot be used to limit the
4842 number of I/O logs.
4843 The simplest way to limit the number of I/O is by setting the
4844 \fImaxseq\fR
4845 option to the maximum number of logs you wish to store.
4846 Once the I/O log sequence number reaches
4847 \fImaxseq\fR,
4848 it will be reset to zero and
4849 \fBsudoers\fR
4850 will truncate and re-use any existing I/O logs.
4851 .SH "FILES"
4852 .TP 26n
4853 \fI@sysconfdir@/sudo.conf\fR
4854 Sudo front end configuration
4855 .TP 26n
4856 \fI@sysconfdir@/sudoers\fR
4857 List of who can run what
4858 .TP 26n
4859 \fI/etc/group\fR
4860 Local groups file
4861 .TP 26n
4862 \fI/etc/netgroup\fR
4863 List of network groups
4864 .TP 26n
4865 \fI@iolog_dir@\fR
4866 I/O log files
4867 .TP 26n
4868 \fI@rundir@/ts\fR
4869 Directory containing time stamps for the
4870 \fBsudoers\fR
4871 security policy
4872 .TP 26n
4873 \fI@vardir@/lectured\fR
4874 Directory containing lecture status files for the
4875 \fBsudoers\fR
4876 security policy
4877 .TP 26n
4878 \fI/etc/environment\fR
4879 Initial environment for
4880 \fB\-i\fR
4881 mode on AIX and Linux systems
4882 .SH "EXAMPLES"
4883 Below are example
4884 \fIsudoers\fR
4885 file entries.
4886 Admittedly, some of these are a bit contrived.
4887 First, we allow a few environment variables to pass and then define our
4888 \fIaliases\fR:
4889 .nf
4890 .sp
4891 .RS 0n
4892 # Run X applications through sudo; HOME is used to find the
4893 # .Xauthority file.  Note that other programs use HOME to find
4894 # configuration files and this may lead to privilege escalation!
4895 Defaults env_keep += "DISPLAY HOME"
4896
4897 # User alias specification
4898 User_Alias      FULLTIMERS = millert, mikef, dowdy
4899 User_Alias      PARTTIMERS = bostley, jwfox, crawl
4900 User_Alias      WEBMASTERS = will, wendy, wim
4901
4902 # Runas alias specification
4903 Runas_Alias     OP = root, operator
4904 Runas_Alias     DB = oracle, sybase
4905 Runas_Alias     ADMINGRP = adm, oper
4906
4907 # Host alias specification
4908 Host_Alias      SPARC = bigtime, eclipse, moet, anchor :\e
4909                 SGI = grolsch, dandelion, black :\e
4910                 ALPHA = widget, thalamus, foobar :\e
4911                 HPPA = boa, nag, python
4912 Host_Alias      CUNETS = 128.138.0.0/255.255.0.0
4913 Host_Alias      CSNETS = 128.138.243.0, 128.138.204.0/24, 128.138.242.0
4914 Host_Alias      SERVERS = master, mail, www, ns
4915 Host_Alias      CDROM = orion, perseus, hercules
4916
4917 # Cmnd alias specification
4918 Cmnd_Alias      DUMPS = /usr/bin/mt, /usr/sbin/dump, /usr/sbin/rdump,\e
4919                         /usr/sbin/restore, /usr/sbin/rrestore,\e
4920                         sha224:0GomF8mNN3wlDt1HD9XldjJ3SNgpFdbjO1+NsQ== \e
4921                         /home/operator/bin/start_backups
4922 Cmnd_Alias      KILL = /usr/bin/kill
4923 Cmnd_Alias      PRINTING = /usr/sbin/lpc, /usr/bin/lprm
4924 Cmnd_Alias      SHUTDOWN = /usr/sbin/shutdown
4925 Cmnd_Alias      HALT = /usr/sbin/halt
4926 Cmnd_Alias      REBOOT = /usr/sbin/reboot
4927 Cmnd_Alias      SHELLS = /usr/bin/sh, /usr/bin/csh, /usr/bin/ksh,\e
4928                          /usr/local/bin/tcsh, /usr/bin/rsh,\e
4929                          /usr/local/bin/zsh
4930 Cmnd_Alias      SU = /usr/bin/su
4931 Cmnd_Alias      PAGERS = /usr/bin/more, /usr/bin/pg, /usr/bin/less
4932 .RE
4933 .fi
4934 .PP
4935 Here we override some of the compiled in default values.
4936 We want
4937 \fBsudo\fR
4938 to log via
4939 syslog(3)
4940 using the
4941 \fIauth\fR
4942 facility in all cases.
4943 We don't want to subject the full time staff to the
4944 \fBsudo\fR
4945 lecture, user
4946 \fBmillert\fR
4947 need not give a password, and we don't want to reset the
4948 \fRLOGNAME\fR
4949 or
4950 \fRUSER\fR
4951 environment variables when running commands as root.
4952 Additionally, on the machines in the
4953 \fISERVERS\fR
4954 \fRHost_Alias\fR,
4955 we keep an additional local log file and make sure we log the year
4956 in each log line since the log entries will be kept around for several years.
4957 Lastly, we disable shell escapes for the commands in the PAGERS
4958 \fRCmnd_Alias\fR
4959 (\fI/usr/bin/more\fR,
4960 \fI/usr/bin/pg\fR
4961 and
4962 \fI/usr/bin/less\fR)
4963 \&.
4964 Note that this will not effectively constrain users with
4965 \fBsudo\fR
4966 \fBALL\fR
4967 privileges.
4968 .nf
4969 .sp
4970 .RS 0n
4971 # Override built-in defaults
4972 Defaults                syslog=auth
4973 Defaults>root           !set_logname
4974 Defaults:FULLTIMERS     !lecture
4975 Defaults:millert        !authenticate
4976 Defaults@SERVERS        log_year, logfile=/var/log/sudo.log
4977 Defaults!PAGERS         noexec
4978 .RE
4979 .fi
4980 .PP
4981 The
4982 \fIUser specification\fR
4983 is the part that actually determines who may run what.
4984 .nf
4985 .sp
4986 .RS 0n
4987 root            ALL = (ALL) ALL
4988 %wheel          ALL = (ALL) ALL
4989 .RE
4990 .fi
4991 .PP
4992 We let
4993 \fBroot\fR
4994 and any user in group
4995 \fBwheel\fR
4996 run any command on any host as any user.
4997 .nf
4998 .sp
4999 .RS 0n
5000 FULLTIMERS      ALL = NOPASSWD: ALL
5001 .RE
5002 .fi
5003 .PP
5004 Full time sysadmins
5005 (\fBmillert\fR,
5006 \fBmikef\fR,
5007 and
5008 \fBdowdy\fR)
5009 may run any command on any host without authenticating themselves.
5010 .nf
5011 .sp
5012 .RS 0n
5013 PARTTIMERS      ALL = ALL
5014 .RE
5015 .fi
5016 .PP
5017 Part time sysadmins
5018 \fBbostley\fR,
5019 \fBjwfox\fR,
5020 and
5021 \fBcrawl\fR)
5022 may run any command on any host but they must authenticate themselves
5023 first (since the entry lacks the
5024 \fRNOPASSWD\fR
5025 tag).
5026 .nf
5027 .sp
5028 .RS 0n
5029 jack            CSNETS = ALL
5030 .RE
5031 .fi
5032 .PP
5033 The user
5034 \fBjack\fR
5035 may run any command on the machines in the
5036 \fICSNETS\fR
5037 alias (the networks
5038 \fR128.138.243.0\fR,
5039 \fR128.138.204.0\fR,
5040 and
5041 \fR128.138.242.0\fR).
5042 Of those networks, only
5043 \fR128.138.204.0\fR
5044 has an explicit netmask (in CIDR notation) indicating it is a class C network.
5045 For the other networks in
5046 \fICSNETS\fR,
5047 the local machine's netmask will be used during matching.
5048 .nf
5049 .sp
5050 .RS 0n
5051 lisa            CUNETS = ALL
5052 .RE
5053 .fi
5054 .PP
5055 The user
5056 \fBlisa\fR
5057 may run any command on any host in the
5058 \fICUNETS\fR
5059 alias (the class B network
5060 \fR128.138.0.0\fR).
5061 .nf
5062 .sp
5063 .RS 0n
5064 operator        ALL = DUMPS, KILL, SHUTDOWN, HALT, REBOOT, PRINTING,\e
5065                 sudoedit /etc/printcap, /usr/oper/bin/
5066 .RE
5067 .fi
5068 .PP
5069 The
5070 \fBoperator\fR
5071 user may run commands limited to simple maintenance.
5072 Here, those are commands related to backups, killing processes, the
5073 printing system, shutting down the system, and any commands in the
5074 directory
5075 \fI/usr/oper/bin/\fR.
5076 Note that one command in the
5077 \fRDUMPS\fR
5078 Cmnd_Alias includes a sha224 digest,
5079 \fI/home/operator/bin/start_backups\fR.
5080 This is because the directory containing the script is writable by the
5081 operator user.
5082 If the script is modified (resulting in a digest mismatch) it will no longer
5083 be possible to run it via
5084 \fBsudo\fR.
5085 .nf
5086 .sp
5087 .RS 0n
5088 joe             ALL = /usr/bin/su operator
5089 .RE
5090 .fi
5091 .PP
5092 The user
5093 \fBjoe\fR
5094 may only
5095 su(1)
5096 to operator.
5097 .nf
5098 .sp
5099 .RS 0n
5100 pete            HPPA = /usr/bin/passwd [A-Za-z]*, !/usr/bin/passwd *root*
5101
5102 %opers          ALL = (: ADMINGRP) /usr/sbin/
5103 .RE
5104 .fi
5105 .PP
5106 Users in the
5107 \fBopers\fR
5108 group may run commands in
5109 \fI/usr/sbin/\fR
5110 as themselves
5111 with any group in the
5112 \fIADMINGRP\fR
5113 \fRRunas_Alias\fR
5114 (the
5115 \fBadm\fR
5116 and
5117 \fBoper\fR
5118 groups).
5119 .PP
5120 The user
5121 \fBpete\fR
5122 is allowed to change anyone's password except for
5123 root on the
5124 \fIHPPA\fR
5125 machines.
5126 Because command line arguments are matched as a single,
5127 concatenated string, the
5128 \(oq*\(cq
5129 wildcard will match
5130 \fImultiple\fR
5131 words.
5132 This example assumes that
5133 passwd(1)
5134 does not take multiple user names on the command line.
5135 Note that on GNU systems, options to
5136 passwd(1)
5137 may be specified after the user argument.
5138 As a result, this rule will also allow:
5139 .nf
5140 .sp
5141 .RS 4n
5142 passwd username --expire
5143 .RE
5144 .fi
5145 .PP
5146 which may not be desirable.
5147 .nf
5148 .sp
5149 .RS 0n
5150 bob             SPARC = (OP) ALL : SGI = (OP) ALL
5151 .RE
5152 .fi
5153 .PP
5154 The user
5155 \fBbob\fR
5156 may run anything on the
5157 \fISPARC\fR
5158 and
5159 \fISGI\fR
5160 machines as any user listed in the
5161 \fIOP\fR
5162 \fRRunas_Alias\fR
5163 (\fBroot\fR
5164 and
5165 \fBoperator\fR.)
5166 .nf
5167 .sp
5168 .RS 0n
5169 jim             +biglab = ALL
5170 .RE
5171 .fi
5172 .PP
5173 The user
5174 \fBjim\fR
5175 may run any command on machines in the
5176 \fIbiglab\fR
5177 netgroup.
5178 \fBsudo\fR
5179 knows that
5180 \(lqbiglab\(rq
5181 is a netgroup due to the
5182 \(oq+\(cq
5183 prefix.
5184 .nf
5185 .sp
5186 .RS 0n
5187 +secretaries    ALL = PRINTING, /usr/bin/adduser, /usr/bin/rmuser
5188 .RE
5189 .fi
5190 .PP
5191 Users in the
5192 \fBsecretaries\fR
5193 netgroup need to help manage the printers as well as add and remove users,
5194 so they are allowed to run those commands on all machines.
5195 .nf
5196 .sp
5197 .RS 0n
5198 fred            ALL = (DB) NOPASSWD: ALL
5199 .RE
5200 .fi
5201 .PP
5202 The user
5203 \fBfred\fR
5204 can run commands as any user in the
5205 \fIDB\fR
5206 \fRRunas_Alias\fR
5207 (\fBoracle\fR
5208 or
5209 \fBsybase\fR)
5210 without giving a password.
5211 .nf
5212 .sp
5213 .RS 0n
5214 john            ALPHA = /usr/bin/su [!-]*, !/usr/bin/su *root*
5215 .RE
5216 .fi
5217 .PP
5218 On the
5219 \fIALPHA\fR
5220 machines, user
5221 \fBjohn\fR
5222 may su to anyone except root but he is not allowed to specify any options
5223 to the
5224 su(1)
5225 command.
5226 .nf
5227 .sp
5228 .RS 0n
5229 jen             ALL, !SERVERS = ALL
5230 .RE
5231 .fi
5232 .PP
5233 The user
5234 \fBjen\fR
5235 may run any command on any machine except for those in the
5236 \fISERVERS\fR
5237 \fRHost_Alias\fR
5238 (master, mail, www and ns).
5239 .nf
5240 .sp
5241 .RS 0n
5242 jill            SERVERS = /usr/bin/, !SU, !SHELLS
5243 .RE
5244 .fi
5245 .PP
5246 For any machine in the
5247 \fISERVERS\fR
5248 \fRHost_Alias\fR,
5249 \fBjill\fR
5250 may run
5251 any commands in the directory
5252 \fI/usr/bin/\fR
5253 except for those commands
5254 belonging to the
5255 \fISU\fR
5256 and
5257 \fISHELLS\fR
5258 \fRCmnd_Aliases\fR.
5259 While not specifically mentioned in the rule, the commands in the
5260 \fIPAGERS\fR
5261 \fRCmnd_Alias\fR
5262 all reside in
5263 \fI/usr/bin\fR
5264 and have the
5265 \fInoexec\fR
5266 option set.
5267 .nf
5268 .sp
5269 .RS 0n
5270 steve           CSNETS = (operator) /usr/local/op_commands/
5271 .RE
5272 .fi
5273 .PP
5274 The user
5275 \fBsteve\fR
5276 may run any command in the directory /usr/local/op_commands/
5277 but only as user operator.
5278 .nf
5279 .sp
5280 .RS 0n
5281 matt            valkyrie = KILL
5282 .RE
5283 .fi
5284 .PP
5285 On his personal workstation, valkyrie,
5286 \fBmatt\fR
5287 needs to be able to kill hung processes.
5288 .nf
5289 .sp
5290 .RS 0n
5291 WEBMASTERS      www = (www) ALL, (root) /usr/bin/su www
5292 .RE
5293 .fi
5294 .PP
5295 On the host www, any user in the
5296 \fIWEBMASTERS\fR
5297 \fRUser_Alias\fR
5298 (will, wendy, and wim), may run any command as user www (which owns the
5299 web pages) or simply
5300 su(1)
5301 to www.
5302 .nf
5303 .sp
5304 .RS 0n
5305 ALL             CDROM = NOPASSWD: /sbin/umount /CDROM,\e
5306                 /sbin/mount -o nosuid\e,nodev /dev/cd0a /CDROM
5307 .RE
5308 .fi
5309 .PP
5310 Any user may mount or unmount a CD-ROM on the machines in the CDROM
5311 \fRHost_Alias\fR
5312 (orion, perseus, hercules) without entering a password.
5313 This is a bit tedious for users to type, so it is a prime candidate
5314 for encapsulating in a shell script.
5315 .SH "SECURITY NOTES"
5316 .SS "Limitations of the \(oq!\&\(cq operator"
5317 It is generally not effective to
5318 \(lqsubtract\(rq
5319 commands from
5320 \fBALL\fR
5321 using the
5322 \(oq!\&\(cq
5323 operator.
5324 A user can trivially circumvent this by copying the desired command
5325 to a different name and then executing that.
5326 For example:
5327 .nf
5328 .sp
5329 .RS 0n
5330 bill    ALL = ALL, !SU, !SHELLS
5331 .RE
5332 .fi
5333 .PP
5334 Doesn't really prevent
5335 \fBbill\fR
5336 from running the commands listed in
5337 \fISU\fR
5338 or
5339 \fISHELLS\fR
5340 since he can simply copy those commands to a different name, or use
5341 a shell escape from an editor or other program.
5342 Therefore, these kind of restrictions should be considered
5343 advisory at best (and reinforced by policy).
5344 .PP
5345 In general, if a user has sudo
5346 \fBALL\fR
5347 there is nothing to prevent them from creating their own program that gives
5348 them a root shell (or making their own copy of a shell) regardless of any
5349 \(oq!\&\(cq
5350 elements in the user specification.
5351 .SS "Security implications of \fIfast_glob\fR"
5352 If the
5353 \fIfast_glob\fR
5354 option is in use, it is not possible to reliably negate commands where the
5355 path name includes globbing (aka wildcard) characters.
5356 This is because the C library's
5357 fnmatch(3)
5358 function cannot resolve relative paths.
5359 While this is typically only an inconvenience for rules that grant privileges,
5360 it can result in a security issue for rules that subtract or revoke privileges.
5361 .PP
5362 For example, given the following
5363 \fIsudoers\fR
5364 file entry:
5365 .nf
5366 .sp
5367 .RS 0n
5368 john    ALL = /usr/bin/passwd [a-zA-Z0-9]*, /usr/bin/chsh [a-zA-Z0-9]*,\e
5369               /usr/bin/chfn [a-zA-Z0-9]*, !/usr/bin/* root
5370 .RE
5371 .fi
5372 .PP
5373 User
5374 \fBjohn\fR
5375 can still run
5376 \fR/usr/bin/passwd root\fR
5377 if
5378 \fIfast_glob\fR
5379 is enabled by changing to
5380 \fI/usr/bin\fR
5381 and running
5382 \fR./passwd root\fR
5383 instead.
5384 .SS "Preventing shell escapes"
5385 Once
5386 \fBsudo\fR
5387 executes a program, that program is free to do whatever
5388 it pleases, including run other programs.
5389 This can be a security issue since it is not uncommon for a program to
5390 allow shell escapes, which lets a user bypass
5391 \fBsudo\fR's
5392 access control and logging.
5393 Common programs that permit shell escapes include shells (obviously),
5394 editors, paginators, mail and terminal programs.
5395 .PP
5396 There are two basic approaches to this problem:
5397 .TP 10n
5398 restrict
5399 Avoid giving users access to commands that allow the user to run
5400 arbitrary commands.
5401 Many editors have a restricted mode where shell
5402 escapes are disabled, though
5403 \fBsudoedit\fR
5404 is a better solution to
5405 running editors via
5406 \fBsudo\fR.
5407 Due to the large number of programs that
5408 offer shell escapes, restricting users to the set of programs that
5409 do not is often unworkable.
5410 .TP 10n
5411 noexec
5412 Many systems that support shared libraries have the ability to
5413 override default library functions by pointing an environment
5414 variable (usually
5415 \fRLD_PRELOAD\fR)
5416 to an alternate shared library.
5417 On such systems,
5418 \fBsudo\fR's
5419 \fInoexec\fR
5420 functionality can be used to prevent a program run by
5421 \fBsudo\fR
5422 from executing any other programs.
5423 Note, however, that this applies only to native dynamically-linked
5424 executables.
5425 Statically-linked executables and foreign executables
5426 running under binary emulation are not affected.
5427 .sp
5428 The
5429 \fInoexec\fR
5430 feature is known to work on SunOS, Solaris, *BSD,
5431 Linux, IRIX, Tru64 UNIX, macOS, HP-UX 11.x and AIX 5.3 and above.
5432 It should be supported on most operating systems that support the
5433 \fRLD_PRELOAD\fR
5434 environment variable.
5435 Check your operating system's manual pages for the dynamic linker
5436 (usually ld.so, ld.so.1, dyld, dld.sl, rld, or loader) to see if
5437 \fRLD_PRELOAD\fR
5438 is supported.
5439 .sp
5440 On Solaris 10 and higher,
5441 \fInoexec\fR
5442 uses Solaris privileges instead of the
5443 \fRLD_PRELOAD\fR
5444 environment variable.
5445 .sp
5446 To enable
5447 \fInoexec\fR
5448 for a command, use the
5449 \fRNOEXEC\fR
5450 tag as documented
5451 in the User Specification section above.
5452 Here is that example again:
5453 .nf
5454 .sp
5455 .RS 10n
5456 aaron   shanty = NOEXEC: /usr/bin/more, /usr/bin/vi
5457 .RE
5458 .fi
5459 .RS 10n
5460 .sp
5461 This allows user
5462 \fBaaron\fR
5463 to run
5464 \fI/usr/bin/more\fR
5465 and
5466 \fI/usr/bin/vi\fR
5467 with
5468 \fInoexec\fR
5469 enabled.
5470 This will prevent those two commands from
5471 executing other commands (such as a shell).
5472 If you are unsure whether or not your system is capable of supporting
5473 \fInoexec\fR
5474 you can always just try it out and check whether shell escapes work when
5475 \fInoexec\fR
5476 is enabled.
5477 .RE
5478 .PP
5479 Note that restricting shell escapes is not a panacea.
5480 Programs running as root are still capable of many potentially hazardous
5481 operations (such as changing or overwriting files) that could lead
5482 to unintended privilege escalation.
5483 In the specific case of an editor, a safer approach is to give the
5484 user permission to run
5485 \fBsudoedit\fR
5486 (see below).
5487 .SS "Secure editing"
5488 The
5489 \fBsudoers\fR
5490 plugin includes
5491 \fBsudoedit\fR
5492 support which allows users to securely edit files with the editor
5493 of their choice.
5494 As
5495 \fBsudoedit\fR
5496 is a built-in command, it must be specified in the
5497 \fIsudoers\fR
5498 file without a leading path.
5499 However, it may take command line arguments just as a normal command does.
5500 Wildcards used in
5501 \fIsudoedit\fR
5502 command line arguments are expected to be path names, so a forward slash
5503 (\(oq/\(cq)
5504 will not be matched by a wildcard.
5505 .PP
5506 Unlike other
5507 \fBsudo\fR
5508 commands, the editor is run with the permissions of the invoking
5509 user and with the environment unmodified.
5510 More information may be found in the description of the
5511 \fB\-e\fR
5512 option in
5513 sudo(@mansectsu@).
5514 .PP
5515 For example, to allow user operator to edit the
5516 \(lqmessage of the day\(rq
5517 file:
5518 .nf
5519 .sp
5520 .RS 6n
5521 operator        sudoedit /etc/motd
5522 .RE
5523 .fi
5524 .PP
5525 The operator user then runs
5526 \fBsudoedit\fR
5527 as follows:
5528 .nf
5529 .sp
5530 .RS 6n
5531 $ sudoedit /etc/motd
5532 .RE
5533 .fi
5534 .PP
5535 The editor will run as the operator user, not root, on a temporary copy of
5536 \fI/etc/motd\fR.
5537 After the file has been edited,
5538 \fI/etc/motd\fR
5539 will be updated with the contents of the temporary copy.
5540 .PP
5541 Users should
5542 \fInever\fR
5543 be granted
5544 \fBsudoedit\fR
5545 permission to edit a file that resides in a directory the user
5546 has write access to, either directly or via a wildcard.
5547 If the user has write access to the directory it is possible to
5548 replace the legitimate file with a link to another file,
5549 allowing the editing of arbitrary files.
5550 To prevent this, starting with version 1.8.16, symbolic links will
5551 not be followed in writable directories and
5552 \fBsudoedit\fR
5553 will refuse to edit a file located in a writable directory
5554 unless the
5555 \fIsudoedit_checkdir\fR
5556 option has been disabled or the invoking user is root.
5557 Additionally, in version 1.8.15 and higher,
5558 \fBsudoedit\fR
5559 will refuse to open a symbolic link unless either the
5560 \fIsudoedit_follow\fR
5561 option is enabled or the
5562 \fIsudoedit\fR
5563 command is prefixed with the
5564 \fRFOLLOW\fR
5565 tag in the
5566 \fIsudoers\fR
5567 file.
5568 .SS "Time stamp file checks"
5569 \fBsudoers\fR
5570 will check the ownership of its time stamp directory
5571 (\fI@rundir@/ts\fR
5572 by default)
5573 and ignore the directory's contents if it is not owned by root or
5574 if it is writable by a user other than root.
5575 Older versions of
5576 \fBsudo\fR
5577 stored time stamp files in
5578 \fI/tmp\fR;
5579 this is no longer recommended as it may be possible for a user
5580 to create the time stamp themselves on systems that allow
5581 unprivileged users to change the ownership of files they create.
5582 .PP
5583 While the time stamp directory
5584 \fIshould\fR
5585 be cleared at reboot time, not all systems contain a
5586 \fI/run\fR
5587 or
5588 \fI/var/run\fR
5589 directory.
5590 To avoid potential problems,
5591 \fBsudoers\fR
5592 will ignore time stamp files that date from before the machine booted
5593 on systems where the boot time is available.
5594 .PP
5595 Some systems with graphical desktop environments allow unprivileged
5596 users to change the system clock.
5597 Since
5598 \fBsudoers\fR
5599 relies on the system clock for time stamp validation, it may be
5600 possible on such systems for a user to run
5601 \fBsudo\fR
5602 for longer than
5603 \fItimestamp_timeout\fR
5604 by setting the clock back.
5605 To combat this,
5606 \fBsudoers\fR
5607 uses a monotonic clock (which never moves backwards) for its time stamps
5608 if the system supports it.
5609 .PP
5610 \fBsudoers\fR
5611 will not honor time stamps set far in the future.
5612 Time stamps with a date greater than current_time + 2 *
5613 \fRTIMEOUT\fR
5614 will be ignored and
5615 \fBsudoers\fR
5616 will log and complain.
5617 .PP
5618 If the
5619 \fItimestamp_type\fR
5620 option is set to
5621 \(lqtty\(rq,
5622 the time stamp record includes the device number of the terminal
5623 the user authenticated with.
5624 This provides per-terminal granularity but time stamp records may still
5625 outlive the user's session.
5626 .PP
5627 Unless the
5628 \fItimestamp_type\fR
5629 option is set to
5630 \(lqglobal\(rq,
5631 the time stamp record also includes the session ID of the process
5632 that last authenticated.
5633 This prevents processes in different terminal sessions from using
5634 the same time stamp record.
5635 On systems where a process's start time can be queried,
5636 the start time of the session leader
5637 is recorded in the time stamp record.
5638 If no terminal is present or the
5639 \fItimestamp_type\fR
5640 option is set to
5641 \(lqppid\(rq,
5642 the start time of the parent process is used instead.
5643 In most cases this will prevent a time stamp record from being re-used
5644 without the user entering a password when logging out and back in again.
5645 .SH "DEBUGGING"
5646 Versions 1.8.4 and higher of the
5647 \fBsudoers\fR
5648 plugin support a flexible debugging framework that can help track
5649 down what the plugin is doing internally if there is a problem.
5650 This can be configured in the
5651 sudo.conf(@mansectform@)
5652 file.
5653 .PP
5654 The
5655 \fBsudoers\fR
5656 plugin uses the same debug flag format as the
5657 \fBsudo\fR
5658 front-end:
5659 \fIsubsystem\fR@\fIpriority\fR.
5660 .PP
5661 The priorities used by
5662 \fBsudoers\fR,
5663 in order of decreasing severity,
5664 are:
5665 \fIcrit\fR, \fIerr\fR, \fIwarn\fR, \fInotice\fR, \fIdiag\fR, \fIinfo\fR, \fItrace\fR
5666 and
5667 \fIdebug\fR.
5668 Each priority, when specified, also includes all priorities higher
5669 than it.
5670 For example, a priority of
5671 \fInotice\fR
5672 would include debug messages logged at
5673 \fInotice\fR
5674 and higher.
5675 .PP
5676 The following subsystems are used by the
5677 \fBsudoers\fR
5678 plugin:
5679 .TP 10n
5680 \fIalias\fR
5681 \fRUser_Alias\fR,
5682 \fRRunas_Alias\fR,
5683 \fRHost_Alias\fR
5684 and
5685 \fRCmnd_Alias\fR
5686 processing
5687 .TP 10n
5688 \fIall\fR
5689 matches every subsystem
5690 .TP 10n
5691 \fIaudit\fR
5692 BSM and Linux audit code
5693 .TP 10n
5694 \fIauth\fR
5695 user authentication
5696 .TP 10n
5697 \fIdefaults\fR
5698 \fIsudoers\fR
5699 file
5700 \fIDefaults\fR
5701 settings
5702 .TP 10n
5703 \fIenv\fR
5704 environment handling
5705 .TP 10n
5706 \fIldap\fR
5707 LDAP-based sudoers
5708 .TP 10n
5709 \fIlogging\fR
5710 logging support
5711 .TP 10n
5712 \fImatch\fR
5713 matching of users, groups, hosts and netgroups in the
5714 \fIsudoers\fR
5715 file
5716 .TP 10n
5717 \fInetif\fR
5718 network interface handling
5719 .TP 10n
5720 \fInss\fR
5721 network service switch handling in
5722 \fBsudoers\fR
5723 .TP 10n
5724 \fIparser\fR
5725 \fIsudoers\fR
5726 file parsing
5727 .TP 10n
5728 \fIperms\fR
5729 permission setting
5730 .TP 10n
5731 \fIplugin\fR
5732 The equivalent of
5733 \fImain\fR
5734 for the plugin.
5735 .TP 10n
5736 \fIpty\fR
5737 pseudo-tty related code
5738 .TP 10n
5739 \fIrbtree\fR
5740 redblack tree internals
5741 .TP 10n
5742 \fIsssd\fR
5743 SSSD-based sudoers
5744 .TP 10n
5745 \fIutil\fR
5746 utility functions
5747 .PD 0
5748 .PP
5749 For example:
5750 .nf
5751 .sp
5752 .RS 0n
5753 Debug sudo /var/log/sudo_debug match@info,nss@info
5754 .RE
5755 .fi
5756 .PD
5757 .PP
5758 For more information, see the
5759 sudo.conf(@mansectform@)
5760 manual.
5761 .SH "SEE ALSO"
5762 ssh(1),
5763 su(1),
5764 fnmatch(3),
5765 glob(3),
5766 mktemp(3),
5767 strftime(3),
5768 sudo.conf(@mansectform@),
5769 sudo_plugin(@mansectform@),
5770 sudoers.ldap(@mansectform@),
5771 sudoers_timestamp(@mansectform@),
5772 sudo(@mansectsu@),
5773 visudo(@mansectsu@)
5774 .SH "AUTHORS"
5775 Many people have worked on
5776 \fBsudo\fR
5777 over the years; this version consists of code written primarily by:
5778 .sp
5779 .RS 6n
5780 Todd C. Miller
5781 .RE
5782 .PP
5783 See the CONTRIBUTORS file in the
5784 \fBsudo\fR
5785 distribution (https://www.sudo.ws/contributors.html) for an
5786 exhaustive list of people who have contributed to
5787 \fBsudo\fR.
5788 .SH "CAVEATS"
5789 The
5790 \fIsudoers\fR
5791 file should
5792 \fBalways\fR
5793 be edited by the
5794 \fBvisudo\fR
5795 command which locks the file and does grammatical checking.
5796 It is
5797 imperative that the
5798 \fIsudoers\fR
5799 file be free of syntax errors since
5800 \fBsudo\fR
5801 will not run with a syntactically incorrect
5802 \fIsudoers\fR
5803 file.
5804 .PP
5805 When using netgroups of machines (as opposed to users), if you
5806 store fully qualified host name in the netgroup (as is usually the
5807 case), you either need to have the machine's host name be fully qualified
5808 as returned by the
5809 \fRhostname\fR
5810 command or use the
5811 \fIfqdn\fR
5812 option in
5813 \fIsudoers\fR.
5814 .SH "BUGS"
5815 If you feel you have found a bug in
5816 \fBsudo\fR,
5817 please submit a bug report at https://bugzilla.sudo.ws/
5818 .SH "SUPPORT"
5819 Limited free support is available via the sudo-users mailing list,
5820 see https://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or
5821 search the archives.
5822 .SH "DISCLAIMER"
5823 \fBsudo\fR
5824 is provided
5825 \(lqAS IS\(rq
5826 and any express or implied warranties, including, but not limited
5827 to, the implied warranties of merchantability and fitness for a
5828 particular purpose are disclaimed.
5829 See the LICENSE file distributed with
5830 \fBsudo\fR
5831 or https://www.sudo.ws/license.html for complete details.