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