-
-
Notifications
You must be signed in to change notification settings - Fork 280
Expand file tree
/
Copy pathsudoers.mdoc.in
More file actions
7555 lines (7514 loc) · 184 KB
/
sudoers.mdoc.in
File metadata and controls
7555 lines (7514 loc) · 184 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.\"
.\" SPDX-License-Identifier: ISC
.\"
.\" Copyright (c) 1994-1996, 1998-2005, 2007-2025
.\" Todd C. Miller <[email protected]>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.\" Sponsored in part by the Defense Advanced Research Projects
.\" Agency (DARPA) and Air Force Research Laboratory, Air Force
.\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
.\"
.nr SL @SEMAN@
.nr AA @AAMAN@
.nr BA @BAMAN@
.nr LC @LCMAN@
.nr PS @PSMAN@
.Dd October 25, 2025
.Dt SUDOERS @mansectform@
.Os Sudo @PACKAGE_VERSION@
.Sh NAME
.Nm sudoers
.Nd default sudo security policy plugin
.Sh DESCRIPTION
The
.Nm
policy plugin determines a user's
.Nm sudo
privileges.
It is the default
.Nm sudo
policy plugin.
The policy is driven by
the
.Pa @sysconfdir@/sudoers
file or, optionally, in LDAP.
The policy format is described in detail in the
.Sx SUDOERS FILE FORMAT
section.
For information on storing
.Nm
policy information
in LDAP, see
.Xr sudoers.ldap @mansectform@ .
.Ss Configuring sudo.conf for sudoers
.Nm sudo
consults the
.Xr sudo.conf @mansectform@
file to determine which plugins to load.
If no
.Xr sudo.conf @mansectform@
file is present, or if it contains no
.Em Plugin
lines,
.Nm
will be used for auditing, policy decisions and I/O logging.
To explicitly configure
.Xr sudo.conf @mansectform@
to use the
.Nm
plugin, the following configuration can be used.
.Bd -literal -offset 4n
Plugin sudoers_audit @sudoers_plugin@
Plugin sudoers_policy @sudoers_plugin@
Plugin sudoers_io @sudoers_plugin@
.Ed
.Pp
Starting with
.Nm sudo
1.8.5, it is possible to specify optional arguments to the
.Nm
plugin in the
.Xr sudo.conf @mansectform@
file.
Plugin arguments, if any, should be listed after the path to the plugin
(i.e., after
.Pa @sudoers_plugin@ ) .
The arguments are only effective for the plugin that opens (and parses) the
.Em sudoers
file.
.Pp
For
.Nm sudo
version 1.9.1 and higher, this is the
.Em sudoers_audit
plugin.
For older versions, it is the
.Em sudoers_policy
plugin.
Multiple arguments may be specified, separated by white space.
For example:
.Bd -literal -offset 4n
Plugin sudoers_audit @sudoers_plugin@ sudoers_mode=0400 error_recovery=false
.Ed
.Pp
The following plugin arguments are supported:
.Bl -tag -width 4n
.It error_recovery=bool
The
.Em error_recovery
argument can be used to control whether
.Nm
should attempt to recover from syntax errors in the
.Em sudoers
file.
If set to
.Em true
(the default),
.Nm
will try to recover from a syntax error by discarding the portion
of the line that contains the error until the end of the line.
A value of
.Em false
will disable error recovery.
Prior to version 1.9.3, no error recovery was performed.
.It ignore_perms=bool
The
.Em ignore_perms
argument can be used to disable security checks when loading the
.Em sudoers
file.
If enabled, the
.Em sudoers
file will be loaded regardless of the owner or file mode.
This argument is intended to be used for testing purposes and
should not be enabled on production systems.
.It ldap_conf=pathname
The
.Em ldap_conf
argument can be used to override the default path to the
.Pa ldap.conf
file.
.It ldap_secret=pathname
The
.Em ldap_secret
argument can be used to override the default path to the
.Pa ldap.secret
file.
.It sudoers_file=pathname
The
.Em sudoers_file
argument can be used to override the default path to the
.Em sudoers
file.
.It sudoers_uid=user-ID
The
.Em sudoers_uid
argument can be used to override the default owner of the sudoers file.
It should be specified as a numeric user-ID.
.It sudoers_gid=group-ID
The
.Em sudoers_gid
argument can be used to override the default group of the sudoers file.
It must be specified as a numeric group-ID (not a group name).
.It sudoers_mode=mode
The
.Em sudoers_mode
argument can be used to override the default file mode for the sudoers file.
It should be specified as an octal value.
.El
.Pp
For more information on configuring
.Xr sudo.conf @mansectform@ ,
refer to its manual.
.Ss User Authentication
The
.Nm
security policy requires that most users authenticate
themselves before they can use
.Nm sudo .
A password is not required
if the invoking user is
.Sy root ,
if the target user is the same as the invoking user, or if the
policy has disabled authentication for the user or command.
Unlike
.Xr su 1 ,
when
.Nm
requires
authentication, it validates the invoking user's credentials, not
the target user's (or
.Sy @runas_default@ Ns No 's )
credentials.
This can be changed via
the
.Em rootpw ,
.Em targetpw
and
.Em runaspw
flags, described later.
.Pp
If a user who is not listed in the policy tries to run a command
via
.Nm sudo ,
mail is sent to the proper authorities.
The address
used for such mail is configurable via the
.Em mailto
Defaults entry
(described later) and defaults to
.Em @mailto@ .
.Pp
No mail will be sent if an unauthorized user tries to run
.Nm sudo
with the
.Fl l
or
.Fl v
option unless there is an authentication error and
either the
.Em mail_always
or
.Em mail_badpass
flags are enabled.
This allows users to
determine for themselves whether or not they are allowed to use
.Nm sudo .
By default, all attempts to run
.Nm sudo
(successful or not)
are logged, regardless of whether or not mail is sent.
.Pp
If
.Nm sudo
is run by
.Sy root
and the
.Ev SUDO_USER
environment variable
is set, the
.Nm
policy will use this value to determine who
the actual user is.
This can be used by a user to log commands
through sudo even when a
.Sy root
shell has been invoked.
It also
allows the
.Fl e
option to remain useful even when invoked via a
sudo-run script or program.
Note, however, that the
.Em sudoers
file lookup is still done for
.Sy root ,
not the user specified by
.Ev SUDO_USER .
.Pp
.Nm
uses per-user time stamp files for credential caching.
Once a user has been authenticated, a record is written
containing the user-ID that was used to authenticate, the
terminal session ID, the start time of the session leader
(or parent process) and a time stamp
(using a monotonic clock if one is available).
The user may then use
.Nm sudo
without a password for a short period of time (@timeout@ minutes
unless overridden by the
.Em timestamp_timeout
option).
By default,
.Nm
uses a separate record for each terminal, which means that
a user's login sessions are authenticated separately.
The
.Em timestamp_type
option can be used to select the type of time stamp record
.Nm
will use.
.Pp
The
.Nm tsdump
utility, included with the sudo source distribution, can be used to
display the contents of a time stamp file.
See
.Xr sudoers_timestamp @mansectform@
for details of the time stamp file format.
.Ss Logging
By default,
.Nm
logs both successful and unsuccessful attempts (as well
as errors).
The
.Em log_allowed
and
.Em log_denied
flags can be used to control this behavior.
Messages can be logged to
.Xr syslog 3 ,
a log file, or both.
The default is to log to
.Xr syslog 3
but this is configurable via the
.Em syslog
and
.Em logfile
settings.
See
.Sx "EVENT LOGGING"
for a description of the log file format.
.Pp
.Nm
is also capable of running a command in a pseudo-terminal and logging
input and/or output.
The standard input, standard output, and standard error can be logged
even when not associated with a terminal.
For more information about I/O logging, see the
.Sx "I/O LOGGING"
section.
.Pp
Starting with version 1.9, the
.Em log_servers
setting may be used to send event and I/O log data to a remote server running
.Nm sudo_logsrvd
or another service that implements the protocol described by
.Xr sudo_logsrv.proto @mansectform@ .
.Ss Command environment
Since environment variables can influence program behavior,
.Nm
provides a means to restrict which variables from the user's
environment are inherited by the command to be run.
There are two
distinct ways
.Nm
can deal with environment variables.
.Pp
By default, the
.Em env_reset
flag is enabled.
This causes commands
to be executed with a new, minimal environment.
On AIX (and Linux
systems without PAM), the environment is initialized with the
contents of the
.Pa /etc/environment
file.
.if \n(LC \{\
On
.Bx
systems, if the
.Em use_loginclass
flag is enabled, the environment is initialized
based on the
.Em path
and
.Em setenv
settings in
.Pa /etc/login.conf .
.\}
The
.Ev HOME ,
.Ev MAIL ,
.Ev SHELL ,
.Ev LOGNAME
and
.Ev USER
environment variables are initialized based on the target user
and the
.Ev SUDO_*
variables are set based on the invoking user.
Additional variables, such as
.Ev DISPLAY ,
.Ev PATH
and
.Ev TERM ,
are preserved from the invoking user's environment if permitted by the
.Em env_check ,
or
.Em env_keep
options.
A few environment variables are treated specially.
If the
.Ev PATH
and
.Ev TERM
variables are not preserved from the user's environment, they will be set
to default values.
The
.Ev LOGNAME
and
.Ev USER
are handled as a single entity.
If one of them is preserved (or removed) from the user's environment,
the other will be as well.
If
.Ev LOGNAME
and
.Ev USER
are to be preserved but only one of them is present in the user's environment,
the other will be set to the same value.
This avoids an inconsistent environment where one of the variables
describing the user name is set to the invoking user and one is
set to the target user.
Environment variables with a value beginning with
.Ql ()
are removed unless both the name and value parts are matched by
.Em env_keep
or
.Em env_check ,
as they may be interpreted as functions by the
.Sy bash
shell.
Prior to version 1.8.11, such variables were always removed.
.Pp
If, however, the
.Em env_reset
flag is disabled, any variables not
explicitly denied by the
.Em env_check
and
.Em env_delete
options are allowed and their values are
inherited from the invoking process.
Prior to version 1.8.21, environment variables with a value beginning with
.Ql ()
were always removed.
Beginning with version 1.8.21, a pattern in
.Em env_delete
is used to match
.Sy bash
shell functions instead.
Since it is not possible
to block all potentially dangerous environment variables, use
of the default
.Em env_reset
behavior is encouraged.
.Pp
Environment variables specified by
.Em env_check ,
.Em env_delete ,
or
.Em env_keep
may include one or more
.Ql *
characters which will match zero or more characters.
No other wildcard characters are supported.
.Pp
By default, environment variables are matched by name.
However, if the pattern includes an equal sign
.Pq Ql =\& ,
both the variables name and value must match.
For example, a
.Sy bash
shell function could be matched as follows:
.Bd -literal -offset 4n
env_keep += "BASH_FUNC_my_func%%=()*"
.Ed
.Pp
Without the
.Ql =()*
suffix, this would not match, as
.Sy bash
shell functions are not preserved by default.
.Pp
The complete list of environment variables that are preserved or removed,
as modified by global Defaults parameters in
.Em sudoers ,
is displayed when
.Nm sudo
is run by
.Sy root
with the
.Fl V
option.
The list of environment variables to remove
varies based on the operating system
.Nm sudo
is running on.
.Pp
Other settings may influence the command environment:
.Bl -bullet -width 1n
.It
.Nm
options such as
.Em always_set_home ,
.Em secure_path ,
.Em set_logname ,
.Em set_home ,
and
.Em setenv .
.It
Command tags, such as
.Dv SETENV
and
.Dv NOSETENV .
Note that
.Dv SETENV
is implied if the command matched is
.Sy ALL .
.It
.Nm sudo
options, such as
.Fl E
and
.Fl i .
.El
.Pp
On systems that support PAM where the
.Sy pam_env
module is enabled for
.Nm sudo ,
variables in the PAM environment may be merged in to the environment.
If a variable in the PAM environment is already present in the
user's environment, the value will only be overridden if the variable
was not preserved by
.Nm .
When
.Em env_reset
is enabled, variables preserved from the invoking user's environment
by the
.Em env_keep
list take precedence over those in the PAM environment.
When
.Em env_reset
is disabled, variables present the invoking user's environment
take precedence over those in the PAM environment unless they
match a pattern in the
.Em env_delete
list.
.Pp
The dynamic linker on most operating systems will remove variables
that can control dynamic linking from the environment of set-user-ID
executables, including
.Nm sudo .
Depending on the operating
system this may include
.Ev _RLD* ,
.Ev DYLD_* ,
.Ev LD_* ,
.Ev LDR_* ,
.Ev LIBPATH ,
.Ev SHLIB_PATH ,
and others.
These type of variables are
removed from the environment before
.Nm sudo
even begins execution
and, as such, it is not possible for
.Nm sudo
to preserve them.
.Pp
As a special case, if the
.Fl i
option (initial login) is
specified,
.Nm
will initialize the environment regardless
of the value of
.Em env_reset .
The
.Ev DISPLAY ,
.Ev PATH
and
.Ev TERM
variables remain unchanged;
.Ev HOME ,
.Ev MAIL ,
.Ev SHELL ,
.Ev USER ,
and
.Ev LOGNAME
are set based on the target user.
On AIX (and Linux
systems without PAM), the contents of
.Pa /etc/environment
are also
included.
.if \n(LC \{\
On
.Bx
systems, if the
.Em use_loginclass
flag is
enabled, the
.Em path
and
.Em setenv
variables in
.Pa /etc/login.conf
are also applied.
.\}
All other environment variables are removed unless permitted by
.Em env_keep
or
.Em env_check ,
described above.
.Pp
Finally, the
.Em restricted_env_file
and
.Em env_file
files are applied, if present.
The variables in
.Em restricted_env_file
are applied first and are subject to the same restrictions as the
invoking user's environment, as detailed above.
The variables in
.Em env_file
are applied last and are not subject to these restrictions.
In both cases, variables present in the files will only be set to
their specified values if they would not conflict with an existing
environment variable.
.Sh SUDOERS FILE FORMAT
The
.Em sudoers
file is composed of two types of entries: aliases
(basically variables) and user specifications (which specify who
may run what).
.Pp
When multiple entries match for a user, they are applied in order.
Where there are multiple matches, the last match is used (which is
not necessarily the most specific match).
.Pp
The
.Em sudoers
file grammar will be described below in Extended Backus-Naur
Form (EBNF).
Don't despair if you are unfamiliar with EBNF; it is fairly simple,
and the definitions below are annotated.
.Ss Resource limits
By default,
.Nm
uses the operating system's native method of setting resource limits
for the target user.
On Linux systems, resource limits are usually set by the
.Pa pam_limits.so
PAM module.
On some BSD systems, the
.Pa /etc/login.conf
file specifies resource limits for the user.
On AIX systems, resource limits are configured in the
.Pa /etc/security/limits
file.
If there is no system mechanism to set per-user resource limits,
the command will run with the same limits as the invoking user.
The one exception to this is the core dump file size, which is set by
.Nm
to 0 by default.
Disabling core dumps by default makes it possible to avoid potential
security problems where the core file is treated as trusted input.
.Pp
Resource limits may also be set in the
.Em sudoers
file itself, in which case they override those set by the system.
See the
.Em rlimit_as ,
.Em rlimit_core ,
.Em rlimit_cpu ,
.Em rlimit_data ,
.Em rlimit_fsize ,
.Em rlimit_locks ,
.Em rlimit_memlock ,
.Em rlimit_nofile ,
.Em rlimit_nproc ,
.Em rlimit_rss ,
.Em rlimit_stack
options described below.
Resource limits in
.Nm
may be specified in one of the following formats:
.Bl -tag -width 6n
.It Dq value
Both the soft and hard resource limits are set to the same value.
The special value
.Dq infinity
can be used to indicate that the value is unlimited.
.It Dq soft,hard
Two comma-separated values.
The soft limit is set to the first value and the hard limit is set
to the second.
Both values must either be enclosed in a set of double quotes,
or the comma must be escaped with a backslash
.Pq Ql \e .
The special value
.Dq infinity
may be used in place of either value.
.It Dq default
The default resource limit for the user will be used.
This may be a user-specific value (see above) or the value of the
resource limit when
.Nm sudo
was invoked for systems that don't support per-user limits.
.It Dq user
The invoking user's resource limits will be preserved when running
the command.
.El
.Pp
For example, to restore the historic core dump file size behavior,
a line like the following may be used.
.sp
.Dl Defaults rlimit_core=default
.Pp
Resource limits in
.Nm
are only supported by version 1.8.7 or higher.
.Ss Quick guide to EBNF
EBNF is a concise and exact way of describing the grammar of a language.
Each EBNF definition is made up of
.Em production rules .
For example:
.Bd -literal -offset 4n
symbol ::= definition | alternate1 | alternate2 ...
.Ed
.Pp
Each
.Em production rule
references others and thus makes up a
grammar for the language.
EBNF also contains the following
operators, which many readers will recognize from regular
expressions.
Do not, however, confuse them with
.Dq wildcard
characters, which have different meanings.
.Bl -tag -width 4n
.It \&?
Means that the preceding symbol (or group of symbols) is optional.
That is, it may appear once or not at all.
.It *
Means that the preceding symbol (or group of symbols) may appear
zero or more times.
.It +
Means that the preceding symbol (or group of symbols) may appear
one or more times.
.El
.Pp
Parentheses may be used to group symbols together.
For clarity,
we will use single quotes
.Pq ''
to designate what is a verbatim character string (as opposed to a symbol name).
.Ss Aliases
There are four kinds of aliases:
.Em User_Alias ,
.Em Runas_Alias ,
.Em Host_Alias
and
.Em Cmnd_Alias .
Beginning with
.Nm sudo
1.9.0,
.Em Cmd_Alias
may be used in place of
.Em Cmnd_Alias
if desired.
.Bd -literal
Alias ::= 'User_Alias' User_Alias_Spec (':' User_Alias_Spec)* |
'Runas_Alias' Runas_Alias_Spec (':' Runas_Alias_Spec)* |
'Host_Alias' Host_Alias_Spec (':' Host_Alias_Spec)* |
'Cmnd_Alias' Cmnd_Alias_Spec (':' Cmnd_Alias_Spec)* |
'Cmd_Alias' Cmnd_Alias_Spec (':' Cmnd_Alias_Spec)*
User_Alias ::= NAME
User_Alias_Spec ::= User_Alias '=' User_List
Runas_Alias ::= NAME
Runas_Alias_Spec ::= Runas_Alias '=' Runas_List
Host_Alias ::= NAME
Host_Alias_Spec ::= Host_Alias '=' Host_List
Cmnd_Alias ::= NAME
Cmnd_Alias_Spec ::= Cmnd_Alias '=' Cmnd_List
NAME ::= [A\(enZ]([A\(enZ][0\(en9]_)*
.Ed
.Pp
Each
.Em alias
definition is of the form
.Bd -literal
Alias_Type NAME = item1, item2, ...
.Ed
.Pp
where
.Em Alias_Type
is one of
.Em User_Alias ,
.Em Runas_Alias ,
.Em Host_Alias ,
or
.Em Cmnd_Alias .
A
.Dv NAME
is a string of uppercase letters, numbers,
and underscore characters
.Pq Ql _ .
A
.Dv NAME
.Sy must
start with an
uppercase letter.
It is possible to put several alias definitions
of the same type on a single line, joined by a colon
.Pq Ql :\& .
For example:
.Bd -literal
Alias_Type NAME = item1, item2, item3 : NAME = item4, item5
.Ed
.Pp
It is a syntax error to redefine an existing
.Em alias .
It is possible to use the same name for
.Em aliases
of different types, but this is not recommended.
.Pp
The definitions of what constitutes a valid
.Em alias
member follow.
.Bd -literal
User_List ::= User |
User ',' User_List
User ::= '!'* user name |
'!'* #user-ID |
'!'* %group |
'!'* %#group-ID |
'!'* +netgroup |
'!'* %:nonunix_group |
'!'* %:#nonunix_gid |
'!'* User_Alias
.Ed
.Pp
A
.Em User_List
is made up of one or more user names, user-IDs
(prefixed with
.Ql # ) ,
system group names and IDs (prefixed with
.Ql %
and
.Ql %#
respectively), netgroups (prefixed with
.Ql + ) ,
non-Unix group names and IDs (prefixed with
.Ql %:
and
.Ql %:#
respectively), and
.Em User_Alias Ns es.
Each list item may be prefixed with zero or more
.Ql \&!
operators.
An odd number of
.Ql \&!
operators negate the value of
the item; an even number just cancel each other out.
User netgroups are matched using the user and domain members only;
the host member is not used when matching.
.Pp
A
.Em user name ,
.Em user-ID ,
.Em group ,
.Em group-ID ,
.Em netgroup ,
.Em nonunix_group
or
.Em nonunix_gid
may be enclosed in double quotes to avoid the
need for escaping special characters.
Alternately, special characters
may be specified in escaped hex mode, e.g., \ex20 for space.
When
using double quotes, any prefix characters must be included inside
the quotes.
.Pp
The actual
.Em nonunix_group
and
.Em nonunix_gid
syntax depends on
the underlying group provider plugin.
For instance, the QAS AD plugin supports the following formats:
.Bl -bullet -width 1n
.It
Group in the same domain: "%:Group Name"
.It
Group in any domain: "%:Group [email protected]"
.It
Group SID: "%:S\-1\-2\-34\-5678901234\-5678901234\-5678901234\-567"
.El
.Pp
See
.Sx "GROUP PROVIDER PLUGINS"
for more information.
.Pp
Quotes around group names are optional.
Unquoted strings must use a backslash
.Pq Ql \e
to escape spaces and special characters.
See
.Sx Other special characters and reserved words
for a list of
characters that need to be escaped.
.Bd -literal
Runas_List ::= Runas_Member |
Runas_Member ',' Runas_List
Runas_Member ::= '!'* user name |
'!'* #user-ID |
'!'* %group |
'!'* %#group-ID |
'!'* %:nonunix_group |
'!'* %:#nonunix_gid |
'!'* +netgroup |
'!'* Runas_Alias |
'!'* ALL
.Ed
.Pp
A
.Em Runas_List
is similar to a
.Em User_List
except that instead
of
.Em User_Alias Ns es
it can contain
.Em Runas_Alias Ns es .
User names and groups are matched as strings.
In other words, two users (groups) with the same user (group) ID
are considered to be distinct.
If you wish to match all user names with the same user-ID (e.g.,
.Sy root
and
.Sy toor ) ,
you can use a user-ID instead of a name (#0 in the example given).
The user-ID or group-ID specified in a
.Em Runas_Member
need not be listed in the password or group database.
.Bd -literal
Host_List ::= Host |
Host ',' Host_List
Host ::= '!'* host name |
'!'* ip_addr |
'!'* network(/netmask)? |
'!'* +netgroup |
'!'* Host_Alias |
'!'* ALL
.Ed
.Pp
A
.Em Host_List
is made up of one or more host names, IP addresses,
network numbers, netgroups (prefixed with
.Ql + ) ,
and other aliases.
Again, the value of an item may be negated with the
.Ql \&!
operator.
Host netgroups are matched using the host (both qualified and unqualified)
and domain members only; the user member is not used when matching.
If you specify a network number without a netmask,
.Nm sudo
will query each of the local host's network interfaces and,
if the network number corresponds to one of the hosts's network
interfaces, will use the netmask of that interface.
The netmask may be specified either in standard IP address notation
(e.g., 255.255.255.0 or ffff:ffff:ffff:ffff::),
or CIDR notation (number of bits, e.g., 24 or 64).
A host name may include shell-style wildcards (see the
.Sx Wildcards
section below),
but unless the
.Em hostname
command on your machine returns the fully
qualified host name, you'll need to use the
.Em fqdn
flag for wildcards to be useful.
.Nm sudo
only inspects actual network interfaces; this means that IP address
127.0.0.1 (localhost) will never match.
Also, the host name
.Dq localhost
will only match if that is the actual host name, which is usually
only the case for non-networked systems.
.Bd -literal
digest ::= [A\(enFa\(enf0\(en9]+ |
[A\(enZa\(enz0\(en9\e+/=]+
Digest_Spec ::= "sha224" ':' digest |
"sha256" ':' digest |