Imported Debian patch 1.6.8p9-2
[debian/sudo] / sudo.man.in
1 .\" Copyright (c) 1994-1996,1998-2003 Todd C. Miller <Todd.Miller@courtesan.com>
2 .\" 
3 .\" Permission to use, copy, modify, and distribute this software for any
4 .\" purpose with or without fee is hereby granted, provided that the above
5 .\" copyright notice and this permission notice appear in all copies.
6 .\" 
7 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 .\" 
16 .\" Sponsored in part by the Defense Advanced Research Projects
17 .\" Agency (DARPA) and Air Force Research Laboratory, Air Force
18 .\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
19 .\" 
20 .\" $Sudo: sudo.pod,v 1.73 2004/09/08 18:34:38 millert Exp $
21 .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14
22 .\"
23 .\" Standard preamble:
24 .\" ========================================================================
25 .de Sh \" Subsection heading
26 .br
27 .if t .Sp
28 .ne 5
29 .PP
30 \fB\\$1\fR
31 .PP
32 ..
33 .de Sp \" Vertical space (when we can't use .PP)
34 .if t .sp .5v
35 .if n .sp
36 ..
37 .de Vb \" Begin verbatim text
38 .ft CW
39 .nf
40 .ne \\$1
41 ..
42 .de Ve \" End verbatim text
43 .ft R
44 .fi
45 ..
46 .\" Set up some character translations and predefined strings.  \*(-- will
47 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
48 .\" double quote, and \*(R" will give a right double quote.  | will give a
49 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
50 .\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
51 .\" expand to `' in nroff, nothing in troff, for use with C<>.
52 .tr \(*W-|\(bv\*(Tr
53 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
54 .ie n \{\
55 .    ds -- \(*W-
56 .    ds PI pi
57 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
58 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
59 .    ds L" ""
60 .    ds R" ""
61 .    ds C` 
62 .    ds C' 
63 'br\}
64 .el\{\
65 .    ds -- \|\(em\|
66 .    ds PI \(*p
67 .    ds L" ``
68 .    ds R" ''
69 'br\}
70 .\"
71 .\" If the F register is turned on, we'll generate index entries on stderr for
72 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
73 .\" entries marked with X<> in POD.  Of course, you'll have to process the
74 .\" output yourself in some meaningful fashion.
75 .if \nF \{\
76 .    de IX
77 .    tm Index:\\$1\t\\n%\t"\\$2"
78 ..
79 .    nr % 0
80 .    rr F
81 .\}
82 .\"
83 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
84 .\" way too many mistakes in technical documents.
85 .hy 0
86 .if n .na
87 .\"
88 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
89 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
90 .    \" fudge factors for nroff and troff
91 .if n \{\
92 .    ds #H 0
93 .    ds #V .8m
94 .    ds #F .3m
95 .    ds #[ \f1
96 .    ds #] \fP
97 .\}
98 .if t \{\
99 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
100 .    ds #V .6m
101 .    ds #F 0
102 .    ds #[ \&
103 .    ds #] \&
104 .\}
105 .    \" simple accents for nroff and troff
106 .if n \{\
107 .    ds ' \&
108 .    ds ` \&
109 .    ds ^ \&
110 .    ds , \&
111 .    ds ~ ~
112 .    ds /
113 .\}
114 .if t \{\
115 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
116 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
117 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
118 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
119 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
120 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
121 .\}
122 .    \" troff and (daisy-wheel) nroff accents
123 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
124 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
125 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
126 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
127 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
128 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
129 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
130 .ds ae a\h'-(\w'a'u*4/10)'e
131 .ds Ae A\h'-(\w'A'u*4/10)'E
132 .    \" corrections for vroff
133 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
134 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
135 .    \" for low resolution devices (crt and lpr)
136 .if \n(.H>23 .if \n(.V>19 \
137 \{\
138 .    ds : e
139 .    ds 8 ss
140 .    ds o a
141 .    ds d- d\h'-1'\(ga
142 .    ds D- D\h'-1'\(hy
143 .    ds th \o'bp'
144 .    ds Th \o'LP'
145 .    ds ae ae
146 .    ds Ae AE
147 .\}
148 .rm #[ #] #H #V #F C
149 .\" ========================================================================
150 .\"
151 .IX Title "SUDO @mansectsu@"
152 .TH SUDO @mansectsu@ "June 20, 2005" "1.6.8p9" "MAINTENANCE COMMANDS"
153 .SH "NAME"
154 sudo, sudoedit \- execute a command as another user
155 .SH "SYNOPSIS"
156 .IX Header "SYNOPSIS"
157 \&\fBsudo\fR \fB\-K\fR | \fB\-L\fR | \fB\-V\fR | \fB\-h\fR | \fB\-k\fR | \fB\-l\fR | \fB\-v\fR
158 .PP
159 \&\fBsudo\fR [\fB\-HPSb\fR] [\fB\-a\fR\ \fIauth_type\fR] [\fB\-c\fR\ \fIclass\fR|\fI\-\fR]
160 [\fB\-p\fR\ \fIprompt\fR] [\fB\-u\fR\ \fIusername\fR|\fI#uid\fR]
161 {\fB\-e\fR\ file\ [...]\ |\ \fB\-i\fR\ |\ \fB\-s\fR\ |\ \fIcommand\fR}
162 .PP
163 \&\fBsudoedit\fR [\fB\-S\fR] [\fB\-a\fR\ \fIauth_type\fR]
164 [\fB\-p\fR\ \fIprompt\fR] [\fB\-u\fR\ \fIusername\fR|\fI#uid\fR]
165 file [...]
166 .SH "DESCRIPTION"
167 .IX Header "DESCRIPTION"
168 \&\fBsudo\fR allows a permitted user to execute a \fIcommand\fR as the
169 superuser or another user, as specified in the \fIsudoers\fR file.
170 The real and effective uid and gid are set to match those of the
171 target user as specified in the passwd file and the group vector
172 is initialized based on the group file (unless the \fB\-P\fR option was
173 specified).  If the invoking user is root or if the target user is
174 the same as the invoking user, no password is required.  Otherwise,
175 \&\fBsudo\fR requires that users authenticate themselves with a password
176 by default (\s-1NOTE:\s0 in the default configuration this is the user's
177 password, not the root password).  Once a user has been authenticated,
178 a timestamp is updated and the user may then use sudo without a
179 password for a short period of time (\f(CW\*(C`@timeout@\*(C'\fR minutes unless
180 overridden in \fIsudoers\fR).
181 .PP
182 When invoked as \fBsudoedit\fR, the \fB\-e\fR option (described below),
183 is implied.
184 .PP
185 \&\fBsudo\fR determines who is an authorized user by consulting the file
186 \&\fI@sysconfdir@/sudoers\fR.  By giving \fBsudo\fR the \fB\-v\fR flag a user
187 can update the time stamp without running a \fIcommand.\fR The password
188 prompt itself will not time out in Debian's version (unless overridden via
189 \&\fIsudoers\fR).
190 .PP
191 If a user who is not listed in the \fIsudoers\fR file tries to run a
192 command via \fBsudo\fR, mail is sent to the proper authorities, as
193 defined at configure time or in the \fIsudoers\fR file (defaults to
194 \&\f(CW\*(C`@mailto@\*(C'\fR).  Note that the mail will not be sent if an unauthorized
195 user tries to run sudo with the \fB\-l\fR or \fB\-v\fR flags.  This allows
196 users to determine for themselves whether or not they are allowed
197 to use \fBsudo\fR.
198 .PP
199 If \fBsudo\fR is run by root and the \f(CW\*(C`SUDO_USER\*(C'\fR environment variable
200 is set, \fBsudo\fR will use this value to determine who the actual
201 user is.  This can be used by a user to log commands through sudo
202 even when a root shell has been invoked.  It also allows the \fB\-e\fR
203 flag to remain useful even when being run via a sudo-run script or
204 program.  Note however, that the sudoers lookup is still done for
205 root, not the user specified by \f(CW\*(C`SUDO_USER\*(C'\fR.
206 .PP
207 \&\fBsudo\fR can log both successful and unsuccessful attempts (as well
208 as errors) to \fIsyslog\fR\|(3), a log file, or both.  By default \fBsudo\fR
209 will log via \fIsyslog\fR\|(3) but this is changeable at configure time
210 or via the \fIsudoers\fR file.
211 .SH "OPTIONS"
212 .IX Header "OPTIONS"
213 \&\fBsudo\fR accepts the following command line options:
214 .IP "\-H" 4
215 .IX Item "-H"
216 The \fB\-H\fR (\fI\s-1HOME\s0\fR) option sets the \f(CW\*(C`HOME\*(C'\fR environment variable
217 to the homedir of the target user (root by default) as specified
218 in passwd(@mansectform@).  By default, \fBsudo\fR does not modify \f(CW\*(C`HOME\*(C'\fR
219 (see \fIset_home\fR and \fIalways_set_home\fR in sudoers(@mansectform@)).
220 .IP "\-K" 4
221 .IX Item "-K"
222 The \fB\-K\fR (sure \fIkill\fR) option is like \fB\-k\fR except that it removes
223 the user's timestamp entirely.  Like \fB\-k\fR, this option does not
224 require a password.
225 .IP "\-L" 4
226 .IX Item "-L"
227 The \fB\-L\fR (\fIlist\fR defaults) option will list out the parameters
228 that may be set in a \fIDefaults\fR line along with a short description
229 for each.  This option is useful in conjunction with \fIgrep\fR\|(1).
230 .IP "\-P" 4
231 .IX Item "-P"
232 The \fB\-P\fR (\fIpreserve group vector\fR) option causes \fBsudo\fR to
233 preserve the invoking user's group vector unaltered.  By default,
234 \&\fBsudo\fR will initialize the group vector to the list of groups the
235 target user is in.  The real and effective group IDs, however, are
236 still set to match the target user.
237 .IP "\-S" 4
238 .IX Item "-S"
239 The \fB\-S\fR (\fIstdin\fR) option causes \fBsudo\fR to read the password from
240 the standard input instead of the terminal device.
241 .IP "\-V" 4
242 .IX Item "-V"
243 The \fB\-V\fR (\fIversion\fR) option causes \fBsudo\fR to print the version
244 number and exit.  If the invoking user is already root the \fB\-V\fR
245 option will print out a list of the defaults \fBsudo\fR was compiled
246 with as well as the machine's local network addresses.
247 .IP "\-a" 4
248 .IX Item "-a"
249 The \fB\-a\fR (\fIauthentication type\fR) option causes \fBsudo\fR to use the
250 specified authentication type when validating the user, as allowed
251 by /etc/login.conf.  The system administrator may specify a list
252 of sudo-specific authentication methods by adding an \*(L"auth\-sudo\*(R"
253 entry in /etc/login.conf.  This option is only available on systems
254 that support \s-1BSD\s0 authentication where \fBsudo\fR has been configured
255 with the \-\-with\-bsdauth option.
256 .IP "\-b" 4
257 .IX Item "-b"
258 The \fB\-b\fR (\fIbackground\fR) option tells \fBsudo\fR to run the given
259 command in the background.  Note that if you use the \fB\-b\fR
260 option you cannot use shell job control to manipulate the process.
261 .IP "\-c" 4
262 .IX Item "-c"
263 The \fB\-c\fR (\fIclass\fR) option causes \fBsudo\fR to run the specified command
264 with resources limited by the specified login class.  The \fIclass\fR
265 argument can be either a class name as defined in /etc/login.conf,
266 or a single '\-' character.  Specifying a \fIclass\fR of \f(CW\*(C`\-\*(C'\fR indicates
267 that the command should be run restricted by the default login
268 capabilities for the user the command is run as.  If the \fIclass\fR
269 argument specifies an existing user class, the command must be run
270 as root, or the \fBsudo\fR command must be run from a shell that is already
271 root.  This option is only available on systems with \s-1BSD\s0 login classes
272 where \fBsudo\fR has been configured with the \-\-with\-logincap option.
273 .IP "\-e" 4
274 .IX Item "-e"
275 The \fB\-e\fR (\fIedit\fR) option indicates that, instead of running
276 a command, the user wishes to edit one or more files.  In lieu
277 of a command, the string \*(L"sudoedit\*(R" is used when consulting
278 the \fIsudoers\fR file.  If the user is authorized by \fIsudoers\fR
279 the following steps are taken:
280 .RS 4
281 .IP "1." 8
282 Temporary copies are made of the files to be edited with the owner
283 set to the invoking user.
284 .IP "2." 8
285 The editor specified by the \f(CW\*(C`VISUAL\*(C'\fR or \f(CW\*(C`EDITOR\*(C'\fR environment
286 variables is run to edit the temporary files.  If neither \f(CW\*(C`VISUAL\*(C'\fR
287 nor \f(CW\*(C`EDITOR\*(C'\fR are set, the program listed in the \fIeditor\fR \fIsudoers\fR
288 variable is used.
289 .IP "3." 8
290 If they have been modified, the temporary files are copied back to
291 their original location and the temporary versions are removed.
292 .RE
293 .RS 4
294 .Sp
295 If the specified file does not exist, it will be created.  Note
296 that unlike most commands run by \fBsudo\fR, the editor is run with
297 the invoking user's environment unmodified.  If, for some reason,
298 \&\fBsudo\fR is unable to update a file with its edited version, the
299 user will receive a warning and the edited copy will remain in a
300 temporary file.
301 .RE
302 .IP "\-h" 4
303 .IX Item "-h"
304 The \fB\-h\fR (\fIhelp\fR) option causes \fBsudo\fR to print a usage message and exit.
305 .IP "\-i" 4
306 .IX Item "-i"
307 The \fB\-i\fR (\fIsimulate initial login\fR) option runs the shell specified
308 in the passwd(@mansectform@) entry of the user that the command is
309 being run as.  The command name argument given to the shell begins
310 with a \f(CW\*(C`\-\*(C'\fR to tell the shell to run as a login shell.  \fBsudo\fR
311 attempts to change to that user's home directory before running the
312 shell.  It also initializes the environment, leaving \fI\s-1TERM\s0\fR
313 unchanged, setting \fI\s-1HOME\s0\fR, \fI\s-1SHELL\s0\fR, \fI\s-1USER\s0\fR, \fI\s-1LOGNAME\s0\fR, and
314 \&\fI\s-1PATH\s0\fR, and unsetting all other environment variables.  Note that
315 because the shell to use is determined before the \fIsudoers\fR file
316 is parsed, a \fIrunas_default\fR setting in \fIsudoers\fR will specify
317 the user to run the shell as but will not affect which shell is
318 actually run.
319 .IP "\-k" 4
320 .IX Item "-k"
321 The \fB\-k\fR (\fIkill\fR) option to \fBsudo\fR invalidates the user's timestamp
322 by setting the time on it to the epoch.  The next time \fBsudo\fR is
323 run a password will be required.  This option does not require a password
324 and was added to allow a user to revoke \fBsudo\fR permissions from a .logout
325 file.
326 .IP "\-l" 4
327 .IX Item "-l"
328 The \fB\-l\fR (\fIlist\fR) option will list out the allowed (and
329 forbidden) commands for the user on the current host.
330 .IP "\-p" 4
331 .IX Item "-p"
332 The \fB\-p\fR (\fIprompt\fR) option allows you to override the default
333 password prompt and use a custom one.  The following percent (`\f(CW\*(C`%\*(C'\fR')
334 escapes are supported:
335 .RS 4
336 .ie n .IP "%u" 8
337 .el .IP "\f(CW%u\fR" 8
338 .IX Item "%u"
339 expanded to the invoking user's login name
340 .ie n .IP "%U" 8
341 .el .IP "\f(CW%U\fR" 8
342 .IX Item "%U"
343 expanded to the login name of the user the command will
344 be run as (defaults to root)
345 .ie n .IP "%h" 8
346 .el .IP "\f(CW%h\fR" 8
347 .IX Item "%h"
348 expanded to the local hostname without the domain name
349 .ie n .IP "%H" 8
350 .el .IP "\f(CW%H\fR" 8
351 .IX Item "%H"
352 expanded to the local hostname including the domain name
353 (on if the machine's hostname is fully qualified or the \fIfqdn\fR
354 sudoers option is set)
355 .ie n .IP "\*(C`%%\*(C'" 8
356 .el .IP "\f(CW\*(C`%%\*(C'\fR" 8
357 .IX Item "%%"
358 two consecutive \f(CW\*(C`%\*(C'\fR characters are collapsed into a single \f(CW\*(C`%\*(C'\fR character
359 .RE
360 .RS 4
361 .RE
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 passwd(@mansectform@).
367 .IP "\-u" 4
368 .IX Item "-u"
369 The \fB\-u\fR (\fIuser\fR) option causes \fBsudo\fR to run the specified command
370 as a user other than \fIroot\fR.  To specify a \fIuid\fR instead of a
371 \&\fIusername\fR, use \fI#uid\fR.  Note that if the \fItargetpw\fR Defaults
372 option is set (see sudoers(@mansectform@)) it is not possible
373 to run commands with a uid not listed in the password database.
374 .IP "\-v" 4
375 .IX Item "-v"
376 If given the \fB\-v\fR (\fIvalidate\fR) option, \fBsudo\fR will update the
377 user's timestamp, prompting for the user's password if necessary.
378 This extends the \fBsudo\fR timeout for another \f(CW\*(C`@timeout@\*(C'\fR minutes
379 (or whatever the timeout is set to in \fIsudoers\fR) but does not run
380 a command.
381 .IP "\-\-" 4
382 The \fB\-\-\fR flag indicates that \fBsudo\fR should stop processing command
383 line arguments.  It is most useful in conjunction with the \fB\-s\fR flag.
384 .SH "RETURN VALUES"
385 .IX Header "RETURN VALUES"
386 Upon successful execution of a program, the return value from \fBsudo\fR
387 will simply be the return value of the program that was executed.
388 .PP
389 Otherwise, \fBsudo\fR quits with an exit value of 1 if there is a
390 configuration/permission problem or if \fBsudo\fR cannot execute the
391 given command.  In the latter case the error string is printed to
392 stderr.  If \fBsudo\fR cannot \fIstat\fR\|(2) one or more entries in the user's
393 \&\f(CW\*(C`PATH\*(C'\fR an error is printed on stderr.  (If the directory does not
394 exist or if it is not really a directory, the entry is ignored and
395 no error is printed.)  This should not happen under normal
396 circumstances.  The most common reason for \fIstat\fR\|(2) to return
397 \&\*(L"permission denied\*(R" is if you are running an automounter and one
398 of the directories in your \f(CW\*(C`PATH\*(C'\fR is on a machine that is currently
399 unreachable.
400 .SH "SECURITY NOTES"
401 .IX Header "SECURITY NOTES"
402 \&\fBsudo\fR tries to be safe when executing external commands.  Variables
403 that control how dynamic loading and binding is done can be used
404 to subvert the program that \fBsudo\fR runs.  To combat this the
405 \&\f(CW\*(C`LD_*\*(C'\fR, \f(CW\*(C`_RLD_*\*(C'\fR, \f(CW\*(C`SHLIB_PATH\*(C'\fR (\s-1HP\-UX\s0 only), and \f(CW\*(C`LIBPATH\*(C'\fR (\s-1AIX\s0
406 only) environment variables are removed from the environment passed
407 on to all commands executed.  \fBsudo\fR will also remove the \f(CW\*(C`IFS\*(C'\fR,
408 \&\f(CW\*(C`CDPATH\*(C'\fR, \f(CW\*(C`ENV\*(C'\fR, \f(CW\*(C`BASH_ENV\*(C'\fR, \f(CW\*(C`KRB_CONF\*(C'\fR, \f(CW\*(C`KRBCONFDIR\*(C'\fR, \f(CW\*(C`KRBTKFILE\*(C'\fR,
409 \&\f(CW\*(C`KRB5_CONFIG\*(C'\fR, \f(CW\*(C`LOCALDOMAIN\*(C'\fR, \f(CW\*(C`RES_OPTIONS\*(C'\fR, \f(CW\*(C`HOSTALIASES\*(C'\fR,
410 \&\f(CW\*(C`NLSPATH\*(C'\fR, \f(CW\*(C`PATH_LOCALE\*(C'\fR, \f(CW\*(C`TERMINFO\*(C'\fR, \f(CW\*(C`TERMINFO_DIRS\*(C'\fR and
411 \&\f(CW\*(C`TERMPATH\*(C'\fR variables as they too can pose a threat.  If the
412 \&\f(CW\*(C`TERMCAP\*(C'\fR variable is set and is a pathname, it too is ignored.
413 Additionally, if the \f(CW\*(C`LC_*\*(C'\fR or \f(CW\*(C`LANGUAGE\*(C'\fR variables contain the
414 \&\f(CW\*(C`/\*(C'\fR or \f(CW\*(C`%\*(C'\fR characters, they are ignored.  Environment variables
415 with a value beginning with \f(CW\*(C`()\*(C'\fR are also removed as they could
416 be interpreted as \fBbash\fR functions.  If \fBsudo\fR has been
417 compiled with SecurID support, the \f(CW\*(C`VAR_ACE\*(C'\fR, \f(CW\*(C`USR_ACE\*(C'\fR and
418 \&\f(CW\*(C`DLC_ACE\*(C'\fR variables are cleared as well.  The list of environment
419 variables that \fBsudo\fR clears is contained in the output of
420 \&\f(CW\*(C`sudo \-V\*(C'\fR when run as root.
421 .PP
422 To prevent command spoofing, \fBsudo\fR checks \*(L".\*(R" and "" (both denoting
423 current directory) last when searching for a command in the user's
424 \&\s-1PATH\s0 (if one or both are in the \s-1PATH\s0).  Note, however, that the
425 actual \f(CW\*(C`PATH\*(C'\fR environment variable is \fInot\fR modified and is passed
426 unchanged to the program that \fBsudo\fR executes.
427 .PP
428 For security reasons, if your \s-1OS\s0 supports shared libraries and does
429 not disable user-defined library search paths for setuid programs
430 (most do), you should either use a linker option that disables this
431 behavior or link \fBsudo\fR statically.
432 .PP
433 \&\fBsudo\fR will check the ownership of its timestamp directory
434 (\fI@timedir@\fR by default) and ignore the directory's contents if
435 it is not owned by root and only writable by root.  On systems that
436 allow non-root users to give away files via \fIchown\fR\|(2), if the timestamp
437 directory is located in a directory writable by anyone (e.g.: \fI/tmp\fR),
438 it is possible for a user to create the timestamp directory before
439 \&\fBsudo\fR is run.  However, because \fBsudo\fR checks the ownership and
440 mode of the directory and its contents, the only damage that can
441 be done is to \*(L"hide\*(R" files by putting them in the timestamp dir.
442 This is unlikely to happen since once the timestamp dir is owned
443 by root and inaccessible by any other user the user placing files
444 there would be unable to get them back out.  To get around this
445 issue you can use a directory that is not world-writable for the
446 timestamps (\fI/var/adm/sudo\fR for instance) or create \fI@timedir@\fR
447 with the appropriate owner (root) and permissions (0700) in the
448 system startup files.
449 .PP
450 \&\fBsudo\fR will not honor timestamps set far in the future.
451 Timestamps with a date greater than current_time + 2 * \f(CW\*(C`TIMEOUT\*(C'\fR
452 will be ignored and sudo will log and complain.  This is done to
453 keep a user from creating his/her own timestamp with a bogus
454 date on systems that allow users to give away files.
455 .PP
456 Please note that \fBsudo\fR will only log the command it explicitly
457 runs.  If a user runs a command such as \f(CW\*(C`sudo su\*(C'\fR or \f(CW\*(C`sudo sh\*(C'\fR,
458 subsequent commands run from that shell will \fInot\fR be logged, nor
459 will \fBsudo\fR's access control affect them.  The same is true for
460 commands that offer shell escapes (including most editors).  Because
461 of this, care must be taken when giving users access to commands
462 via \fBsudo\fR to verify that the command does not inadvertently give
463 the user an effective root shell.
464 .SH "ENVIRONMENT"
465 .IX Header "ENVIRONMENT"
466 \&\fBsudo\fR utilizes the following environment variables:
467 .PP
468 .Vb 2
469 \& EDITOR                 Default editor to use in -e (sudoedit) mode if
470 \&                        VISUAL is not set
471 .Ve
472 .PP
473 .Vb 3
474 \& HOME                   In -s or -H mode (or if sudo was configured with
475 \&                        the --enable-shell-sets-home option), set to
476 \&                        homedir of the target user
477 .Ve
478 .PP
479 .Vb 2
480 \& PATH                   Set to a sane value if sudo was configured with
481 \&                        the --with-secure-path option
482 .Ve
483 .PP
484 .Vb 1
485 \& SHELL                  Used to determine shell to run with -s option
486 .Ve
487 .PP
488 .Vb 1
489 \& SUDO_PROMPT            Used as the default password prompt
490 .Ve
491 .PP
492 .Vb 1
493 \& SUDO_COMMAND           Set to the command run by sudo
494 .Ve
495 .PP
496 .Vb 1
497 \& SUDO_USER              Set to the login of the user who invoked sudo
498 .Ve
499 .PP
500 .Vb 1
501 \& SUDO_UID               Set to the uid of the user who invoked sudo
502 .Ve
503 .PP
504 .Vb 1
505 \& SUDO_GID               Set to the gid of the user who invoked sudo
506 .Ve
507 .PP
508 .Vb 1
509 \& SUDO_PS1               If set, PS1 will be set to its value
510 .Ve
511 .PP
512 .Vb 2
513 \& USER                   Set to the target user (root unless the -u option
514 \&                        is specified)
515 .Ve
516 .PP
517 .Vb 1
518 \& VISUAL                 Default editor to use in -e (sudoedit) mode
519 .Ve
520 .SH "FILES"
521 .IX Header "FILES"
522 .Vb 2
523 \& @sysconfdir@/sudoers           List of who can run what
524 \& @timedir@              Directory containing timestamps
525 .Ve
526 .SH "EXAMPLES"
527 .IX Header "EXAMPLES"
528 Note: the following examples assume suitable sudoers(@mansectform@) entries.
529 .PP
530 To get a file listing of an unreadable directory:
531 .PP
532 .Vb 1
533 \& $ sudo ls /usr/local/protected
534 .Ve
535 .PP
536 To list the home directory of user yazza on a machine where the
537 file system holding ~yazza is not exported as root:
538 .PP
539 .Vb 1
540 \& $ sudo -u yazza ls ~yazza
541 .Ve
542 .PP
543 To edit the \fIindex.html\fR file as user www:
544 .PP
545 .Vb 1
546 \& $ sudo -u www vi ~www/htdocs/index.html
547 .Ve
548 .PP
549 To shutdown a machine:
550 .PP
551 .Vb 1
552 \& $ sudo shutdown -r +15 "quick reboot"
553 .Ve
554 .PP
555 To make a usage listing of the directories in the /home
556 partition.  Note that this runs the commands in a sub-shell
557 to make the \f(CW\*(C`cd\*(C'\fR and file redirection work.
558 .PP
559 .Vb 1
560 \& $ sudo sh -c "cd /home ; du -s * | sort -rn > USAGE"
561 .Ve
562 .SH "SEE ALSO"
563 .IX Header "SEE ALSO"
564 \&\fIgrep\fR\|(1), \fIsu\fR\|(1), \fIstat\fR\|(2), \fIlogin_cap\fR\|(3), sudoers(@mansectform@),
565 passwd(@mansectform@), visudo(@mansectsu@)
566 .SH "AUTHORS"
567 .IX Header "AUTHORS"
568 Many people have worked on \fBsudo\fR over the years; this
569 version consists of code written primarily by:
570 .PP
571 .Vb 2
572 \&        Todd Miller
573 \&        Chris Jepeway
574 .Ve
575 .PP
576 See the \s-1HISTORY\s0 file in the \fBsudo\fR distribution or visit
577 http://www.sudo.ws/sudo/history.html for a short history
578 of \fBsudo\fR.
579 .SH "CAVEATS"
580 .IX Header "CAVEATS"
581 There is no easy way to prevent a user from gaining a root shell
582 if that user is allowed to run arbitrary commands via \fBsudo\fR.
583 Also, many programs (such as editors) allow the user to run commands
584 via shell escapes, thus avoiding \fBsudo\fR's checks.  However, on
585 most systems it is possible to prevent shell escapes with \fBsudo\fR's
586 \&\fInoexec\fR functionality.  See the sudoers(@mansectform@) manual
587 for details.
588 .PP
589 It is not meaningful to run the \f(CW\*(C`cd\*(C'\fR command directly via sudo, e.g.
590 .PP
591 .Vb 1
592 \& $ sudo cd /usr/local/protected
593 .Ve
594 .PP
595 since when whe command exits the parent process (your shell) will
596 still be the same.  Please see the \s-1EXAMPLES\s0 section for more information.
597 .PP
598 If users have sudo \f(CW\*(C`ALL\*(C'\fR there is nothing to prevent them from
599 creating their own program that gives them a root shell regardless
600 of any '!' elements in the user specification.
601 .PP
602 Running shell scripts via \fBsudo\fR can expose the same kernel bugs that
603 make setuid shell scripts unsafe on some operating systems (if your \s-1OS\s0
604 has a /dev/fd/ directory, setuid shell scripts are generally safe).
605 .SH "BUGS"
606 .IX Header "BUGS"
607 If you feel you have found a bug in \fBsudo\fR, please submit a bug report
608 at http://www.sudo.ws/sudo/bugs/
609 .SH "SUPPORT"
610 .IX Header "SUPPORT"
611 Commercial support is available for \fBsudo\fR, see
612 http://www.sudo.ws/sudo/support.html for details.
613 .PP
614 Limited free support is available via the sudo-users mailing list,
615 see http://www.sudo.ws/mailman/listinfo/sudo\-users to subscribe or
616 search the archives.
617 .SH "DISCLAIMER"
618 .IX Header "DISCLAIMER"
619 \&\fBSudo\fR is provided ``\s-1AS\s0 \s-1IS\s0'' and any express or implied warranties,
620 including, but not limited to, the implied warranties of merchantability
621 and fitness for a particular purpose are disclaimed.  See the \s-1LICENSE\s0
622 file distributed with \fBsudo\fR or http://www.sudo.ws/sudo/license.html
623 for complete details.