38c2d92d39fd0addc2b2cc245611855c614d82c1
[debian/sudo] / sudo.man.in
1 .\" Copyright (c) 1994-1996, 1998-2005, 2007
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: sudo.man.in,v 1.29.2.19 2008/01/05 23:59:42 millert Exp $
22 .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
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 .\" If the F register is turned on, we'll generate index entries on stderr for
73 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
74 .\" entries marked with X<> in POD.  Of course, you'll have to process the
75 .\" output yourself in some meaningful fashion.
76 .if \nF \{\
77 .    de IX
78 .    tm Index:\\$1\t\\n%\t"\\$2"
79 ..
80 .    nr % 0
81 .    rr F
82 .\}
83 .\"
84 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
85 .\" way too many mistakes in technical documents.
86 .hy 0
87 .if n .na
88 .\"
89 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
90 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
91 .    \" fudge factors for nroff and troff
92 .if n \{\
93 .    ds #H 0
94 .    ds #V .8m
95 .    ds #F .3m
96 .    ds #[ \f1
97 .    ds #] \fP
98 .\}
99 .if t \{\
100 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
101 .    ds #V .6m
102 .    ds #F 0
103 .    ds #[ \&
104 .    ds #] \&
105 .\}
106 .    \" simple accents for nroff and troff
107 .if n \{\
108 .    ds ' \&
109 .    ds ` \&
110 .    ds ^ \&
111 .    ds , \&
112 .    ds ~ ~
113 .    ds /
114 .\}
115 .if t \{\
116 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
117 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
118 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
119 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
120 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
121 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
122 .\}
123 .    \" troff and (daisy-wheel) nroff accents
124 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
125 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
126 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
127 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
128 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
129 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
130 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
131 .ds ae a\h'-(\w'a'u*4/10)'e
132 .ds Ae A\h'-(\w'A'u*4/10)'E
133 .    \" corrections for vroff
134 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
135 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
136 .    \" for low resolution devices (crt and lpr)
137 .if \n(.H>23 .if \n(.V>19 \
138 \{\
139 .    ds : e
140 .    ds 8 ss
141 .    ds o a
142 .    ds d- d\h'-1'\(ga
143 .    ds D- D\h'-1'\(hy
144 .    ds th \o'bp'
145 .    ds Th \o'LP'
146 .    ds ae ae
147 .    ds Ae AE
148 .\}
149 .rm #[ #] #H #V #F C
150 .\" ========================================================================
151 .\"
152 .IX Title "SUDO @mansectsu@"
153 .TH SUDO @mansectsu@ "January  5, 2008" "1.6.9p11" "MAINTENANCE COMMANDS"
154 .SH "NAME"
155 sudo, sudoedit \- execute a command as another user
156 .SH "SYNOPSIS"
157 .IX Header "SYNOPSIS"
158 \&\fBsudo\fR \fB\-h\fR | \fB\-K\fR | \fB\-k\fR | \fB\-L\fR | \fB\-l\fR | \fB\-V\fR | \fB\-v\fR
159 .PP
160 \&\fBsudo\fR [\fB\-bEHPS\fR] [\fB\-a\fR\ \fIauth_type\fR]
161 [\fB\-c\fR\ \fIclass\fR|\fI\-\fR] [\fB\-p\fR\ \fIprompt\fR] [\fB\-u\fR\ \fIusername\fR|\fI#uid\fR]
162 [\fB\s-1VAR\s0\fR=\fIvalue\fR] {\fB\-i\fR\ |\ \fB\-s\fR\ |\ \fIcommand\fR}
163 .PP
164 \&\fBsudoedit\fR [\fB\-S\fR] [\fB\-a\fR\ \fIauth_type\fR] [\fB\-c\fR\ \fIclass\fR|\fI\-\fR]
165 [\fB\-p\fR\ \fIprompt\fR] [\fB\-u\fR\ \fIusername\fR|\fI#uid\fR]
166 file ...
167 .SH "DESCRIPTION"
168 .IX Header "DESCRIPTION"
169 \&\fBsudo\fR allows a permitted user to execute a \fIcommand\fR as the
170 superuser or another user, as specified in the \fIsudoers\fR file.
171 The real and effective uid and gid are set to match those of the
172 target user as specified in the passwd file and the group vector
173 is initialized based on the group file (unless the \fB\-P\fR option was
174 specified).  If the invoking user is root or if the target user is
175 the same as the invoking user, no password is required.  Otherwise,
176 \&\fBsudo\fR requires that users authenticate themselves with a password
177 by default (\s-1NOTE:\s0 in the default configuration this is the user's
178 password, not the root password).  Once a user has been authenticated,
179 a timestamp is updated and the user may then use sudo without a
180 password for a short period of time (\f(CW\*(C`@timeout@\*(C'\fR minutes unless
181 overridden in \fIsudoers\fR).
182 .PP
183 When invoked as \fBsudoedit\fR, the \fB\-e\fR option (described below),
184 is implied.
185 .PP
186 \&\fBsudo\fR determines who is an authorized user by consulting the file
187 \&\fI@sysconfdir@/sudoers\fR.  By giving \fBsudo\fR the \fB\-v\fR flag, a user
188 can update the time stamp without running a \fIcommand\fR. The password
189 prompt itself will also time out if the user's password is not
190 entered within \f(CW\*(C`@password_timeout@\*(C'\fR minutes (unless overridden via
191 \&\fIsudoers\fR).
192 .PP
193 If a user who is not listed in the \fIsudoers\fR file tries to run a
194 command via \fBsudo\fR, mail is sent to the proper authorities, as
195 defined at configure time or in the \fIsudoers\fR file (defaults to
196 \&\f(CW\*(C`@mailto@\*(C'\fR).  Note that the mail will not be sent if an unauthorized
197 user tries to run sudo with the \fB\-l\fR or \fB\-v\fR flags.  This allows
198 users to determine for themselves whether or not they are allowed
199 to use \fBsudo\fR.
200 .PP
201 If \fBsudo\fR is run by root and the \f(CW\*(C`SUDO_USER\*(C'\fR environment variable
202 is set, \fBsudo\fR will use this value to determine who the actual
203 user is.  This can be used by a user to log commands through sudo
204 even when a root shell has been invoked.  It also allows the \fB\-e\fR
205 flag to remain useful even when being run via a sudo-run script or
206 program.  Note however, that the sudoers lookup is still done for
207 root, not the user specified by \f(CW\*(C`SUDO_USER\*(C'\fR.
208 .PP
209 \&\fBsudo\fR can log both successful and unsuccessful attempts (as well
210 as errors) to \fIsyslog\fR\|(3), a log file, or both.  By default \fBsudo\fR
211 will log via \fIsyslog\fR\|(3) but this is changeable at configure time
212 or via the \fIsudoers\fR file.
213 .SH "OPTIONS"
214 .IX Header "OPTIONS"
215 \&\fBsudo\fR accepts the following command line options:
216 .IP "\-a" 4
217 .IX Item "-a"
218 The \fB\-a\fR (\fIauthentication type\fR) option causes \fBsudo\fR to use the
219 specified authentication type when validating the user, as allowed
220 by \fI/etc/login.conf\fR.  The system administrator may specify a list
221 of sudo-specific authentication methods by adding an \*(L"auth\-sudo\*(R"
222 entry in \fI/etc/login.conf\fR.  This option is only available on systems
223 that support \s-1BSD\s0 authentication.
224 .IP "\-b" 4
225 .IX Item "-b"
226 The \fB\-b\fR (\fIbackground\fR) option tells \fBsudo\fR to run the given
227 command in the background.  Note that if you use the \fB\-b\fR
228 option you cannot use shell job control to manipulate the process.
229 .IP "\-c" 4
230 .IX Item "-c"
231 The \fB\-c\fR (\fIclass\fR) option causes \fBsudo\fR to run the specified command
232 with resources limited by the specified login class.  The \fIclass\fR
233 argument can be either a class name as defined in \f(CW\*(C`/etc/login.conf\*(C'\fR,
234 or a single '\-' character.  Specifying a \fIclass\fR of \f(CW\*(C`\-\*(C'\fR indicates
235 that the command should be run restricted by the default login
236 capabilities for the user the command is run as.  If the \fIclass\fR
237 argument specifies an existing user class, the command must be run
238 as root, or the \fBsudo\fR command must be run from a shell that is already
239 root.  This option is only available on systems with \s-1BSD\s0 login classes.
240 .IP "\-E" 4
241 .IX Item "-E"
242 The \fB\-E\fR (\fIpreserve\fR \fIenvironment\fR) option will override the
243 \&\fIenv_reset\fR option in \fIsudoers\fR\|(@mansectform@)).  It is only
244 available when either the matching command has the \f(CW\*(C`SETENV\*(C'\fR tag
245 or the \fIsetenv\fR option is set in \fIsudoers\fR\|(@mansectform@).
246 .IP "\-e" 4
247 .IX Item "-e"
248 The \fB\-e\fR (\fIedit\fR) option indicates that, instead of running
249 a command, the user wishes to edit one or more files.  In lieu
250 of a command, the string \*(L"sudoedit\*(R" is used when consulting
251 the \fIsudoers\fR file.  If the user is authorized by \fIsudoers\fR
252 the following steps are taken:
253 .RS 4
254 .IP "1." 4
255 Temporary copies are made of the files to be edited with the owner
256 set to the invoking user.
257 .IP "2." 4
258 The editor specified by the \f(CW\*(C`VISUAL\*(C'\fR or \f(CW\*(C`EDITOR\*(C'\fR environment
259 variables is run to edit the temporary files.  If neither \f(CW\*(C`VISUAL\*(C'\fR
260 nor \f(CW\*(C`EDITOR\*(C'\fR are set, the program listed in the \fIeditor\fR \fIsudoers\fR
261 variable is used.
262 .IP "3." 4
263 If they have been modified, the temporary files are copied back to
264 their original location and the temporary versions are removed.
265 .RE
266 .RS 4
267 .Sp
268 If the specified file does not exist, it will be created.  Note
269 that unlike most commands run by \fBsudo\fR, the editor is run with
270 the invoking user's environment unmodified.  If, for some reason,
271 \&\fBsudo\fR is unable to update a file with its edited version, the
272 user will receive a warning and the edited copy will remain in a
273 temporary file.
274 .RE
275 .IP "\-H" 4
276 .IX Item "-H"
277 The \fB\-H\fR (\fI\s-1HOME\s0\fR) option sets the \f(CW\*(C`HOME\*(C'\fR environment variable
278 to the homedir of the target user (root by default) as specified
279 in \fIpasswd\fR\|(@mansectform@).  By default, \fBsudo\fR does not modify \f(CW\*(C`HOME\*(C'\fR
280 (see \fIset_home\fR and \fIalways_set_home\fR in \fIsudoers\fR\|(@mansectform@)).
281 .IP "\-h" 4
282 .IX Item "-h"
283 The \fB\-h\fR (\fIhelp\fR) option causes \fBsudo\fR to print a usage message and exit.
284 .IP "\-i" 4
285 .IX Item "-i"
286 The \fB\-i\fR (\fIsimulate initial login\fR) option runs the shell specified
287 in the \fIpasswd\fR\|(@mansectform@) entry of the user that the command is
288 being run as.  The command name argument given to the shell begins
289 with a `\f(CW\*(C`\-\*(C'\fR' to tell the shell to run as a login shell.  \fBsudo\fR
290 attempts to change to that user's home directory before running the
291 shell.  It also initializes the environment, leaving \fI\s-1TERM\s0\fR
292 unchanged, setting \fI\s-1HOME\s0\fR, \fI\s-1SHELL\s0\fR, \fI\s-1USER\s0\fR, \fI\s-1LOGNAME\s0\fR, and
293 \&\fI\s-1PATH\s0\fR, and unsetting all other environment variables.  Note that
294 because the shell to use is determined before the \fIsudoers\fR file
295 is parsed, a \fIrunas_default\fR setting in \fIsudoers\fR will specify
296 the user to run the shell as but will not affect which shell is
297 actually run.
298 .IP "\-K" 4
299 .IX Item "-K"
300 The \fB\-K\fR (sure \fIkill\fR) option is like \fB\-k\fR except that it removes
301 the user's timestamp entirely.  Like \fB\-k\fR, this option does not
302 require a password.
303 .IP "\-k" 4
304 .IX Item "-k"
305 The \fB\-k\fR (\fIkill\fR) option to \fBsudo\fR invalidates the user's timestamp
306 by setting the time on it to the Epoch.  The next time \fBsudo\fR is
307 run a password will be required.  This option does not require a password
308 and was added to allow a user to revoke \fBsudo\fR permissions from a .logout
309 file.
310 .IP "\-L" 4
311 .IX Item "-L"
312 The \fB\-L\fR (\fIlist\fR defaults) option will list out the parameters
313 that may be set in a \fIDefaults\fR line along with a short description
314 for each.  This option is useful in conjunction with \fIgrep\fR\|(1).
315 .IP "\-l" 4
316 .IX Item "-l"
317 The \fB\-l\fR (\fIlist\fR) option will list out the allowed (and
318 forbidden) commands for the invoking user on the current host.
319 .IP "\-P" 4
320 .IX Item "-P"
321 The \fB\-P\fR (\fIpreserve\fR \fIgroup vector\fR) option causes \fBsudo\fR to
322 preserve the invoking user's group vector unaltered.  By default,
323 \&\fBsudo\fR will initialize the group vector to the list of groups the
324 target user is in.  The real and effective group IDs, however, are
325 still set to match the target user.
326 .IP "\-p" 4
327 .IX Item "-p"
328 The \fB\-p\fR (\fIprompt\fR) option allows you to override the default
329 password prompt and use a custom one.  The following percent (`\f(CW\*(C`%\*(C'\fR')
330 escapes are supported:
331 .RS 4
332 .ie n .IP "%H" 4
333 .el .IP "\f(CW%H\fR" 4
334 .IX Item "%H"
335 expanded to the local hostname including the domain name
336 (on if the machine's hostname is fully qualified or the \fIfqdn\fR
337 \&\fIsudoers\fR option is set)
338 .ie n .IP "%h" 4
339 .el .IP "\f(CW%h\fR" 4
340 .IX Item "%h"
341 expanded to the local hostname without the domain name
342 .ie n .IP "%p" 4
343 .el .IP "\f(CW%p\fR" 4
344 .IX Item "%p"
345 expanded to the user whose password is being asked for (respects the
346 \&\fIrootpw\fR, \fItargetpw\fR and \fIrunaspw\fR flags in \fIsudoers\fR)
347 .ie n .IP "%U" 4
348 .el .IP "\f(CW%U\fR" 4
349 .IX Item "%U"
350 expanded to the login name of the user the command will
351 be run as (defaults to root)
352 .ie n .IP "%u" 4
353 .el .IP "\f(CW%u\fR" 4
354 .IX Item "%u"
355 expanded to the invoking user's login name
356 .ie n .IP "\*(C`%%\*(C'" 4
357 .el .IP "\f(CW\*(C`%%\*(C'\fR" 4
358 .IX Item "%%"
359 two consecutive \f(CW\*(C`%\*(C'\fR characters are collapsed into a single \f(CW\*(C`%\*(C'\fR character
360 .RE
361 .RS 4
362 .RE
363 .IP "\-S" 4
364 .IX Item "-S"
365 The \fB\-S\fR (\fIstdin\fR) option causes \fBsudo\fR to read the password from
366 the standard input instead of the terminal device.
367 .IP "\-s" 4
368 .IX Item "-s"
369 The \fB\-s\fR (\fIshell\fR) option runs the shell specified by the \fI\s-1SHELL\s0\fR
370 environment variable if it is set or the shell as specified
371 in \fIpasswd\fR\|(@mansectform@).
372 .IP "\-u" 4
373 .IX Item "-u"
374 The \fB\-u\fR (\fIuser\fR) option causes \fBsudo\fR to run the specified
375 command as a user other than \fIroot\fR.  To specify a \fIuid\fR instead
376 of a \fIusername\fR, use \fI#uid\fR.  When running commands as a \fIuid\fR,
377 many shells require that the '#' be escaped with a backslash ('\e').
378 Note that if the \fItargetpw\fR Defaults option is set (see \fIsudoers\fR\|(@mansectform@))
379 it is not possible to run commands with a uid not listed in the
380 password database.
381 .IP "\-V" 4
382 .IX Item "-V"
383 The \fB\-V\fR (\fIversion\fR) option causes \fBsudo\fR to print the version
384 number and exit.  If the invoking user is already root the \fB\-V\fR
385 option will print out a list of the defaults \fBsudo\fR was compiled
386 with as well as the machine's local network addresses.
387 .IP "\-v" 4
388 .IX Item "-v"
389 If given the \fB\-v\fR (\fIvalidate\fR) option, \fBsudo\fR will update the
390 user's timestamp, prompting for the user's password if necessary.
391 This extends the \fBsudo\fR timeout for another \f(CW\*(C`@timeout@\*(C'\fR minutes
392 (or whatever the timeout is set to in \fIsudoers\fR) but does not run
393 a command.
394 .IP "\-\-" 4
395 The \fB\-\-\fR flag indicates that \fBsudo\fR should stop processing command
396 line arguments.  It is most useful in conjunction with the \fB\-s\fR flag.
397 .PP
398 Environment variables to be set for the command may also be passed
399 on the command line in the form of \fB\s-1VAR\s0\fR=\fIvalue\fR, e.g.
400 \&\fB\s-1LD_LIBRARY_PATH\s0\fR=\fI/usr/local/pkg/lib\fR.  Variables passed on the
401 command line are subject to the same restrictions as normal environment
402 variables with one important exception.  If the \fIsetenv\fR option
403 is set in \fIsudoers\fR, the command to be run has the \f(CW\*(C`SETENV\*(C'\fR tag
404 set or the command matched is \f(CW\*(C`ALL\*(C'\fR, the user may set variables
405 that would overwise be forbidden.  See \fIsudoers\fR\|(@mansectform@) for more information.
406 .SH "RETURN VALUES"
407 .IX Header "RETURN VALUES"
408 Upon successful execution of a program, the return value from \fBsudo\fR
409 will simply be the return value of the program that was executed.
410 .PP
411 Otherwise, \fBsudo\fR quits with an exit value of 1 if there is a
412 configuration/permission problem or if \fBsudo\fR cannot execute the
413 given command.  In the latter case the error string is printed to
414 stderr.  If \fBsudo\fR cannot \fIstat\fR\|(2) one or more entries in the user's
415 \&\f(CW\*(C`PATH\*(C'\fR an error is printed on stderr.  (If the directory does not
416 exist or if it is not really a directory, the entry is ignored and
417 no error is printed.)  This should not happen under normal
418 circumstances.  The most common reason for \fIstat\fR\|(2) to return
419 \&\*(L"permission denied\*(R" is if you are running an automounter and one
420 of the directories in your \f(CW\*(C`PATH\*(C'\fR is on a machine that is currently
421 unreachable.
422 .SH "SECURITY NOTES"
423 .IX Header "SECURITY NOTES"
424 \&\fBsudo\fR tries to be safe when executing external commands.
425 .PP
426 There are two distinct ways to deal with environment variables.
427 By default, the \fIenv_reset\fR \fIsudoers\fR option is enabled.
428 This causes commands to be executed with a minimal environment
429 containing \f(CW\*(C`TERM\*(C'\fR, \f(CW\*(C`PATH\*(C'\fR, \f(CW\*(C`HOME\*(C'\fR, \f(CW\*(C`SHELL\*(C'\fR, \f(CW\*(C`LOGNAME\*(C'\fR, \f(CW\*(C`USER\*(C'\fR
430 and \f(CW\*(C`USERNAME\*(C'\fR in addition to variables from the invoking process
431 permitted by the \fIenv_check\fR and \fIenv_keep\fR \fIsudoers\fR options.
432 There is effectively a whitelist for environment variables.
433 .PP
434 If, however, the \fIenv_reset\fR option is disabled in \fIsudoers\fR, any
435 variables not explicitly denied by the \fIenv_check\fR and \fIenv_delete\fR
436 options are inherited from the invoking process.  In this case,
437 \&\fIenv_check\fR and \fIenv_delete\fR behave like a blacklist.  Since it
438 is not possible to blacklist all potentially dangerous environment
439 variables, use of the default \fIenv_reset\fR behavior is encouraged.
440 .PP
441 In all cases, environment variables with a value beginning with
442 \&\f(CW\*(C`()\*(C'\fR are removed as they could be interpreted as \fBbash\fR functions.
443 The list of environment variables that \fBsudo\fR allows or denies is
444 contained in the output of \f(CW\*(C`sudo \-V\*(C'\fR when run as root.
445 .PP
446 Note that the dynamic linker on most operating systems will remove
447 variables that can control dynamic linking from the environment of
448 setuid executables, including \fBsudo\fR.  Depending on the operating
449 system this may include \f(CW\*(C`_RLD*\*(C'\fR, \f(CW\*(C`DYLD_*\*(C'\fR, \f(CW\*(C`LD_*\*(C'\fR, \f(CW\*(C`LDR_*\*(C'\fR,
450 \&\f(CW\*(C`LIBPATH\*(C'\fR, \f(CW\*(C`SHLIB_PATH\*(C'\fR, and others.  These type of variables are
451 removed from the environment before \fBsudo\fR even begins execution
452 and, as such, it is not possible for \fBsudo\fR to preserve them.
453 .PP
454 To prevent command spoofing, \fBsudo\fR checks \*(L".\*(R" and "" (both denoting
455 current directory) last when searching for a command in the user's
456 \&\s-1PATH\s0 (if one or both are in the \s-1PATH\s0).  Note, however, that the
457 \&\f(CW\*(C`PATH\*(C'\fR environment variable is further modified in Debian because of
458 the use of the \fI\s-1SECURE_PATH\s0\fR build option.
459 .PP
460 \&\fBsudo\fR will check the ownership of its timestamp directory
461 (\fI@timedir@\fR by default) and ignore the directory's contents if
462 it is not owned by root or if it is writable by a user other than
463 root.  On systems that allow non-root users to give away files via
464 \&\fIchown\fR\|(2), if the timestamp directory is located in a directory
465 writable by anyone (e.g., \fI/tmp\fR), it is possible for a user to
466 create the timestamp directory before \fBsudo\fR is run.  However,
467 because \fBsudo\fR checks the ownership and mode of the directory and
468 its contents, the only damage that can be done is to \*(L"hide\*(R" files
469 by putting them in the timestamp dir.  This is unlikely to happen
470 since once the timestamp dir is owned by root and inaccessible by
471 any other user, the user placing files there would be unable to get
472 them back out.  To get around this issue you can use a directory
473 that is not world-writable for the timestamps (\fI/var/adm/sudo\fR for
474 instance) or create \fI@timedir@\fR with the appropriate owner (root)
475 and permissions (0700) in the system startup files.
476 .PP
477 \&\fBsudo\fR will not honor timestamps set far in the future.
478 Timestamps with a date greater than current_time + 2 * \f(CW\*(C`TIMEOUT\*(C'\fR
479 will be ignored and sudo will log and complain.  This is done to
480 keep a user from creating his/her own timestamp with a bogus
481 date on systems that allow users to give away files.
482 .PP
483 Please note that \fBsudo\fR will normally only log the command it
484 explicitly runs.  If a user runs a command such as \f(CW\*(C`sudo su\*(C'\fR or
485 \&\f(CW\*(C`sudo sh\*(C'\fR, subsequent commands run from that shell will \fInot\fR be
486 logged, nor will \fBsudo\fR's access control affect them.  The same
487 is true for commands that offer shell escapes (including most
488 editors).  Because of this, care must be taken when giving users
489 access to commands via \fBsudo\fR to verify that the command does not
490 inadvertently give the user an effective root shell.  For more
491 information, please see the \f(CW\*(C`PREVENTING SHELL ESCAPES\*(C'\fR section in
492 \&\fIsudoers\fR\|(@mansectform@).
493 .SH "ENVIRONMENT"
494 .IX Header "ENVIRONMENT"
495 \&\fBsudo\fR utilizes the following environment variables:
496 .ie n .IP "\*(C`EDITOR\*(C'" 16
497 .el .IP "\f(CW\*(C`EDITOR\*(C'\fR" 16
498 .IX Item "EDITOR"
499 Default editor to use in \fB\-e\fR (sudoedit) mode if \f(CW\*(C`VISUAL\*(C'\fR is not set
500 .ie n .IP "\*(C`HOME\*(C'" 16
501 .el .IP "\f(CW\*(C`HOME\*(C'\fR" 16
502 .IX Item "HOME"
503 In \fB\-s\fR or \fB\-H\fR mode (or if sudo was configured with the
504 \&\-\-enable\-shell\-sets\-home option), set to homedir of the target user
505 .ie n .IP "\*(C`PATH\*(C'" 16
506 .el .IP "\f(CW\*(C`PATH\*(C'\fR" 16
507 .IX Item "PATH"
508 Set to a sane value if the \fIsecure_path\fR sudoers option is set.
509 .ie n .IP "\*(C`SHELL\*(C'" 16
510 .el .IP "\f(CW\*(C`SHELL\*(C'\fR" 16
511 .IX Item "SHELL"
512 Used to determine shell to run with \f(CW\*(C`\-s\*(C'\fR option
513 .ie n .IP "\*(C`SUDO_PROMPT\*(C'" 16
514 .el .IP "\f(CW\*(C`SUDO_PROMPT\*(C'\fR" 16
515 .IX Item "SUDO_PROMPT"
516 Used as the default password prompt
517 .ie n .IP "\*(C`SUDO_COMMAND\*(C'" 16
518 .el .IP "\f(CW\*(C`SUDO_COMMAND\*(C'\fR" 16
519 .IX Item "SUDO_COMMAND"
520 Set to the command run by sudo
521 .ie n .IP "\*(C`SUDO_USER\*(C'" 16
522 .el .IP "\f(CW\*(C`SUDO_USER\*(C'\fR" 16
523 .IX Item "SUDO_USER"
524 Set to the login of the user who invoked sudo
525 .ie n .IP "\*(C`SUDO_UID\*(C'" 16
526 .el .IP "\f(CW\*(C`SUDO_UID\*(C'\fR" 16
527 .IX Item "SUDO_UID"
528 Set to the uid of the user who invoked sudo
529 .ie n .IP "\*(C`SUDO_GID\*(C'" 16
530 .el .IP "\f(CW\*(C`SUDO_GID\*(C'\fR" 16
531 .IX Item "SUDO_GID"
532 Set to the gid of the user who invoked sudo
533 .ie n .IP "\*(C`SUDO_PS1\*(C'" 16
534 .el .IP "\f(CW\*(C`SUDO_PS1\*(C'\fR" 16
535 .IX Item "SUDO_PS1"
536 If set, \f(CW\*(C`PS1\*(C'\fR will be set to its value
537 .ie n .IP "\*(C`USER\*(C'" 16
538 .el .IP "\f(CW\*(C`USER\*(C'\fR" 16
539 .IX Item "USER"
540 Set to the target user (root unless the \fB\-u\fR option is specified)
541 .ie n .IP "\*(C`VISUAL\*(C'" 16
542 .el .IP "\f(CW\*(C`VISUAL\*(C'\fR" 16
543 .IX Item "VISUAL"
544 Default editor to use in \fB\-e\fR (sudoedit) mode
545 .SH "FILES"
546 .IX Header "FILES"
547 .ie n .IP "\fI@sysconfdir@/sudoers\fR\*(C`              \*(C'List of who can run what" 4
548 .el .IP "\fI@sysconfdir@/sudoers\fR\f(CW\*(C`           \*(C'\fRList of who can run what" 4
549 .IX Item "@sysconfdir@/sudoers          List of who can run what"
550 .PD 0
551 .ie n .IP "\fI@timedir@\fR\*(C`         \*(C'Directory containing timestamps" 4
552 .el .IP "\fI@timedir@\fR\f(CW\*(C`              \*(C'\fRDirectory containing timestamps" 4
553 .IX Item "@timedir@             Directory containing timestamps"
554 .PD
555 .SH "EXAMPLES"
556 .IX Header "EXAMPLES"
557 Note: the following examples assume suitable \fIsudoers\fR\|(@mansectform@) entries.
558 .PP
559 To get a file listing of an unreadable directory:
560 .PP
561 .Vb 1
562 \& $ sudo ls /usr/local/protected
563 .Ve
564 .PP
565 To list the home directory of user yazza on a machine where the
566 file system holding ~yazza is not exported as root:
567 .PP
568 .Vb 1
569 \& $ sudo \-u yazza ls ~yazza
570 .Ve
571 .PP
572 To edit the \fIindex.html\fR file as user www:
573 .PP
574 .Vb 1
575 \& $ sudo \-u www vi ~www/htdocs/index.html
576 .Ve
577 .PP
578 To shutdown a machine:
579 .PP
580 .Vb 1
581 \& $ sudo shutdown \-r +15 "quick reboot"
582 .Ve
583 .PP
584 To make a usage listing of the directories in the /home
585 partition.  Note that this runs the commands in a sub-shell
586 to make the \f(CW\*(C`cd\*(C'\fR and file redirection work.
587 .PP
588 .Vb 1
589 \& $ sudo sh \-c "cd /home ; du \-s * | sort \-rn > USAGE"
590 .Ve
591 .SH "SEE ALSO"
592 .IX Header "SEE ALSO"
593 \&\fIgrep\fR\|(1), \fIsu\fR\|(1), \fIstat\fR\|(2), \fIlogin_cap\fR\|(3), \fIpasswd\fR\|(@mansectform@),
594 \&\fIsudoers\fR\|(@mansectform@), \fIvisudo\fR\|(@mansectsu@)
595 .PP
596 The file /usr/share/doc/sudo/OPTIONS describes the options used for building
597 the Debian version of sudo, some of which change default behaviors documented
598 elsewhere in this document.
599 .SH "AUTHORS"
600 .IX Header "AUTHORS"
601 Many people have worked on \fBsudo\fR over the years; this
602 version consists of code written primarily by:
603 .PP
604 .Vb 2
605 \&        Todd C. Miller
606 \&        Chris Jepeway
607 .Ve
608 .PP
609 See the \s-1HISTORY\s0 file in the \fBsudo\fR distribution or visit
610 http://www.sudo.ws/sudo/history.html for a short history
611 of \fBsudo\fR.
612 .SH "CAVEATS"
613 .IX Header "CAVEATS"
614 There is no easy way to prevent a user from gaining a root shell
615 if that user is allowed to run arbitrary commands via \fBsudo\fR.
616 Also, many programs (such as editors) allow the user to run commands
617 via shell escapes, thus avoiding \fBsudo\fR's checks.  However, on
618 most systems it is possible to prevent shell escapes with \fBsudo\fR's
619 \&\fInoexec\fR functionality.  See the \fIsudoers\fR\|(@mansectform@) manual
620 for details.
621 .PP
622 It is not meaningful to run the \f(CW\*(C`cd\*(C'\fR command directly via sudo, e.g.,
623 .PP
624 .Vb 1
625 \& $ sudo cd /usr/local/protected
626 .Ve
627 .PP
628 since when the command exits the parent process (your shell) will
629 still be the same.  Please see the \s-1EXAMPLES\s0 section for more information.
630 .PP
631 If users have sudo \f(CW\*(C`ALL\*(C'\fR there is nothing to prevent them from
632 creating their own program that gives them a root shell regardless
633 of any '!' elements in the user specification.
634 .PP
635 Running shell scripts via \fBsudo\fR can expose the same kernel bugs that
636 make setuid shell scripts unsafe on some operating systems (if your \s-1OS\s0
637 has a /dev/fd/ directory, setuid shell scripts are generally safe).
638 .SH "BUGS"
639 .IX Header "BUGS"
640 If you feel you have found a bug in \fBsudo\fR, please submit a bug report
641 at http://www.sudo.ws/sudo/bugs/
642 .SH "SUPPORT"
643 .IX Header "SUPPORT"
644 Limited free support is available via the sudo-users mailing list,
645 see http://www.sudo.ws/mailman/listinfo/sudo\-users to subscribe or
646 search the archives.
647 .SH "DISCLAIMER"
648 .IX Header "DISCLAIMER"
649 \&\fBsudo\fR is provided ``\s-1AS\s0 \s-1IS\s0'' and any express or implied warranties,
650 including, but not limited to, the implied warranties of merchantability
651 and fitness for a particular purpose are disclaimed.  See the \s-1LICENSE\s0
652 file distributed with \fBsudo\fR or http://www.sudo.ws/sudo/license.html
653 for complete details.