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