d98c9586209e94d7a5bc3ec170f12cc9c0a1c694
[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.17 2007/12/17 22:11:10 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.  | will give a
50 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
51 .\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
52 .\" expand to `' in nroff, nothing in troff, for use with C<>.
53 .tr \(*W-|\(bv\*(Tr
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@ "December 17, 2007" "1.6.9p10" "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 "%U" 4
343 .el .IP "\f(CW%U\fR" 4
344 .IX Item "%U"
345 expanded to the login name of the user the command will
346 be run as (defaults to root)
347 .ie n .IP "%u" 4
348 .el .IP "\f(CW%u\fR" 4
349 .IX Item "%u"
350 expanded to the invoking user's login name
351 .ie n .IP "\*(C`%%\*(C'" 4
352 .el .IP "\f(CW\*(C`%%\*(C'\fR" 4
353 .IX Item "%%"
354 two consecutive \f(CW\*(C`%\*(C'\fR characters are collapsed into a single \f(CW\*(C`%\*(C'\fR character
355 .RE
356 .RS 4
357 .RE
358 .IP "\-S" 4
359 .IX Item "-S"
360 The \fB\-S\fR (\fIstdin\fR) option causes \fBsudo\fR to read the password from
361 the standard input instead of the terminal device.
362 .IP "\-s" 4
363 .IX Item "-s"
364 The \fB\-s\fR (\fIshell\fR) option runs the shell specified by the \fI\s-1SHELL\s0\fR
365 environment variable if it is set or the shell as specified
366 in \fIpasswd\fR\|(@mansectform@).
367 .IP "\-u" 4
368 .IX Item "-u"
369 The \fB\-u\fR (\fIuser\fR) option causes \fBsudo\fR to run the specified
370 command as a user other than \fIroot\fR.  To specify a \fIuid\fR instead
371 of a \fIusername\fR, use \fI#uid\fR.  When running commands as a \fIuid\fR,
372 many shells require that the '#' be escaped with a backslash ('\e').
373 Note that if the \fItargetpw\fR Defaults option is set (see \fIsudoers\fR\|(@mansectform@))
374 it is not possible to run commands with a uid not listed in the
375 password database.
376 .IP "\-V" 4
377 .IX Item "-V"
378 The \fB\-V\fR (\fIversion\fR) option causes \fBsudo\fR to print the version
379 number and exit.  If the invoking user is already root the \fB\-V\fR
380 option will print out a list of the defaults \fBsudo\fR was compiled
381 with as well as the machine's local network addresses.
382 .IP "\-v" 4
383 .IX Item "-v"
384 If given the \fB\-v\fR (\fIvalidate\fR) option, \fBsudo\fR will update the
385 user's timestamp, prompting for the user's password if necessary.
386 This extends the \fBsudo\fR timeout for another \f(CW\*(C`@timeout@\*(C'\fR minutes
387 (or whatever the timeout is set to in \fIsudoers\fR) but does not run
388 a command.
389 .IP "\-\-" 4
390 The \fB\-\-\fR flag indicates that \fBsudo\fR should stop processing command
391 line arguments.  It is most useful in conjunction with the \fB\-s\fR flag.
392 .PP
393 Environment variables to be set for the command may also be passed
394 on the command line in the form of \fB\s-1VAR\s0\fR=\fIvalue\fR, e.g.
395 \&\fB\s-1LD_LIBRARY_PATH\s0\fR=\fI/usr/local/pkg/lib\fR.  Variables passed on the
396 command line are subject to the same restrictions as normal environment
397 variables with one important exception.  If the \fIsetenv\fR option
398 is set in \fIsudoers\fR, the command to be run has the \f(CW\*(C`SETENV\*(C'\fR tag
399 set or the command matched is \f(CW\*(C`ALL\*(C'\fR, the user may set variables
400 that would overwise be forbidden.  See \fIsudoers\fR\|(@mansectform@) for more information.
401 .SH "RETURN VALUES"
402 .IX Header "RETURN VALUES"
403 Upon successful execution of a program, the return value from \fBsudo\fR
404 will simply be the return value of the program that was executed.
405 .PP
406 Otherwise, \fBsudo\fR quits with an exit value of 1 if there is a
407 configuration/permission problem or if \fBsudo\fR cannot execute the
408 given command.  In the latter case the error string is printed to
409 stderr.  If \fBsudo\fR cannot \fIstat\fR\|(2) one or more entries in the user's
410 \&\f(CW\*(C`PATH\*(C'\fR an error is printed on stderr.  (If the directory does not
411 exist or if it is not really a directory, the entry is ignored and
412 no error is printed.)  This should not happen under normal
413 circumstances.  The most common reason for \fIstat\fR\|(2) to return
414 \&\*(L"permission denied\*(R" is if you are running an automounter and one
415 of the directories in your \f(CW\*(C`PATH\*(C'\fR is on a machine that is currently
416 unreachable.
417 .SH "SECURITY NOTES"
418 .IX Header "SECURITY NOTES"
419 \&\fBsudo\fR tries to be safe when executing external commands.
420 .PP
421 There are two distinct ways to deal with environment variables.
422 By default, the \fIenv_reset\fR \fIsudoers\fR option is enabled.
423 This causes commands to be executed with a minimal environment
424 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
425 and \f(CW\*(C`USERNAME\*(C'\fR in addition to variables from the invoking process
426 permitted by the \fIenv_check\fR and \fIenv_keep\fR \fIsudoers\fR options.
427 There is effectively a whitelist for environment variables.
428 .PP
429 If, however, the \fIenv_reset\fR option is disabled in \fIsudoers\fR, any
430 variables not explicitly denied by the \fIenv_check\fR and \fIenv_delete\fR
431 options are inherited from the invoking process.  In this case,
432 \&\fIenv_check\fR and \fIenv_delete\fR behave like a blacklist.  Since it
433 is not possible to blacklist all potentially dangerous environment
434 variables, use of the default \fIenv_reset\fR behavior is encouraged.
435 .PP
436 In all cases, environment variables with a value beginning with
437 \&\f(CW\*(C`()\*(C'\fR are removed as they could be interpreted as \fBbash\fR functions.
438 The list of environment variables that \fBsudo\fR allows or denies is
439 contained in the output of \f(CW\*(C`sudo \-V\*(C'\fR when run as root.
440 .PP
441 Note that the dynamic linker on most operating systems will remove
442 variables that can control dynamic linking from the environment of
443 setuid executables, including \fBsudo\fR.  Depending on the operating
444 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,
445 \&\f(CW\*(C`LIBPATH\*(C'\fR, \f(CW\*(C`SHLIB_PATH\*(C'\fR, and others.  These type of variables are
446 removed from the environment before \fBsudo\fR even begins execution
447 and, as such, it is not possible for \fBsudo\fR to preserve them.
448 .PP
449 To prevent command spoofing, \fBsudo\fR checks \*(L".\*(R" and "" (both denoting
450 current directory) last when searching for a command in the user's
451 \&\s-1PATH\s0 (if one or both are in the \s-1PATH\s0).  Note, however, that the
452 actual \f(CW\*(C`PATH\*(C'\fR environment variable is \fInot\fR modified and is passed
453 unchanged to the program that \fBsudo\fR executes.
454 .PP
455 \&\fBsudo\fR will check the ownership of its timestamp directory
456 (\fI@timedir@\fR by default) and ignore the directory's contents if
457 it is not owned by root or if it is writable by a user other than
458 root.  On systems that allow non-root users to give away files via
459 \&\fIchown\fR\|(2), if the timestamp directory is located in a directory
460 writable by anyone (e.g., \fI/tmp\fR), it is possible for a user to
461 create the timestamp directory before \fBsudo\fR is run.  However,
462 because \fBsudo\fR checks the ownership and mode of the directory and
463 its contents, the only damage that can be done is to \*(L"hide\*(R" files
464 by putting them in the timestamp dir.  This is unlikely to happen
465 since once the timestamp dir is owned by root and inaccessible by
466 any other user, the user placing files there would be unable to get
467 them back out.  To get around this issue you can use a directory
468 that is not world-writable for the timestamps (\fI/var/adm/sudo\fR for
469 instance) or create \fI@timedir@\fR with the appropriate owner (root)
470 and permissions (0700) in the system startup files.
471 .PP
472 \&\fBsudo\fR will not honor timestamps set far in the future.
473 Timestamps with a date greater than current_time + 2 * \f(CW\*(C`TIMEOUT\*(C'\fR
474 will be ignored and sudo will log and complain.  This is done to
475 keep a user from creating his/her own timestamp with a bogus
476 date on systems that allow users to give away files.
477 .PP
478 Please note that \fBsudo\fR will normally only log the command it
479 explicitly runs.  If a user runs a command such as \f(CW\*(C`sudo su\*(C'\fR or
480 \&\f(CW\*(C`sudo sh\*(C'\fR, subsequent commands run from that shell will \fInot\fR be
481 logged, nor will \fBsudo\fR's access control affect them.  The same
482 is true for commands that offer shell escapes (including most
483 editors).  Because of this, care must be taken when giving users
484 access to commands via \fBsudo\fR to verify that the command does not
485 inadvertently give the user an effective root shell.  For more
486 information, please see the \f(CW\*(C`PREVENTING SHELL ESCAPES\*(C'\fR section in
487 \&\fIsudoers\fR\|(@mansectform@).
488 .SH "ENVIRONMENT"
489 .IX Header "ENVIRONMENT"
490 \&\fBsudo\fR utilizes the following environment variables:
491 .ie n .IP "\*(C`EDITOR\*(C'" 16
492 .el .IP "\f(CW\*(C`EDITOR\*(C'\fR" 16
493 .IX Item "EDITOR"
494 Default editor to use in \fB\-e\fR (sudoedit) mode if \f(CW\*(C`VISUAL\*(C'\fR is not set
495 .ie n .IP "\*(C`HOME\*(C'" 16
496 .el .IP "\f(CW\*(C`HOME\*(C'\fR" 16
497 .IX Item "HOME"
498 In \fB\-s\fR or \fB\-H\fR mode (or if sudo was configured with the
499 \&\-\-enable\-shell\-sets\-home option), set to homedir of the target user
500 .ie n .IP "\*(C`PATH\*(C'" 16
501 .el .IP "\f(CW\*(C`PATH\*(C'\fR" 16
502 .IX Item "PATH"
503 Set to a sane value if the \fIsecure_path\fR sudoers option is set.
504 .ie n .IP "\*(C`SHELL\*(C'" 16
505 .el .IP "\f(CW\*(C`SHELL\*(C'\fR" 16
506 .IX Item "SHELL"
507 Used to determine shell to run with \f(CW\*(C`\-s\*(C'\fR option
508 .ie n .IP "\*(C`SUDO_PROMPT\*(C'" 16
509 .el .IP "\f(CW\*(C`SUDO_PROMPT\*(C'\fR" 16
510 .IX Item "SUDO_PROMPT"
511 Used as the default password prompt
512 .ie n .IP "\*(C`SUDO_COMMAND\*(C'" 16
513 .el .IP "\f(CW\*(C`SUDO_COMMAND\*(C'\fR" 16
514 .IX Item "SUDO_COMMAND"
515 Set to the command run by sudo
516 .ie n .IP "\*(C`SUDO_USER\*(C'" 16
517 .el .IP "\f(CW\*(C`SUDO_USER\*(C'\fR" 16
518 .IX Item "SUDO_USER"
519 Set to the login of the user who invoked sudo
520 .ie n .IP "\*(C`SUDO_UID\*(C'" 16
521 .el .IP "\f(CW\*(C`SUDO_UID\*(C'\fR" 16
522 .IX Item "SUDO_UID"
523 Set to the uid of the user who invoked sudo
524 .ie n .IP "\*(C`SUDO_GID\*(C'" 16
525 .el .IP "\f(CW\*(C`SUDO_GID\*(C'\fR" 16
526 .IX Item "SUDO_GID"
527 Set to the gid of the user who invoked sudo
528 .ie n .IP "\*(C`SUDO_PS1\*(C'" 16
529 .el .IP "\f(CW\*(C`SUDO_PS1\*(C'\fR" 16
530 .IX Item "SUDO_PS1"
531 If set, \f(CW\*(C`PS1\*(C'\fR will be set to its value
532 .ie n .IP "\*(C`USER\*(C'" 16
533 .el .IP "\f(CW\*(C`USER\*(C'\fR" 16
534 .IX Item "USER"
535 Set to the target user (root unless the \fB\-u\fR option is specified)
536 .ie n .IP "\*(C`VISUAL\*(C'" 16
537 .el .IP "\f(CW\*(C`VISUAL\*(C'\fR" 16
538 .IX Item "VISUAL"
539 Default editor to use in \fB\-e\fR (sudoedit) mode
540 .SH "FILES"
541 .IX Header "FILES"
542 .ie n .IP "\fI@sysconfdir@/sudoers\fR\*(C`              \*(C'List of who can run what" 4
543 .el .IP "\fI@sysconfdir@/sudoers\fR\f(CW\*(C`           \*(C'\fRList of who can run what" 4
544 .IX Item "@sysconfdir@/sudoers          List of who can run what"
545 .PD 0
546 .ie n .IP "\fI@timedir@\fR\*(C`         \*(C'Directory containing timestamps" 4
547 .el .IP "\fI@timedir@\fR\f(CW\*(C`              \*(C'\fRDirectory containing timestamps" 4
548 .IX Item "@timedir@             Directory containing timestamps"
549 .PD
550 .SH "EXAMPLES"
551 .IX Header "EXAMPLES"
552 Note: the following examples assume suitable \fIsudoers\fR\|(@mansectform@) entries.
553 .PP
554 To get a file listing of an unreadable directory:
555 .PP
556 .Vb 1
557 \& $ sudo ls /usr/local/protected
558 .Ve
559 .PP
560 To list the home directory of user yazza on a machine where the
561 file system holding ~yazza is not exported as root:
562 .PP
563 .Vb 1
564 \& $ sudo -u yazza ls ~yazza
565 .Ve
566 .PP
567 To edit the \fIindex.html\fR file as user www:
568 .PP
569 .Vb 1
570 \& $ sudo -u www vi ~www/htdocs/index.html
571 .Ve
572 .PP
573 To shutdown a machine:
574 .PP
575 .Vb 1
576 \& $ sudo shutdown -r +15 "quick reboot"
577 .Ve
578 .PP
579 To make a usage listing of the directories in the /home
580 partition.  Note that this runs the commands in a sub-shell
581 to make the \f(CW\*(C`cd\*(C'\fR and file redirection work.
582 .PP
583 .Vb 1
584 \& $ sudo sh -c "cd /home ; du -s * | sort -rn > USAGE"
585 .Ve
586 .SH "SEE ALSO"
587 .IX Header "SEE ALSO"
588 \&\fIgrep\fR\|(1), \fIsu\fR\|(1), \fIstat\fR\|(2), \fIlogin_cap\fR\|(3), \fIpasswd\fR\|(@mansectform@),
589 \&\fIsudoers\fR\|(@mansectform@), \fIvisudo\fR\|(@mansectsu@)
590 .SH "AUTHORS"
591 .IX Header "AUTHORS"
592 Many people have worked on \fBsudo\fR over the years; this
593 version consists of code written primarily by:
594 .PP
595 .Vb 2
596 \&        Todd C. Miller
597 \&        Chris Jepeway
598 .Ve
599 .PP
600 See the \s-1HISTORY\s0 file in the \fBsudo\fR distribution or visit
601 http://www.sudo.ws/sudo/history.html for a short history
602 of \fBsudo\fR.
603 .SH "CAVEATS"
604 .IX Header "CAVEATS"
605 There is no easy way to prevent a user from gaining a root shell
606 if that user is allowed to run arbitrary commands via \fBsudo\fR.
607 Also, many programs (such as editors) allow the user to run commands
608 via shell escapes, thus avoiding \fBsudo\fR's checks.  However, on
609 most systems it is possible to prevent shell escapes with \fBsudo\fR's
610 \&\fInoexec\fR functionality.  See the \fIsudoers\fR\|(@mansectform@) manual
611 for details.
612 .PP
613 It is not meaningful to run the \f(CW\*(C`cd\*(C'\fR command directly via sudo, e.g.,
614 .PP
615 .Vb 1
616 \& $ sudo cd /usr/local/protected
617 .Ve
618 .PP
619 since when the command exits the parent process (your shell) will
620 still be the same.  Please see the \s-1EXAMPLES\s0 section for more information.
621 .PP
622 If users have sudo \f(CW\*(C`ALL\*(C'\fR there is nothing to prevent them from
623 creating their own program that gives them a root shell regardless
624 of any '!' elements in the user specification.
625 .PP
626 Running shell scripts via \fBsudo\fR can expose the same kernel bugs that
627 make setuid shell scripts unsafe on some operating systems (if your \s-1OS\s0
628 has a /dev/fd/ directory, setuid shell scripts are generally safe).
629 .SH "BUGS"
630 .IX Header "BUGS"
631 If you feel you have found a bug in \fBsudo\fR, please submit a bug report
632 at http://www.sudo.ws/sudo/bugs/
633 .SH "SUPPORT"
634 .IX Header "SUPPORT"
635 Limited free support is available via the sudo-users mailing list,
636 see http://www.sudo.ws/mailman/listinfo/sudo\-users to subscribe or
637 search the archives.
638 .SH "DISCLAIMER"
639 .IX Header "DISCLAIMER"
640 \&\fBsudo\fR is provided ``\s-1AS\s0 \s-1IS\s0'' and any express or implied warranties,
641 including, but not limited to, the implied warranties of merchantability
642 and fitness for a particular purpose are disclaimed.  See the \s-1LICENSE\s0
643 file distributed with \fBsudo\fR or http://www.sudo.ws/sudo/license.html
644 for complete details.