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