Annotation of src/usr.bin/sudo/sudoers.5, Revision 1.14
1.9 millert 1: .\" Automatically generated by Pod::Man version 1.15
1.12 millert 2: .\" Thu Apr 25 09:34:54 2002
1.14 ! millert 3: .\"
! 4: .\" Copyright (c) 1994-1996,1998-2001 Todd C. Miller <Todd.Miller@courtesan.com>
! 5: .\" All rights reserved.
! 6: .\"
! 7: .\" Redistribution and use in source and binary forms, with or without
! 8: .\" modification, are permitted provided that the following conditions
! 9: .\" are met:
! 10: .\"
! 11: .\" 1. Redistributions of source code must retain the above copyright
! 12: .\" notice, this list of conditions and the following disclaimer.
! 13: .\"
! 14: .\" 2. Redistributions in binary form must reproduce the above copyright
! 15: .\" notice, this list of conditions and the following disclaimer in the
! 16: .\" documentation and/or other materials provided with the distribution.
! 17: .\"
! 18: .\" 3. The name of the author may not be used to endorse or promote products
! 19: .\" derived from this software without specific prior written permission
! 20: .\" from the author.
! 21: .\"
! 22: .\" 4. Products derived from this software may not be called "Sudo" nor
! 23: .\" may "Sudo" appear in their names without specific prior written
! 24: .\" permission from the author.
! 25: .\"
! 26: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
! 27: .\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
! 28: .\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
! 29: .\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
! 30: .\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
! 31: .\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
! 32: .\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
! 33: .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
! 34: .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
! 35: .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.9 millert 36: .\"
37: .\" Standard preamble:
38: .\" ======================================================================
39: .de Sh \" Subsection heading
1.1 millert 40: .br
41: .if t .Sp
42: .ne 5
43: .PP
44: \fB\\$1\fR
45: .PP
46: ..
1.9 millert 47: .de Sp \" Vertical space (when we can't use .PP)
1.1 millert 48: .if t .sp .5v
49: .if n .sp
50: ..
1.9 millert 51: .de Ip \" List item
1.1 millert 52: .br
53: .ie \\n(.$>=3 .ne \\$3
54: .el .ne 3
55: .IP "\\$1" \\$2
56: ..
1.9 millert 57: .de Vb \" Begin verbatim text
1.1 millert 58: .ft CW
59: .nf
60: .ne \\$1
61: ..
1.9 millert 62: .de Ve \" End verbatim text
1.1 millert 63: .ft R
64:
65: .fi
66: ..
1.9 millert 67: .\" Set up some character translations and predefined strings. \*(-- will
68: .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
69: .\" double quote, and \*(R" will give a right double quote. | will give a
70: .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used
71: .\" to do unbreakable dashes and therefore won't be available. \*(C` and
72: .\" \*(C' expand to `' in nroff, nothing in troff, for use with C<>
1.1 millert 73: .tr \(*W-|\(bv\*(Tr
1.9 millert 74: .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
1.1 millert 75: .ie n \{\
1.9 millert 76: . ds -- \(*W-
77: . ds PI pi
78: . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
79: . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
80: . ds L" ""
81: . ds R" ""
82: . ds C`
83: . ds C'
1.1 millert 84: 'br\}
85: .el\{\
1.9 millert 86: . ds -- \|\(em\|
87: . ds PI \(*p
88: . ds L" ``
89: . ds R" ''
1.1 millert 90: 'br\}
1.9 millert 91: .\"
92: .\" If the F register is turned on, we'll generate index entries on stderr
93: .\" for titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and
94: .\" index entries marked with X<> in POD. Of course, you'll have to process
95: .\" the output yourself in some meaningful fashion.
96: .if \nF \{\
97: . de IX
98: . tm Index:\\$1\t\\n%\t"\\$2"
1.1 millert 99: ..
1.9 millert 100: . nr % 0
101: . rr F
1.1 millert 102: .\}
1.9 millert 103: .\"
104: .\" For nroff, turn off justification. Always turn off hyphenation; it
105: .\" makes way too many mistakes in technical documents.
106: .hy 0
1.1 millert 107: .if n .na
1.9 millert 108: .\"
109: .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
110: .\" Fear. Run. Save yourself. No user-serviceable parts.
1.1 millert 111: .bd B 3
1.9 millert 112: . \" fudge factors for nroff and troff
1.1 millert 113: .if n \{\
1.9 millert 114: . ds #H 0
115: . ds #V .8m
116: . ds #F .3m
117: . ds #[ \f1
118: . ds #] \fP
1.1 millert 119: .\}
120: .if t \{\
1.9 millert 121: . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
122: . ds #V .6m
123: . ds #F 0
124: . ds #[ \&
125: . ds #] \&
1.1 millert 126: .\}
1.9 millert 127: . \" simple accents for nroff and troff
1.1 millert 128: .if n \{\
1.9 millert 129: . ds ' \&
130: . ds ` \&
131: . ds ^ \&
132: . ds , \&
133: . ds ~ ~
134: . ds /
1.1 millert 135: .\}
136: .if t \{\
1.9 millert 137: . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
138: . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
139: . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
140: . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
141: . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
142: . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
1.1 millert 143: .\}
1.9 millert 144: . \" troff and (daisy-wheel) nroff accents
1.1 millert 145: .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
146: .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
147: .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
148: .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
149: .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
150: .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
151: .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
152: .ds ae a\h'-(\w'a'u*4/10)'e
153: .ds Ae A\h'-(\w'A'u*4/10)'E
1.9 millert 154: . \" corrections for vroff
1.1 millert 155: .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
156: .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
1.9 millert 157: . \" for low resolution devices (crt and lpr)
1.1 millert 158: .if \n(.H>23 .if \n(.V>19 \
159: \{\
1.9 millert 160: . ds : e
161: . ds 8 ss
162: . ds o a
163: . ds d- d\h'-1'\(ga
164: . ds D- D\h'-1'\(hy
165: . ds th \o'bp'
166: . ds Th \o'LP'
167: . ds ae ae
168: . ds Ae AE
1.1 millert 169: .\}
170: .rm #[ #] #H #V #F C
1.9 millert 171: .\" ======================================================================
172: .\"
173: .IX Title "sudoers 5"
1.12 millert 174: .TH sudoers 5 "1.6.6" "April 25, 2002" "MAINTENANCE COMMANDS"
1.9 millert 175: .UC
1.1 millert 176: .SH "NAME"
177: sudoers \- list of which users may execute what
178: .SH "DESCRIPTION"
1.9 millert 179: .IX Header "DESCRIPTION"
1.7 pjanzen 180: The \fIsudoers\fR file is composed of two types of entries:
1.1 millert 181: aliases (basically variables) and user specifications
182: (which specify who may run what). The grammar of \fIsudoers\fR
1.9 millert 183: will be described below in Extended Backus-Naur Form (\s-1EBNF\s0).
184: Don't despair if you don't know what \s-1EBNF\s0 is; it is fairly
1.7 pjanzen 185: simple, and the definitions below are annotated.
1.1 millert 186: .Sh "Quick guide to \s-1EBNF\s0"
1.9 millert 187: .IX Subsection "Quick guide to EBNF"
188: \&\s-1EBNF\s0 is a concise and exact way of describing the grammar of a language.
1.7 pjanzen 189: Each \s-1EBNF\s0 definition is made up of \fIproduction rules\fR. E.g.,
1.1 millert 190: .PP
191: .Vb 1
192: \& symbol ::= definition | alternate1 | alternate2 ...
193: .Ve
194: Each \fIproduction rule\fR references others and thus makes up a
195: grammar for the language. \s-1EBNF\s0 also contains the following
196: operators, which many readers will recognize from regular
197: expressions. Do not, however, confuse them with \*(L"wildcard\*(R"
198: characters, which have different meanings.
1.9 millert 199: .Ip "\f(CW\*(C`?\*(C'\fR" 8
200: .IX Item "?"
1.1 millert 201: Means that the preceding symbol (or group of symbols) is optional.
202: That is, it may appear once or not at all.
1.9 millert 203: .Ip "\f(CW\*(C`*\*(C'\fR" 8
204: .IX Item "*"
1.1 millert 205: Means that the preceding symbol (or group of symbols) may appear
206: zero or more times.
1.9 millert 207: .Ip "\f(CW\*(C`+\*(C'\fR" 8
208: .IX Item "+"
1.1 millert 209: Means that the preceding symbol (or group of symbols) may appear
210: one or more times.
211: .PP
212: Parentheses may be used to group symbols together. For clarity,
213: we will use single quotes ('') to designate what is a verbatim character
214: string (as opposed to a symbol name).
215: .Sh "Aliases"
1.9 millert 216: .IX Subsection "Aliases"
217: There are four kinds of aliases: \f(CW\*(C`User_Alias\*(C'\fR, \f(CW\*(C`Runas_Alias\*(C'\fR,
218: \&\f(CW\*(C`Host_Alias\*(C'\fR and \f(CW\*(C`Cmnd_Alias\*(C'\fR.
1.1 millert 219: .PP
220: .Vb 4
1.9 millert 221: \& Alias ::= 'User_Alias' User_Alias (':' User_Alias)* |
222: \& 'Runas_Alias' Runas_Alias (':' Runas_Alias)* |
223: \& 'Host_Alias' Host_Alias (':' Host_Alias)* |
224: \& 'Cmnd_Alias' Cmnd_Alias (':' Cmnd_Alias)*
1.1 millert 225: .Ve
226: .Vb 1
227: \& User_Alias ::= NAME '=' User_List
228: .Ve
229: .Vb 1
1.9 millert 230: \& Runas_Alias ::= NAME '=' Runas_List
1.1 millert 231: .Ve
232: .Vb 1
233: \& Host_Alias ::= NAME '=' Host_List
234: .Ve
235: .Vb 1
236: \& Cmnd_Alias ::= NAME '=' Cmnd_List
237: .Ve
238: .Vb 1
239: \& NAME ::= [A-Z]([A-Z][0-9]_)*
240: .Ve
241: Each \fIalias\fR definition is of the form
242: .PP
243: .Vb 1
244: \& Alias_Type NAME = item1, item2, ...
245: .Ve
1.9 millert 246: 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,
247: or \f(CW\*(C`Cmnd_Alias\*(C'\fR. A \f(CW\*(C`NAME\*(C'\fR is a string of uppercase letters, numbers,
1.13 jmc 248: and underscore characters ('_'). A \f(CW\*(C`NAME\*(C'\fR \fBmust\fR start with an
1.7 pjanzen 249: uppercase letter. It is possible to put several alias definitions
1.8 jufi 250: of the same type on a single line, joined by a colon (':'). E.g.,
1.1 millert 251: .PP
252: .Vb 1
253: \& Alias_Type NAME = item1, item2, item3 : NAME = item4, item5
254: .Ve
255: The definitions of what constitutes a valid \fIalias\fR member follow.
256: .PP
257: .Vb 2
258: \& User_List ::= User |
259: \& User ',' User_List
260: .Ve
1.9 millert 261: .Vb 4
1.1 millert 262: \& User ::= '!'* username |
263: \& '!'* '%'group |
264: \& '!'* '+'netgroup |
265: \& '!'* User_Alias
266: .Ve
1.9 millert 267: A \f(CW\*(C`User_List\*(C'\fR is made up of one or more usernames, uids
268: (prefixed with '#'), System groups (prefixed with '%'),
269: netgroups (prefixed with '+') and other aliases. Each list
270: item may be prefixed with one or more '!' operators. An odd number
271: of '!' operators negate the value of the item; an even number
1.1 millert 272: just cancel each other out.
273: .PP
274: .Vb 2
275: \& Runas_List ::= Runas_User |
276: \& Runas_User ',' Runas_List
277: .Ve
278: .Vb 5
279: \& Runas_User ::= '!'* username |
280: \& '!'* '#'uid |
281: \& '!'* '%'group |
282: \& '!'* +netgroup |
283: \& '!'* Runas_Alias
284: .Ve
1.9 millert 285: A \f(CW\*(C`Runas_List\*(C'\fR is similar to a \f(CW\*(C`User_List\*(C'\fR except that it can
286: also contain uids (prefixed with '#') and instead of \f(CW\*(C`User_Alias\*(C'\fRes
287: it can contain \f(CW\*(C`Runas_Alias\*(C'\fRes.
1.1 millert 288: .PP
289: .Vb 2
290: \& Host_List ::= Host |
291: \& Host ',' Host_List
292: .Ve
293: .Vb 5
294: \& Host ::= '!'* hostname |
295: \& '!'* ip_addr |
296: \& '!'* network(/netmask)? |
297: \& '!'* '+'netgroup |
298: \& '!'* Host_Alias
299: .Ve
1.9 millert 300: A \f(CW\*(C`Host_List\*(C'\fR is made up of one or more hostnames, \s-1IP\s0 addresses,
301: network numbers, netgroups (prefixed with '+') and other aliases.
302: Again, the value of an item may be negated with the '!' operator.
1.1 millert 303: If you do not specify a netmask with a network number, the netmask
304: of the host's ethernet \fIinterface\fR\|(s) will be used when matching.
1.6 krw 305: The netmask may be specified either in dotted quad notation (e.g.
306: 255.255.255.0) or \s-1CIDR\s0 notation (number of bits, e.g. 24). A hostname
1.9 millert 307: may include shell-style wildcards (see `Wildcards' section below),
308: but unless the \f(CW\*(C`hostname\*(C'\fR command on your machine returns the fully
1.5 millert 309: qualified hostname, you'll need to use the \fIfqdn\fR option for wildcards
310: to be useful.
1.1 millert 311: .PP
312: .Vb 2
313: \& Cmnd_List ::= Cmnd |
314: \& Cmnd ',' Cmnd_List
315: .Ve
316: .Vb 3
317: \& commandname ::= filename |
318: \& filename args |
319: \& filename '""'
320: .Ve
321: .Vb 3
322: \& Cmnd ::= '!'* commandname |
323: \& '!'* directory |
324: \& '!'* Cmnd_Alias
325: .Ve
1.9 millert 326: A \f(CW\*(C`Cmnd_List\*(C'\fR is a list of one or more commandnames, directories, and other
1.5 millert 327: aliases. A commandname is a fully qualified filename which may include
1.9 millert 328: shell-style wildcards (see `Wildcards' section below). A simple
1.1 millert 329: filename allows the user to run the command with any arguments he/she
1.9 millert 330: wishes. However, you may also specify command line arguments (including
331: wildcards). Alternately, you can specify \f(CW\*(C`""\*(C'\fR to indicate that the command
1.1 millert 332: may only be run \fBwithout\fR command line arguments. A directory is a
1.9 millert 333: fully qualified pathname ending in a '/'. When you specify a directory
334: in a \f(CW\*(C`Cmnd_List\*(C'\fR, the user will be able to run any file within that directory
1.1 millert 335: (but not in any subdirectories therein).
336: .PP
1.9 millert 337: If a \f(CW\*(C`Cmnd\*(C'\fR has associated command line arguments, then the arguments
338: in the \f(CW\*(C`Cmnd\*(C'\fR must match exactly those given by the user on the command line
1.1 millert 339: (or match the wildcards if there are any). Note that the following
1.9 millert 340: characters must be escaped with a '\e' if they are used in command
341: arguments: ',', ':', '=', '\e'.
1.1 millert 342: .Sh "Defaults"
1.9 millert 343: .IX Subsection "Defaults"
1.1 millert 344: Certain configuration options may be changed from their default
1.9 millert 345: values at runtime via one or more \f(CW\*(C`Default_Entry\*(C'\fR lines. These
1.1 millert 346: may affect all users on any host, all users on a specific host,
347: or just a specific user. When multiple entries match, they are
348: applied in order. Where there are conflicting values, the last
349: value on a matching line takes effect.
350: .PP
351: .Vb 3
352: \& Default_Type ::= 'Defaults' ||
353: \& 'Defaults' ':' User ||
354: \& 'Defaults' '@' Host
355: .Ve
356: .Vb 1
357: \& Default_Entry ::= Default_Type Parameter_List
358: .Ve
1.9 millert 359: .Vb 4
1.1 millert 360: \& Parameter ::= Parameter '=' Value ||
1.9 millert 361: \& Parameter '+=' Value ||
362: \& Parameter '-=' Value ||
1.1 millert 363: \& '!'* Parameter ||
364: .Ve
1.9 millert 365: Parameters may be \fBflags\fR, \fBinteger\fR values, \fBstrings\fR, or \fBlists\fR.
366: Flags are implicitly boolean and can be turned off via the '!'
367: operator. Some integer, string and list parameters may also be
368: used in a boolean context to disable them. Values may be enclosed
369: in double quotes (\f(CW\*(C`"\*(C'\fR) when they contain multiple words. Special
370: characters may be escaped with a backslash (\f(CW\*(C`\e\*(C'\fR).
371: .PP
372: Lists have two additional assignment operators, \f(CW\*(C`+=\*(C'\fR and \f(CW\*(C`\-=\*(C'\fR.
373: These operators are used to add to and delete from a list respectively.
374: It is not an error to use the \f(CW\*(C`\-=\*(C'\fR operator to remove an element
375: that does not exist in a list.
376: .PP
377: Note that since the \fIsudoers\fR file is parsed in order the best place
378: to put the Defaults section is after the Host, User, and Cmnd aliases
379: but before the user specifications.
1.1 millert 380: .PP
1.9 millert 381: \&\fBFlags\fR:
1.1 millert 382: .Ip "long_otp_prompt" 12
1.9 millert 383: .IX Item "long_otp_prompt"
1.4 millert 384: When validating with a One Time Password scheme (\fBS/Key\fR or \fB\s-1OPIE\s0\fR),
385: a two-line prompt is used to make it easier to cut and paste the
386: challenge to a local window. It's not as pretty as the default but
1.9 millert 387: some people find it more convenient. This flag is \fIoff\fR
388: by default.
1.1 millert 389: .Ip "ignore_dot" 12
1.9 millert 390: .IX Item "ignore_dot"
391: If set, \fBsudo\fR will ignore '.' or '' (current dir) in the \f(CW\*(C`PATH\*(C'\fR
392: environment variable; the \f(CW\*(C`PATH\*(C'\fR itself is not modified. This
393: flag is \fIoff\fR by default.
1.1 millert 394: .Ip "mail_always" 12
1.9 millert 395: .IX Item "mail_always"
1.5 millert 396: Send mail to the \fImailto\fR user every time a users runs \fBsudo\fR.
1.9 millert 397: This flag is \fIoff\fR by default.
398: .Ip "mail_badpass" 12
399: .IX Item "mail_badpass"
400: Send mail to the \fImailto\fR user if the user running sudo does not
401: enter the correct password. This flag is \fIoff\fR by default.
1.1 millert 402: .Ip "mail_no_user" 12
1.9 millert 403: .IX Item "mail_no_user"
1.4 millert 404: If set, mail will be sent to the \fImailto\fR user if the invoking
1.9 millert 405: user is not in the \fIsudoers\fR file. This flag is \fIon\fR
406: by default.
1.1 millert 407: .Ip "mail_no_host" 12
1.9 millert 408: .IX Item "mail_no_host"
1.4 millert 409: If set, mail will be sent to the \fImailto\fR user if the invoking
410: user exists in the \fIsudoers\fR file, but is not allowed to run
1.9 millert 411: commands on the current host. This flag is \fIoff\fR by default.
1.1 millert 412: .Ip "mail_no_perms" 12
1.9 millert 413: .IX Item "mail_no_perms"
1.4 millert 414: If set, mail will be sent to the \fImailto\fR user if the invoking
1.13 jmc 415: user is allowed to use \fBsudo\fR but the command they are trying is not
1.9 millert 416: listed in their \fIsudoers\fR file entry. This flag is \fIoff\fR
417: by default.
1.1 millert 418: .Ip "tty_tickets" 12
1.9 millert 419: .IX Item "tty_tickets"
1.4 millert 420: If set, users must authenticate on a per-tty basis. Normally,
1.9 millert 421: \&\fBsudo\fR uses a directory in the ticket dir with the same name as
1.4 millert 422: the user running it. With this flag enabled, \fBsudo\fR will use a
423: file named for the tty the user is logged in on in that directory.
1.9 millert 424: This flag is \fIoff\fR by default.
1.1 millert 425: .Ip "lecture" 12
1.9 millert 426: .IX Item "lecture"
1.4 millert 427: If set, a user will receive a short lecture the first time he/she
1.9 millert 428: runs \fBsudo\fR. This flag is \fIon\fR by default.
1.1 millert 429: .Ip "authenticate" 12
1.9 millert 430: .IX Item "authenticate"
1.4 millert 431: If set, users must authenticate themselves via a password (or other
432: means of authentication) before they may run commands. This default
1.9 millert 433: may be overridden via the \f(CW\*(C`PASSWD\*(C'\fR and \f(CW\*(C`NOPASSWD\*(C'\fR tags.
434: This flag is \fIon\fR by default.
1.1 millert 435: .Ip "root_sudo" 12
1.9 millert 436: .IX Item "root_sudo"
1.5 millert 437: If set, root is allowed to run \fBsudo\fR too. Disabling this prevents users
438: from \*(L"chaining\*(R" \fBsudo\fR commands to get a root shell by doing something
1.9 millert 439: like \f(CW\*(C`"sudo sudo /bin/sh"\*(C'\fR.
440: This flag is \fIon\fR by default.
1.1 millert 441: .Ip "log_host" 12
1.9 millert 442: .IX Item "log_host"
1.4 millert 443: If set, the hostname will be logged in the (non-syslog) \fBsudo\fR log file.
1.9 millert 444: This flag is \fIoff\fR by default.
1.1 millert 445: .Ip "log_year" 12
1.9 millert 446: .IX Item "log_year"
1.4 millert 447: If set, the four-digit year will be logged in the (non-syslog) \fBsudo\fR log file.
1.9 millert 448: This flag is \fIoff\fR by default.
1.1 millert 449: .Ip "shell_noargs" 12
1.9 millert 450: .IX Item "shell_noargs"
1.4 millert 451: If set and \fBsudo\fR is invoked with no arguments it acts as if the
1.9 millert 452: \&\fB\-s\fR flag had been given. That is, it runs a shell as root (the
453: shell is determined by the \f(CW\*(C`SHELL\*(C'\fR environment variable if it is
1.4 millert 454: set, falling back on the shell listed in the invoking user's
1.9 millert 455: /etc/passwd entry if not). This flag is \fIoff\fR by default.
1.1 millert 456: .Ip "set_home" 12
1.9 millert 457: .IX Item "set_home"
458: If set and \fBsudo\fR is invoked with the \fB\-s\fR flag the \f(CW\*(C`HOME\*(C'\fR
1.4 millert 459: environment variable will be set to the home directory of the target
1.9 millert 460: user (which is root unless the \fB\-u\fR option is used). This effectively
461: makes the \fB\-s\fR flag imply \fB\-H\fR. This flag is \fIoff\fR by default.
462: .Ip "always_set_home" 12
463: .IX Item "always_set_home"
464: If set, \fBsudo\fR will set the \f(CW\*(C`HOME\*(C'\fR environment variable to the home
465: directory of the target user (which is root unless the \fB\-u\fR option is used).
466: This effectively means that the \fB\-H\fR flag is always implied.
467: This flag is \fIoff\fR by default.
1.1 millert 468: .Ip "path_info" 12
1.9 millert 469: .IX Item "path_info"
1.4 millert 470: Normally, \fBsudo\fR will tell the user when a command could not be
1.9 millert 471: found in their \f(CW\*(C`PATH\*(C'\fR environment variable. Some sites may wish
472: to disable this as it could be used to gather information on the
473: location of executables that the normal user does not have access
474: to. The disadvantage is that if the executable is simply not in
475: the user's \f(CW\*(C`PATH\*(C'\fR, \fBsudo\fR will tell the user that they are not
476: allowed to run it, which can be confusing. This flag is \fIoff\fR by
477: default.
478: .Ip "preserve_groups" 12
479: .IX Item "preserve_groups"
480: By default \fBsudo\fR will initialize the group vector to the list of
481: groups the target user is in. When \fIpreserve_groups\fR is set, the
482: user's existing group vector is left unaltered. The real and
483: effective group IDs, however, are still set to match the target
484: user. This flag is \fIoff\fR by default.
1.1 millert 485: .Ip "fqdn" 12
1.9 millert 486: .IX Item "fqdn"
1.4 millert 487: Set this flag if you want to put fully qualified hostnames in the
1.13 jmc 488: \&\fIsudoers\fR file. I.e., instead of myhost you would use myhost.mydomain.edu.
1.4 millert 489: You may still use the short form if you wish (and even mix the two).
1.5 millert 490: Beware that turning on \fIfqdn\fR requires \fBsudo\fR to make \s-1DNS\s0 lookups
1.4 millert 491: which may make \fBsudo\fR unusable if \s-1DNS\s0 stops working (for example
492: if the machine is not plugged into the network). Also note that
493: you must use the host's official name as \s-1DNS\s0 knows it. That is,
1.9 millert 494: you may not use a host alias (\f(CW\*(C`CNAME\*(C'\fR entry) due to performance
1.4 millert 495: issues and the fact that there is no way to get all aliases from
1.9 millert 496: \&\s-1DNS\s0. If your machine's hostname (as returned by the \f(CW\*(C`hostname\*(C'\fR
1.4 millert 497: command) is already fully qualified you shouldn't need to set
1.9 millert 498: \&\fIfqdn\fR. This flag is \fIoff\fR by default.
1.1 millert 499: .Ip "insults" 12
1.9 millert 500: .IX Item "insults"
1.5 millert 501: If set, \fBsudo\fR will insult users when they enter an incorrect
1.9 millert 502: password. This flag is \fIon\fR by default.
1.1 millert 503: .Ip "requiretty" 12
1.9 millert 504: .IX Item "requiretty"
1.5 millert 505: If set, \fBsudo\fR will only run when the user is logged in to a real
1.9 millert 506: tty. This will disallow things like \f(CW\*(C`"rsh somehost sudo ls"\*(C'\fR since
507: \&\fIrsh\fR\|(1) does not allocate a tty. Because it is not possible to turn
1.13 jmc 508: off echo when there is no tty present, some sites may wish to set
1.4 millert 509: this flag to prevent a user from entering a visible password. This
1.9 millert 510: flag is \fIoff\fR by default.
1.5 millert 511: .Ip "env_editor" 12
1.9 millert 512: .IX Item "env_editor"
513: If set, \fBvisudo\fR will use the value of the \s-1EDITOR\s0 or \s-1VISUAL\s0
514: environment variables before falling back on the default editor list.
515: Note that this may create a security hole as it allows the user to
516: run any arbitrary command as root without logging. A safer alternative
517: is to place a colon-separated list of editors in the \f(CW\*(C`editor\*(C'\fR
518: variable. \fBvisudo\fR will then only use the \s-1EDITOR\s0 or \s-1VISUAL\s0 if
519: they match a value specified in \f(CW\*(C`editor\*(C'\fR. This flag is \f(CW\*(C`on\*(C'\fR by
520: default.
1.5 millert 521: .Ip "rootpw" 12
1.9 millert 522: .IX Item "rootpw"
1.5 millert 523: If set, \fBsudo\fR will prompt for the root password instead of the password
1.9 millert 524: of the invoking user. This flag is \fIoff\fR by default.
1.5 millert 525: .Ip "runaspw" 12
1.9 millert 526: .IX Item "runaspw"
1.5 millert 527: If set, \fBsudo\fR will prompt for the password of the user defined by the
1.9 millert 528: \&\fIrunas_default\fR option (defaults to \f(CW\*(C`root\*(C'\fR) instead of the password
529: of the invoking user. This flag is \fIoff\fR by default.
1.5 millert 530: .Ip "targetpw" 12
1.9 millert 531: .IX Item "targetpw"
1.5 millert 532: If set, \fBsudo\fR will prompt for the password of the user specified by
1.9 millert 533: the \fB\-u\fR flag (defaults to \f(CW\*(C`root\*(C'\fR) instead of the password of the
534: invoking user. This flag is \fIoff\fR by default.
1.5 millert 535: .Ip "set_logname" 12
1.9 millert 536: .IX Item "set_logname"
537: Normally, \fBsudo\fR will set the \f(CW\*(C`LOGNAME\*(C'\fR and \f(CW\*(C`USER\*(C'\fR environment variables
538: to the name of the target user (usually root unless the \fB\-u\fR flag is given).
1.5 millert 539: However, since some programs (including the \s-1RCS\s0 revision control system)
1.9 millert 540: use \f(CW\*(C`LOGNAME\*(C'\fR to determine the real identity of the user, it may be desirable
1.5 millert 541: to change this behavior. This can be done by negating the set_logname option.
1.9 millert 542: .Ip "stay_setuid" 12
543: .IX Item "stay_setuid"
544: Normally, when \fBsudo\fR executes a command the real and effective
545: UIDs are set to the target user (root by default). This option
546: changes that behavior such that the real \s-1UID\s0 is left as the invoking
547: user's \s-1UID\s0. In other words, this makes \fBsudo\fR act as a setuid
548: wrapper. This can be useful on systems that disable some potentially
1.10 millert 549: dangerous functionality when a program is run setuid. Note, however,
550: that this means that sudo will run with the real uid of the invoking
551: user which may allow that user to kill \fBsudo\fR before it can log a
552: failure, depending on how your \s-1OS\s0 defines the interaction between
553: signals and setuid processes.
1.9 millert 554: .Ip "env_reset" 12
555: .IX Item "env_reset"
556: If set, \fBsudo\fR will reset the environment to only contain the
557: following variables: \f(CW\*(C`HOME\*(C'\fR, \f(CW\*(C`LOGNAME\*(C'\fR, \f(CW\*(C`PATH\*(C'\fR, \f(CW\*(C`SHELL\*(C'\fR, \f(CW\*(C`TERM\*(C'\fR,
558: and \f(CW\*(C`USER\*(C'\fR (in addition to the \f(CW\*(C`SUDO_*\*(C'\fR variables).
559: Of these, only \f(CW\*(C`TERM\*(C'\fR is copied unaltered from the old environment.
560: The other variables are set to default values (possibly modified
561: by the value of the \fIset_logname\fR option). If \fBsudo\fR was compiled
562: with the \f(CW\*(C`SECURE_PATH\*(C'\fR option, its value will be used for the \f(CW\*(C`PATH\*(C'\fR
563: environment variable.
564: Other variables may be preserved with the \fIenv_keep\fR option.
565: .Ip "use_loginclass" 12
566: .IX Item "use_loginclass"
567: If set, \fBsudo\fR will apply the defaults specified for the target user's
568: login class if one exists. Only available if \fBsudo\fR is configured with
569: the \-\-with-logincap option. This flag is \fIoff\fR by default.
1.1 millert 570: .PP
1.9 millert 571: \&\fBIntegers\fR:
1.1 millert 572: .Ip "passwd_tries" 12
1.9 millert 573: .IX Item "passwd_tries"
1.4 millert 574: The number of tries a user gets to enter his/her password before
1.9 millert 575: \&\fBsudo\fR logs the failure and exits. The default is \f(CW\*(C`3\*(C'\fR.
1.1 millert 576: .PP
1.9 millert 577: \&\fBIntegers that can be used in a boolean context\fR:
1.1 millert 578: .Ip "loglinelen" 12
1.9 millert 579: .IX Item "loglinelen"
1.4 millert 580: Number of characters per line for the file log. This value is used
581: to decide when to wrap lines for nicer log files. This has no
582: effect on the syslog log file, only the file log. The default is
1.9 millert 583: \&\f(CW\*(C`80\*(C'\fR (use 0 or negate the option to disable word wrap).
1.1 millert 584: .Ip "timestamp_timeout" 12
1.9 millert 585: .IX Item "timestamp_timeout"
586: Number of minutes that can elapse before \fBsudo\fR will ask for a
587: passwd again. The default is \f(CW\*(C`5\*(C'\fR. Set this to \f(CW\*(C`0\*(C'\fR to always
588: prompt for a password.
589: If set to a value less than \f(CW\*(C`0\*(C'\fR the user's timestamp will never
590: expire. This can be used to allow users to create or delete their
591: own timestamps via \f(CW\*(C`sudo \-v\*(C'\fR and \f(CW\*(C`sudo \-k\*(C'\fR respectively.
1.1 millert 592: .Ip "passwd_timeout" 12
1.9 millert 593: .IX Item "passwd_timeout"
1.5 millert 594: Number of minutes before the \fBsudo\fR password prompt times out.
1.9 millert 595: The default is \f(CW\*(C`5\*(C'\fR, set this to \f(CW\*(C`0\*(C'\fR for no password timeout.
1.1 millert 596: .Ip "umask" 12
1.9 millert 597: .IX Item "umask"
598: Umask to use when running the command. Negate this option or set
599: it to 0777 to preserve the user's umask. The default is \f(CW\*(C`0022\*(C'\fR.
1.1 millert 600: .PP
1.9 millert 601: \&\fBStrings\fR:
1.1 millert 602: .Ip "mailsub" 12
1.9 millert 603: .IX Item "mailsub"
604: Subject of the mail sent to the \fImailto\fR user. The escape \f(CW\*(C`%h\*(C'\fR
1.4 millert 605: will expand to the hostname of the machine.
1.9 millert 606: Default is \f(CW\*(C`*** SECURITY information for %h ***\*(C'\fR.
1.1 millert 607: .Ip "badpass_message" 12
1.9 millert 608: .IX Item "badpass_message"
1.4 millert 609: Message that is displayed if a user enters an incorrect password.
1.9 millert 610: The default is \f(CW\*(C`Sorry, try again.\*(C'\fR unless insults are enabled.
1.1 millert 611: .Ip "timestampdir" 12
1.9 millert 612: .IX Item "timestampdir"
1.4 millert 613: The directory in which \fBsudo\fR stores its timestamp files.
1.9 millert 614: The default is \fI/var/run/sudo\fR.
1.1 millert 615: .Ip "passprompt" 12
1.9 millert 616: .IX Item "passprompt"
1.4 millert 617: The default prompt to use when asking for a password; can be overridden
1.9 millert 618: via the \fB\-p\fR option or the \f(CW\*(C`SUDO_PROMPT\*(C'\fR environment variable. Supports
1.4 millert 619: two escapes: \*(L"%u\*(R" expands to the user's login name and \*(L"%h\*(R" expands
1.9 millert 620: to the local hostname. The default value is \f(CW\*(C`Password:\*(C'\fR.
1.1 millert 621: .Ip "runas_default" 12
1.9 millert 622: .IX Item "runas_default"
623: The default user to run commands as if the \fB\-u\fR flag is not specified
624: on the command line. This defaults to \f(CW\*(C`root\*(C'\fR.
1.1 millert 625: .Ip "syslog_goodpri" 12
1.9 millert 626: .IX Item "syslog_goodpri"
1.4 millert 627: Syslog priority to use when user authenticates successfully.
1.9 millert 628: Defaults to \f(CW\*(C`notice\*(C'\fR.
1.1 millert 629: .Ip "syslog_badpri" 12
1.9 millert 630: .IX Item "syslog_badpri"
1.4 millert 631: Syslog priority to use when user authenticates unsuccessfully.
1.9 millert 632: Defaults to \f(CW\*(C`alert\*(C'\fR.
1.5 millert 633: .Ip "editor" 12
1.9 millert 634: .IX Item "editor"
635: A colon (':') separated list of editors allowed to be used with
636: \&\fBvisudo\fR. \fBvisudo\fR will choose the editor that matches the user's
637: \&\s-1USER\s0 environment variable if possible, or the first editor in the
638: list that exists and is executable. The default is the path to vi
639: on your system.
1.1 millert 640: .PP
1.9 millert 641: \&\fBStrings that can be used in a boolean context\fR:
1.5 millert 642: .Ip "logfile" 12
1.9 millert 643: .IX Item "logfile"
1.5 millert 644: Path to the \fBsudo\fR log file (not the syslog log file). Setting a path
1.7 pjanzen 645: turns on logging to a file; negating this option turns it off.
1.1 millert 646: .Ip "syslog" 12
1.9 millert 647: .IX Item "syslog"
1.4 millert 648: Syslog facility if syslog is being used for logging (negate to
1.9 millert 649: disable syslog logging). Defaults to \f(CW\*(C`authpriv\*(C'\fR.
1.1 millert 650: .Ip "mailerpath" 12
1.9 millert 651: .IX Item "mailerpath"
1.4 millert 652: Path to mail program used to send warning mail.
653: Defaults to the path to sendmail found at configure time.
1.1 millert 654: .Ip "mailerflags" 12
1.9 millert 655: .IX Item "mailerflags"
656: Flags to use when invoking mailer. Defaults to \fB\-t\fR.
1.1 millert 657: .Ip "mailto" 12
1.9 millert 658: .IX Item "mailto"
659: Address to send warning and error mail to. The address should
660: be enclosed in double quotes (\f(CW\*(C`"\*(C'\fR) to protect against sudo
661: interpreting the \f(CW\*(C`@\*(C'\fR sign. Defaults to \f(CW\*(C`root\*(C'\fR.
1.1 millert 662: .Ip "exempt_group" 12
1.9 millert 663: .IX Item "exempt_group"
1.4 millert 664: Users in this group are exempt from password and \s-1PATH\s0 requirements.
665: This is not set by default.
1.3 millert 666: .Ip "verifypw" 12
1.9 millert 667: .IX Item "verifypw"
668: This option controls when a password will be required when a user runs
669: \&\fBsudo\fR with the \fB\-v\fR flag. It has the following possible values:
670: .RS 12
671: .Ip "all" 8
672: .IX Item "all"
673: All the user's \fIsudoers\fR entries for the current host must have
674: the \f(CW\*(C`NOPASSWD\*(C'\fR flag set to avoid entering a password.
675: .Ip "any" 8
676: .IX Item "any"
677: At least one of the user's \fIsudoers\fR entries for the current host
678: must have the \f(CW\*(C`NOPASSWD\*(C'\fR flag set to avoid entering a password.
679: .Ip "never" 8
680: .IX Item "never"
681: The user need never enter a password to use the \fB\-v\fR flag.
682: .Ip "always" 8
683: .IX Item "always"
684: The user must always enter a password to use the \fB\-v\fR flag.
685: .RE
686: .RS 12
1.3 millert 687: .Sp
1.9 millert 688: The default value is `all'.
689: .RE
1.3 millert 690: .Ip "listpw" 12
1.9 millert 691: .IX Item "listpw"
1.3 millert 692: This option controls when a password will be required when a
1.13 jmc 693: user runs \fBsudo\fR with the \fB\-l\fR flag. It has the
694: following possible values:
1.9 millert 695: .RS 12
696: .Ip "all" 8
697: .IX Item "all"
698: All the user's \fIsudoers\fR entries for the current host must have
699: the \f(CW\*(C`NOPASSWD\*(C'\fR flag set to avoid entering a password.
700: .Ip "any" 8
701: .IX Item "any"
702: At least one of the user's \fIsudoers\fR entries for the current host
703: must have the \f(CW\*(C`NOPASSWD\*(C'\fR flag set to avoid entering a password.
704: .Ip "never" 8
705: .IX Item "never"
706: The user need never enter a password to use the \fB\-l\fR flag.
707: .Ip "always" 8
708: .IX Item "always"
709: The user must always enter a password to use the \fB\-l\fR flag.
710: .RE
711: .RS 12
1.3 millert 712: .Sp
1.9 millert 713: The default value is `any'.
714: .RE
715: .PP
716: \&\fBLists that can be used in a boolean context\fR:
717: .Ip "env_check" 12
718: .IX Item "env_check"
719: Environment variables to be removed from the user's environment if
720: the variable's value contains \f(CW\*(C`%\*(C'\fR or \f(CW\*(C`/\*(C'\fR characters. This can
1.13 jmc 721: be used to guard against printf-style format vulnerabilities in
1.9 millert 722: poorly-written programs. The argument may be a double-quoted,
723: space-separated list or a single value without double-quotes. The
724: list can be replaced, added to, deleted from, or disabled by using
725: the \f(CW\*(C`=\*(C'\fR, \f(CW\*(C`+=\*(C'\fR, \f(CW\*(C`\-=\*(C'\fR, and \f(CW\*(C`!\*(C'\fR operators respectively. The default
1.13 jmc 726: list of environment variables to check is printed when \fBsudo\fR is
1.9 millert 727: run by root with the \fI\-V\fR option.
728: .Ip "env_delete" 12
729: .IX Item "env_delete"
730: Environment variables to be removed from the user's environment.
731: The argument may be a double-quoted, space-separated list or a
732: single value without double-quotes. The list can be replaced, added
733: to, deleted from, or disabled by using the \f(CW\*(C`=\*(C'\fR, \f(CW\*(C`+=\*(C'\fR, \f(CW\*(C`\-=\*(C'\fR, and
734: \&\f(CW\*(C`!\*(C'\fR operators respectively. The default list of environment
1.13 jmc 735: variables to remove is printed when \fBsudo\fR is run by root with the
1.9 millert 736: \&\fI\-V\fR option.
737: .Ip "env_keep" 12
738: .IX Item "env_keep"
739: Environment variables to be preserved in the user's environment
740: when the \fIenv_reset\fR option is in effect. This allows fine-grained
741: control over the environment \fBsudo\fR\-spawned processes will receive.
742: The argument may be a double-quoted, space-separated list or a
743: single value without double-quotes. The list can be replaced, added
744: to, deleted from, or disabled by using the \f(CW\*(C`=\*(C'\fR, \f(CW\*(C`+=\*(C'\fR, \f(CW\*(C`\-=\*(C'\fR, and
745: \&\f(CW\*(C`!\*(C'\fR operators respectively. This list has no default members.
1.1 millert 746: .PP
1.5 millert 747: When logging via \fIsyslog\fR\|(3), \fBsudo\fR accepts the following values for the syslog
1.1 millert 748: facility (the value of the \fBsyslog\fR Parameter): \fBauthpriv\fR (if your \s-1OS\s0
749: supports it), \fBauth\fR, \fBdaemon\fR, \fBuser\fR, \fBlocal0\fR, \fBlocal1\fR, \fBlocal2\fR,
1.9 millert 750: \&\fBlocal3\fR, \fBlocal4\fR, \fBlocal5\fR, \fBlocal6\fR, and \fBlocal7\fR. The following
1.1 millert 751: syslog priorities are supported: \fBalert\fR, \fBcrit\fR, \fBdebug\fR, \fBemerg\fR,
1.9 millert 752: \&\fBerr\fR, \fBinfo\fR, \fBnotice\fR, and \fBwarning\fR.
1.1 millert 753: .Sh "User Specification"
1.9 millert 754: .IX Subsection "User Specification"
1.3 millert 755: .Vb 2
1.9 millert 756: \& User_Spec ::= User_list Host_List '=' Cmnd_Spec_List \e
1.3 millert 757: \& (':' User_Spec)*
1.1 millert 758: .Ve
759: .Vb 2
760: \& Cmnd_Spec_List ::= Cmnd_Spec |
761: \& Cmnd_Spec ',' Cmnd_Spec_List
762: .Ve
763: .Vb 1
1.3 millert 764: \& Cmnd_Spec ::= Runas_Spec? ('NOPASSWD:' | 'PASSWD:')? Cmnd
765: .Ve
766: .Vb 1
767: \& Runas_Spec ::= '(' Runas_List ')'
1.1 millert 768: .Ve
769: A \fBuser specification\fR determines which commands a user may run
770: (and as what user) on specified hosts. By default, commands are
1.7 pjanzen 771: run as \fBroot\fR, but this can be changed on a per-command basis.
1.1 millert 772: .PP
773: Let's break that down into its constituent parts:
774: .Sh "Runas_Spec"
1.9 millert 775: .IX Subsection "Runas_Spec"
776: A \f(CW\*(C`Runas_Spec\*(C'\fR is simply a \f(CW\*(C`Runas_List\*(C'\fR (as defined above)
1.1 millert 777: enclosed in a set of parentheses. If you do not specify a
1.9 millert 778: \&\f(CW\*(C`Runas_Spec\*(C'\fR in the user specification, a default \f(CW\*(C`Runas_Spec\*(C'\fR
779: of \fBroot\fR will be used. A \f(CW\*(C`Runas_Spec\*(C'\fR sets the default for
1.1 millert 780: commands that follow it. What this means is that for the entry:
781: .PP
782: .Vb 1
1.13 jmc 783: \& dgb boulder = (operator) /bin/ls, /bin/kill, /usr/bin/lprm
1.1 millert 784: .Ve
785: The user \fBdgb\fR may run \fI/bin/ls\fR, \fI/bin/kill\fR, and
1.9 millert 786: \&\fI/usr/bin/lprm\fR \*(-- but only as \fBoperator\fR. E.g.,
1.1 millert 787: .PP
788: .Vb 1
789: \& sudo -u operator /bin/ls.
790: .Ve
1.9 millert 791: It is also possible to override a \f(CW\*(C`Runas_Spec\*(C'\fR later on in an
1.1 millert 792: entry. If we modify the entry like so:
793: .PP
794: .Vb 1
795: \& dgb boulder = (operator) /bin/ls, (root) /bin/kill, /usr/bin/lprm
796: .Ve
797: Then user \fBdgb\fR is now allowed to run \fI/bin/ls\fR as \fBoperator\fR,
798: but \fI/bin/kill\fR and \fI/usr/bin/lprm\fR as \fBroot\fR.
799: .Sh "\s-1NOPASSWD\s0 and \s-1PASSWD\s0"
1.9 millert 800: .IX Subsection "NOPASSWD and PASSWD"
1.1 millert 801: By default, \fBsudo\fR requires that a user authenticate him or herself
802: before running a command. This behavior can be modified via the
1.9 millert 803: \&\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
804: a default for the commands that follow it in the \f(CW\*(C`Cmnd_Spec_List\*(C'\fR.
805: Conversely, the \f(CW\*(C`PASSWD\*(C'\fR tag can be used to reverse things.
1.1 millert 806: For example:
807: .PP
808: .Vb 1
809: \& ray rushmore = NOPASSWD: /bin/kill, /bin/ls, /usr/bin/lprm
810: .Ve
811: would allow the user \fBray\fR to run \fI/bin/kill\fR, \fI/bin/ls\fR, and
1.9 millert 812: \&\fI/usr/bin/lprm\fR as root on the machine rushmore as \fBroot\fR without
1.1 millert 813: authenticating himself. If we only want \fBray\fR to be able to
814: run \fI/bin/kill\fR without a password the entry would be:
815: .PP
816: .Vb 1
817: \& ray rushmore = NOPASSWD: /bin/kill, PASSWD: /bin/ls, /usr/bin/lprm
818: .Ve
1.9 millert 819: Note, however, that the \f(CW\*(C`PASSWD\*(C'\fR tag has no effect on users who are
1.3 millert 820: in the group specified by the exempt_group option.
821: .PP
1.9 millert 822: By default, if the \f(CW\*(C`NOPASSWD\*(C'\fR tag is applied to any of the entries
1.3 millert 823: for a user on the current host, he or she will be able to run
1.9 millert 824: \&\f(CW\*(C`sudo \-l\*(C'\fR without a password. Additionally, a user may only run
825: \&\f(CW\*(C`sudo \-v\*(C'\fR without a password if the \f(CW\*(C`NOPASSWD\*(C'\fR tag is present
1.3 millert 826: for all a user's entries that pertain to the current host.
827: This behavior may be overridden via the verifypw and listpw options.
1.1 millert 828: .Sh "Wildcards (aka meta characters):"
1.9 millert 829: .IX Subsection "Wildcards (aka meta characters):"
830: \&\fBsudo\fR allows shell-style \fIwildcards\fR to be used in pathnames
1.1 millert 831: as well as command line arguments in the \fIsudoers\fR file. Wildcard
1.9 millert 832: matching is done via the \fB\s-1POSIX\s0\fR \f(CW\*(C`fnmatch(3)\*(C'\fR routine. Note that
1.1 millert 833: these are \fInot\fR regular expressions.
1.9 millert 834: .Ip "\f(CW\*(C`*\*(C'\fR" 8
835: .IX Item "*"
1.1 millert 836: Matches any set of zero or more characters.
1.9 millert 837: .Ip "\f(CW\*(C`?\*(C'\fR" 8
838: .IX Item "?"
1.1 millert 839: Matches any single character.
1.9 millert 840: .Ip "\f(CW\*(C`[...]\*(C'\fR" 8
841: .IX Item "[...]"
1.1 millert 842: Matches any character in the specified range.
1.9 millert 843: .Ip "\f(CW\*(C`[!...]\*(C'\fR" 8
844: .IX Item "[!...]"
1.1 millert 845: Matches any character \fBnot\fR in the specified range.
1.9 millert 846: .Ip "\f(CW\*(C`\ex\*(C'\fR" 8
847: .IX Item "x"
1.1 millert 848: For any character \*(L"x\*(R", evaluates to \*(L"x\*(R". This is used to
849: escape special characters such as: \*(L"*\*(R", \*(L"?\*(R", \*(L"[\*(R", and \*(L"}\*(R".
850: .PP
851: Note that a forward slash ('/') will \fBnot\fR be matched by
852: wildcards used in the pathname. When matching the command
1.13 jmc 853: line arguments, however, a slash \fBdoes\fR get matched by
1.1 millert 854: wildcards. This is to make a path like:
855: .PP
856: .Vb 1
857: \& /usr/bin/*
858: .Ve
1.9 millert 859: match \f(CW\*(C`/usr/bin/who\*(C'\fR but not \f(CW\*(C`/usr/bin/X11/xterm\*(C'\fR.
1.1 millert 860: .Sh "Exceptions to wildcard rules:"
1.9 millert 861: .IX Subsection "Exceptions to wildcard rules:"
1.1 millert 862: The following exceptions apply to the above rules:
1.13 jmc 863: .if n .Ip "\f(CW""""\fR" 8
1.9 millert 864: .el .Ip "\f(CW``''\fR" 8
865: .IX Item """""
866: If the empty string \f(CW\*(C`""\*(C'\fR is the only command line argument in the
867: \&\fIsudoers\fR entry it means that command is not allowed to be run
1.1 millert 868: with \fBany\fR arguments.
869: .Sh "Other special characters and reserved words:"
1.9 millert 870: .IX Subsection "Other special characters and reserved words:"
1.1 millert 871: The pound sign ('#') is used to indicate a comment (unless it
872: occurs in the context of a user name and is followed by one or
873: more digits, in which case it is treated as a uid). Both the
874: comment character and any text after it, up to the end of the line,
875: are ignored.
876: .PP
1.2 aaron 877: The reserved word \fB\s-1ALL\s0\fR is a built in \fIalias\fR that always causes
1.1 millert 878: a match to succeed. It can be used wherever one might otherwise
1.9 millert 879: 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.
1.1 millert 880: You should not try to define your own \fIalias\fR called \fB\s-1ALL\s0\fR as the
881: built in alias will be used in preference to your own. Please note
882: that using \fB\s-1ALL\s0\fR can be dangerous since in a command context, it
883: allows the user to run \fBany\fR command on the system.
884: .PP
1.9 millert 885: An exclamation point ('!') can be used as a logical \fInot\fR operator
886: both in an \fIalias\fR and in front of a \f(CW\*(C`Cmnd\*(C'\fR. This allows one to
887: exclude certain values. Note, however, that using a \f(CW\*(C`!\*(C'\fR in
888: conjunction with the built in \f(CW\*(C`ALL\*(C'\fR alias to allow a user to
1.1 millert 889: run \*(L"all but a few\*(R" commands rarely works as intended (see \s-1SECURITY\s0
1.9 millert 890: \&\s-1NOTES\s0 below).
1.1 millert 891: .PP
1.9 millert 892: Long lines can be continued with a backslash ('\e') as the last
1.1 millert 893: character on the line.
894: .PP
1.7 pjanzen 895: Whitespace between elements in a list as well as special syntactic
1.9 millert 896: characters in a \fIUser Specification\fR ('=', ':', '(', ')') is optional.
1.1 millert 897: .PP
1.9 millert 898: The following characters must be escaped with a backslash ('\e') when
1.6 krw 899: used as part of a word (e.g. a username or hostname):
1.9 millert 900: \&'@', '!', '=', ':', ',', '(', ')', '\e'.
1.1 millert 901: .SH "EXAMPLES"
1.9 millert 902: .IX Header "EXAMPLES"
1.1 millert 903: Below are example \fIsudoers\fR entries. Admittedly, some of
904: these are a bit contrived. First, we define our \fIaliases\fR:
905: .PP
906: .Vb 4
907: \& # User alias specification
908: \& User_Alias FULLTIMERS = millert, mikef, dowdy
909: \& User_Alias PARTTIMERS = bostley, jwfox, crawl
910: \& User_Alias WEBMASTERS = will, wendy, wim
911: .Ve
912: .Vb 3
913: \& # Runas alias specification
914: \& Runas_Alias OP = root, operator
915: \& Runas_Alias DB = oracle, sybase
916: .Ve
917: .Vb 9
918: \& # Host alias specification
919: \& Host_Alias SPARC = bigtime, eclipse, moet, anchor :\e
920: \& SGI = grolsch, dandelion, black :\e
921: \& ALPHA = widget, thalamus, foobar :\e
922: \& HPPA = boa, nag, python
923: \& Host_Alias CUNETS = 128.138.0.0/255.255.0.0
924: \& Host_Alias CSNETS = 128.138.243.0, 128.138.204.0/24, 128.138.242.0
925: \& Host_Alias SERVERS = master, mail, www, ns
926: \& Host_Alias CDROM = orion, perseus, hercules
927: .Ve
928: .Vb 12
929: \& # Cmnd alias specification
930: \& Cmnd_Alias DUMPS = /usr/bin/mt, /usr/sbin/dump, /usr/sbin/rdump,\e
931: \& /usr/sbin/restore, /usr/sbin/rrestore
932: \& Cmnd_Alias KILL = /usr/bin/kill
933: \& Cmnd_Alias PRINTING = /usr/sbin/lpc, /usr/bin/lprm
934: \& Cmnd_Alias SHUTDOWN = /usr/sbin/shutdown
935: \& Cmnd_Alias HALT = /usr/sbin/halt, /usr/sbin/fasthalt
936: \& Cmnd_Alias REBOOT = /usr/sbin/reboot, /usr/sbin/fastboot
937: \& Cmnd_Alias SHELLS = /usr/bin/sh, /usr/bin/csh, /usr/bin/ksh, \e
938: \& /usr/local/bin/tcsh, /usr/bin/rsh, \e
939: \& /usr/local/bin/zsh
940: \& Cmnd_Alias SU = /usr/bin/su
941: .Ve
942: Here we override some of the compiled in default values. We want
1.9 millert 943: \&\fBsudo\fR to log via \fIsyslog\fR\|(3) using the \fIauth\fR facility in all cases.
1.1 millert 944: We don't want to subject the full time staff to the \fBsudo\fR lecture,
945: and user \fBmillert\fR need not give a password. In addition, on the
1.9 millert 946: machines in the \fI\s-1SERVERS\s0\fR \f(CW\*(C`Host_Alias\*(C'\fR, we keep an additional
1.1 millert 947: local log file and make sure we log the year in each log line since
948: the log entries will be kept around for several years.
949: .PP
950: .Vb 5
1.9 millert 951: \& # Override built in defaults
1.1 millert 952: \& Defaults syslog=auth
953: \& Defaults:FULLTIMERS !lecture
954: \& Defaults:millert !authenticate
955: \& Defaults@SERVERS log_year, logfile=/var/log/sudo.log
956: .Ve
957: The \fIUser specification\fR is the part that actually determines who may
958: run what.
959: .PP
960: .Vb 2
961: \& root ALL = (ALL) ALL
962: \& %wheel ALL = (ALL) ALL
963: .Ve
964: We let \fBroot\fR and any user in group \fBwheel\fR run any command on any
965: host as any user.
966: .PP
967: .Vb 1
968: \& FULLTIMERS ALL = NOPASSWD: ALL
969: .Ve
970: Full time sysadmins (\fBmillert\fR, \fBmikef\fR, and \fBdowdy\fR) may run any
971: command on any host without authenticating themselves.
972: .PP
973: .Vb 1
974: \& PARTTIMERS ALL = ALL
975: .Ve
976: Part time sysadmins (\fBbostley\fR, \fBjwfox\fR, and \fBcrawl\fR) may run any
977: command on any host but they must authenticate themselves first
1.9 millert 978: (since the entry lacks the \f(CW\*(C`NOPASSWD\*(C'\fR tag).
1.1 millert 979: .PP
980: .Vb 1
981: \& jack CSNETS = ALL
982: .Ve
1.9 millert 983: The user \fBjack\fR may run any command on the machines in the \fI\s-1CSNETS\s0\fR alias
984: (the networks \f(CW\*(C`128.138.243.0\*(C'\fR, \f(CW\*(C`128.138.204.0\*(C'\fR, and \f(CW\*(C`128.138.242.0\*(C'\fR).
985: Of those networks, only \f(CW\*(C`128.138.204.0\*(C'\fR has an explicit netmask (in
986: \&\s-1CIDR\s0 notation) indicating it is a class C network. For the other
987: networks in \fI\s-1CSNETS\s0\fR, the local machine's netmask will be used
1.1 millert 988: during matching.
989: .PP
990: .Vb 1
991: \& lisa CUNETS = ALL
992: .Ve
1.9 millert 993: The user \fBlisa\fR may run any command on any host in the \fI\s-1CUNETS\s0\fR alias
994: (the class B network \f(CW\*(C`128.138.0.0\*(C'\fR).
1.1 millert 995: .PP
996: .Vb 2
997: \& operator ALL = DUMPS, KILL, PRINTING, SHUTDOWN, HALT, REBOOT,\e
998: \& /usr/oper/bin/
999: .Ve
1000: The \fBoperator\fR user may run commands limited to simple maintenance.
1001: Here, those are commands related to backups, killing processes, the
1002: printing system, shutting down the system, and any commands in the
1003: directory \fI/usr/oper/bin/\fR.
1004: .PP
1005: .Vb 1
1006: \& joe ALL = /usr/bin/su operator
1007: .Ve
1008: The user \fBjoe\fR may only \fIsu\fR\|(1) to operator.
1009: .PP
1010: .Vb 1
1011: \& pete HPPA = /usr/bin/passwd [A-z]*, !/usr/bin/passwd root
1012: .Ve
1013: The user \fBpete\fR is allowed to change anyone's password except for
1.9 millert 1014: root on the \fI\s-1HPPA\s0\fR machines. Note that this assumes \fIpasswd\fR\|(1)
1.1 millert 1015: does not take multiple usernames on the command line.
1016: .PP
1017: .Vb 1
1018: \& bob SPARC = (OP) ALL : SGI = (OP) ALL
1019: .Ve
1.9 millert 1020: The user \fBbob\fR may run anything on the \fI\s-1SPARC\s0\fR and \fI\s-1SGI\s0\fR machines
1021: as any user listed in the \fI\s-1OP\s0\fR \f(CW\*(C`Runas_Alias\*(C'\fR (\fBroot\fR and \fBoperator\fR).
1.1 millert 1022: .PP
1023: .Vb 1
1024: \& jim +biglab = ALL
1025: .Ve
1026: The user \fBjim\fR may run any command on machines in the \fIbiglab\fR netgroup.
1.9 millert 1027: \&\fBSudo\fR knows that \*(L"biglab\*(R" is a netgroup due to the '+' prefix.
1.1 millert 1028: .PP
1029: .Vb 1
1030: \& +secretaries ALL = PRINTING, /usr/bin/adduser, /usr/bin/rmuser
1031: .Ve
1032: Users in the \fBsecretaries\fR netgroup need to help manage the printers
1033: as well as add and remove users, so they are allowed to run those
1034: commands on all machines.
1035: .PP
1036: .Vb 1
1037: \& fred ALL = (DB) NOPASSWD: ALL
1038: .Ve
1.9 millert 1039: The user \fBfred\fR can run commands as any user in the \fI\s-1DB\s0\fR \f(CW\*(C`Runas_Alias\*(C'\fR
1.1 millert 1040: (\fBoracle\fR or \fBsybase\fR) without giving a password.
1041: .PP
1042: .Vb 1
1043: \& john ALPHA = /usr/bin/su [!-]*, !/usr/bin/su *root*
1044: .Ve
1.9 millert 1045: On the \fI\s-1ALPHA\s0\fR machines, user \fBjohn\fR may su to anyone except root
1.1 millert 1046: but he is not allowed to give \fIsu\fR\|(1) any flags.
1047: .PP
1048: .Vb 1
1049: \& jen ALL, !SERVERS = ALL
1050: .Ve
1051: The user \fBjen\fR may run any command on any machine except for those
1.9 millert 1052: in the \fI\s-1SERVERS\s0\fR \f(CW\*(C`Host_Alias\*(C'\fR (master, mail, www and ns).
1.1 millert 1053: .PP
1054: .Vb 1
1055: \& jill SERVERS = /usr/bin/, !SU, !SHELLS
1056: .Ve
1.9 millert 1057: For any machine in the \fI\s-1SERVERS\s0\fR \f(CW\*(C`Host_Alias\*(C'\fR, \fBjill\fR may run
1.1 millert 1058: any commands in the directory /usr/bin/ except for those commands
1.9 millert 1059: belonging to the \fI\s-1SU\s0\fR and \fI\s-1SHELLS\s0\fR \f(CW\*(C`Cmnd_Aliases\*(C'\fR.
1.1 millert 1060: .PP
1061: .Vb 1
1062: \& steve CSNETS = (operator) /usr/local/op_commands/
1063: .Ve
1064: The user \fBsteve\fR may run any command in the directory /usr/local/op_commands/
1065: but only as user operator.
1066: .PP
1067: .Vb 1
1068: \& matt valkyrie = KILL
1069: .Ve
1070: On his personal workstation, valkyrie, \fBmatt\fR needs to be able to
1071: kill hung processes.
1072: .PP
1073: .Vb 1
1074: \& WEBMASTERS www = (www) ALL, (root) /usr/bin/su www
1075: .Ve
1.9 millert 1076: On the host www, any user in the \fI\s-1WEBMASTERS\s0\fR \f(CW\*(C`User_Alias\*(C'\fR (will,
1.1 millert 1077: wendy, and wim), may run any command as user www (which owns the
1078: web pages) or simply \fIsu\fR\|(1) to www.
1079: .PP
1080: .Vb 2
1081: \& ALL CDROM = NOPASSWD: /sbin/umount /CDROM,\e
1082: \& /sbin/mount -o nosuid\e,nodev /dev/cd0a /CDROM
1083: .Ve
1.9 millert 1084: Any user may mount or unmount a \s-1CD-ROM\s0 on the machines in the \s-1CDROM\s0
1085: \&\f(CW\*(C`Host_Alias\*(C'\fR (orion, perseus, hercules) without entering a password.
1.7 pjanzen 1086: This is a bit tedious for users to type, so it is a prime candidate
1.1 millert 1087: for encapsulating in a shell script.
1088: .SH "SECURITY NOTES"
1.9 millert 1089: .IX Header "SECURITY NOTES"
1090: It is generally not effective to \*(L"subtract\*(R" commands from \f(CW\*(C`ALL\*(C'\fR
1091: using the '!' operator. A user can trivially circumvent this
1.1 millert 1092: by copying the desired command to a different name and then
1093: executing that. For example:
1094: .PP
1095: .Vb 1
1096: \& bill ALL = ALL, !SU, !SHELLS
1097: .Ve
1098: Doesn't really prevent \fBbill\fR from running the commands listed in
1.9 millert 1099: \&\fI\s-1SU\s0\fR or \fI\s-1SHELLS\s0\fR since he can simply copy those commands to a
1.1 millert 1100: different name, or use a shell escape from an editor or other
1101: program. Therefore, these kind of restrictions should be considered
1102: advisory at best (and reinforced by policy).
1103: .SH "CAVEATS"
1.9 millert 1104: .IX Header "CAVEATS"
1.1 millert 1105: The \fIsudoers\fR file should \fBalways\fR be edited by the \fBvisudo\fR
1106: command which locks the file and does grammatical checking. It is
1107: imperative that \fIsudoers\fR be free of syntax errors since \fBsudo\fR
1108: will not run with a syntactically incorrect \fIsudoers\fR file.
1.3 millert 1109: .PP
1110: When using netgroups of machines (as opposed to users), if you
1.5 millert 1111: store fully qualified hostnames in the netgroup (as is usually the
1112: case), you either need to have the machine's hostname be fully qualified
1.9 millert 1113: as returned by the \f(CW\*(C`hostname\*(C'\fR command or use the \fIfqdn\fR option in
1114: \&\fIsudoers\fR.
1.1 millert 1115: .SH "FILES"
1.9 millert 1116: .IX Header "FILES"
1.1 millert 1117: .Vb 3
1118: \& /etc/sudoers List of who can run what
1119: \& /etc/group Local groups file
1120: \& /etc/netgroup List of network groups
1121: .Ve
1122: .SH "SEE ALSO"
1123: .IX Header "SEE ALSO"
1.13 jmc 1124: \&\fIrsh\fR\|(1), \fIsu\fR\|(1), \fIfnmatch\fR\|(3), \fIsudo\fR\|(8), \fIvisudo\fR\|(8).