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