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