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