Annotation of src/usr.bin/sudo/sudo.pod, Revision 1.11
1.10 millert 1: Copyright (c) 1994-1996, 1998-2005, 2007-2008
1.6 millert 2: Todd C. Miller <Todd.Miller@courtesan.com>
1.1 millert 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:
1.11 ! millert 21: $Sudo: sudo.pod,v 1.120 2008/11/15 18:34:01 millert Exp $
1.1 millert 22: =pod
23:
24: =head1 NAME
25:
26: sudo, sudoedit - execute a command as another user
27:
28: =head1 SYNOPSIS
29:
1.10 millert 30: B<sudo> [B<-n>] B<-h> | B<-K> | B<-k> | B<-L> | B<-V> | B<-v>
1.1 millert 31:
1.10 millert 32: B<sudo> B<-l[l]> [B<-AnS>] S<[B<-g> I<groupname>|I<#gid>]> S<[B<-U> I<username>]>
33: S<[B<-u> I<username>|I<#uid>]> [I<command>]
34:
35: B<sudo> [B<-AbEHnPS>]
1.9 millert 36: S<[B<-a> I<auth_type>]>
1.10 millert 37: S<[B<-C> I<fd>]>
1.9 millert 38: S<[B<-c> I<class>|I<->]>
1.10 millert 39: S<[B<-g> I<groupname>|I<#gid>]> S<[B<-p> I<prompt>]>
1.9 millert 40: S<[B<-u> I<username>|I<#uid>]>
1.10 millert 41: S<[B<VAR>=I<value>]> S<[B<-i> | B<-s>]> [I<command>]
1.1 millert 42:
1.10 millert 43: B<sudoedit> [B<-AnS>]
1.9 millert 44: S<[B<-a> I<auth_type>]>
1.10 millert 45: S<[B<-C> I<fd>]>
1.9 millert 46: S<[B<-c> I<class>|I<->]>
1.10 millert 47: S<[B<-g> I<groupname>|I<#gid>]> S<[B<-p> I<prompt>]>
48: S<[B<-u> I<username>|I<#uid>]> file ...
1.1 millert 49:
50: =head1 DESCRIPTION
51:
52: B<sudo> allows a permitted user to execute a I<command> as the
53: superuser or another user, as specified in the I<sudoers> file.
54: The real and effective uid and gid are set to match those of the
55: target user as specified in the passwd file and the group vector
56: is initialized based on the group file (unless the B<-P> option was
57: specified). If the invoking user is root or if the target user is
58: the same as the invoking user, no password is required. Otherwise,
59: B<sudo> requires that users authenticate themselves with a password
60: by default (NOTE: in the default configuration this is the user's
61: password, not the root password). Once a user has been authenticated,
62: a timestamp is updated and the user may then use sudo without a
63: password for a short period of time (C<@timeout@> minutes unless
64: overridden in I<sudoers>).
65:
66: When invoked as B<sudoedit>, the B<-e> option (described below),
67: is implied.
68:
69: B<sudo> determines who is an authorized user by consulting the file
1.11 ! millert 70: F<@sysconfdir@/sudoers>. By running B<sudo> with the B<-v> option,
! 71: a user can update the time stamp without running a I<command>. The
! 72: password prompt itself will also time out if the user's password
! 73: is not entered within C<@password_timeout@> minutes (unless overridden
! 74: via I<sudoers>).
1.1 millert 75:
76: If a user who is not listed in the I<sudoers> file tries to run a
77: command via B<sudo>, mail is sent to the proper authorities, as
78: defined at configure time or in the I<sudoers> file (defaults to
79: C<@mailto@>). Note that the mail will not be sent if an unauthorized
1.11 ! millert 80: user tries to run sudo with the B<-l> or B<-v> option. This allows
1.1 millert 81: users to determine for themselves whether or not they are allowed
82: to use B<sudo>.
83:
84: If B<sudo> is run by root and the C<SUDO_USER> environment variable
85: is set, B<sudo> will use this value to determine who the actual
86: user is. This can be used by a user to log commands through sudo
87: even when a root shell has been invoked. It also allows the B<-e>
1.11 ! millert 88: option to remain useful even when being run via a sudo-run script or
1.1 millert 89: program. Note however, that the sudoers lookup is still done for
90: root, not the user specified by C<SUDO_USER>.
91:
92: B<sudo> can log both successful and unsuccessful attempts (as well
93: as errors) to syslog(3), a log file, or both. By default B<sudo>
94: will log via syslog(3) but this is changeable at configure time
95: or via the I<sudoers> file.
96:
97: =head1 OPTIONS
98:
99: B<sudo> accepts the following command line options:
100:
1.10 millert 101: =over 12
102:
103: =item -A
104:
105: Normally, if B<sudo> requires a password, it will read it from the
106: current terminal. If the B<-A> (I<askpass>) option is specified,
107: a helper program is executed to read the user's password and output
108: the password to the standard output. If the C<SUDO_ASKPASS>
109: environment variable is set, it specifies the path to the helper
110: program. Otherwise, the value specified by the I<askpass> option
111: in L<sudoers(5)> is used.
1.1 millert 112:
1.10 millert 113: =item -a I<type>
1.1 millert 114:
115: The B<-a> (I<authentication type>) option causes B<sudo> to use the
116: specified authentication type when validating the user, as allowed
1.6 millert 117: by F</etc/login.conf>. The system administrator may specify a list
1.1 millert 118: of sudo-specific authentication methods by adding an "auth-sudo"
1.6 millert 119: entry in F</etc/login.conf>. This option is only available on systems
1.1 millert 120: that support BSD authentication.
121:
122: =item -b
123:
124: The B<-b> (I<background>) option tells B<sudo> to run the given
125: command in the background. Note that if you use the B<-b>
126: option you cannot use shell job control to manipulate the process.
127:
1.10 millert 128: =item -C I<fd>
129:
130: Normally, B<sudo> will close all open file descriptors other than
131: standard input, standard output and standard error. The B<-C>
132: (I<close from>) option allows the user to specify a starting point
133: above the standard error (file descriptor three). Values less than
134: three are not permitted. This option is only available if the
135: administrator has enabled the I<closefrom_override> option in
136: L<sudoers(5)>.
137:
138: =item -c I<class>
1.1 millert 139:
140: The B<-c> (I<class>) option causes B<sudo> to run the specified command
141: with resources limited by the specified login class. The I<class>
1.10 millert 142: argument can be either a class name as defined in F</etc/login.conf>,
1.1 millert 143: or a single '-' character. Specifying a I<class> of C<-> indicates
144: that the command should be run restricted by the default login
145: capabilities for the user the command is run as. If the I<class>
146: argument specifies an existing user class, the command must be run
147: as root, or the B<sudo> command must be run from a shell that is already
148: root. This option is only available on systems with BSD login classes.
149:
150: =item -E
151:
1.6 millert 152: The B<-E> (I<preserve> I<environment>) option will override the
1.1 millert 153: I<env_reset> option in L<sudoers(5)>). It is only
154: available when either the matching command has the C<SETENV> tag
155: or the I<setenv> option is set in L<sudoers(5)>.
156:
157: =item -e
158:
159: The B<-e> (I<edit>) option indicates that, instead of running
160: a command, the user wishes to edit one or more files. In lieu
161: of a command, the string "sudoedit" is used when consulting
162: the I<sudoers> file. If the user is authorized by I<sudoers>
163: the following steps are taken:
164:
1.6 millert 165: =over 4
1.1 millert 166:
167: =item 1.
168:
169: Temporary copies are made of the files to be edited with the owner
170: set to the invoking user.
171:
172: =item 2.
173:
1.10 millert 174: The editor specified by the C<SUDO_EDITOR>, C<VISUAL> or C<EDITOR>
175: environment variables is run to edit the temporary files. If none
176: of C<SUDO_EDITOR>, C<VISUAL> or C<EDITOR> are set, the first program
177: listed in the I<editor> I<sudoers> variable is used.
1.1 millert 178:
179: =item 3.
180:
181: If they have been modified, the temporary files are copied back to
182: their original location and the temporary versions are removed.
183:
184: =back
185:
186: If the specified file does not exist, it will be created. Note
187: that unlike most commands run by B<sudo>, the editor is run with
188: the invoking user's environment unmodified. If, for some reason,
189: B<sudo> is unable to update a file with its edited version, the
190: user will receive a warning and the edited copy will remain in a
191: temporary file.
192:
1.10 millert 193: =item -g I<group>
194:
195: Normally, B<sudo> sets the primary group to the one specified by
196: the passwd database for the user the command is being run as (by
197: default, root). The B<-g> (I<group>) option causes B<sudo> to run
198: the specified command with the primary group set to I<group>. To
199: specify a I<gid> instead of a I<group name>, use I<#gid>. When
200: running commands as a I<gid>, many shells require that the '#' be
201: escaped with a backslash ('\'). If no B<-u> option is specified,
202: the command will be run as the invoking user (not root). In either
203: case, the primary group will be set to I<group>.
204:
1.1 millert 205: =item -H
206:
207: The B<-H> (I<HOME>) option sets the C<HOME> environment variable
208: to the homedir of the target user (root by default) as specified
209: in passwd(5). By default, B<sudo> does not modify C<HOME>
210: (see I<set_home> and I<always_set_home> in L<sudoers(5)>).
211:
212: =item -h
213:
214: The B<-h> (I<help>) option causes B<sudo> to print a usage message and exit.
215:
1.10 millert 216: =item -i [command]
1.1 millert 217:
218: The B<-i> (I<simulate initial login>) option runs the shell specified
1.10 millert 219: in the L<passwd(5)> entry of the target user as a login shell. This
220: means that login-specific resource files such as C<.profile> or
221: C<.login> will be read by the shell. If a command is specified,
222: it is passed to the shell for execution. Otherwise, an interactive
223: shell is executed. B<sudo> attempts to change to that user's home
224: directory before running the shell. It also initializes the
225: environment, leaving I<DISPLAY> and I<TERM> unchanged, setting
226: I<HOME>, I<SHELL>, I<USER>, I<LOGNAME>, and I<PATH>, as well as
227: the contents of F</etc/environment> on Linux and AIX systems.
228: All other environment variables are removed.
1.1 millert 229:
230: =item -K
231:
232: The B<-K> (sure I<kill>) option is like B<-k> except that it removes
233: the user's timestamp entirely. Like B<-k>, this option does not
234: require a password.
235:
236: =item -k
237:
238: The B<-k> (I<kill>) option to B<sudo> invalidates the user's timestamp
239: by setting the time on it to the Epoch. The next time B<sudo> is
240: run a password will be required. This option does not require a password
241: and was added to allow a user to revoke B<sudo> permissions from a .logout
242: file.
243:
244: =item -L
245:
246: The B<-L> (I<list> defaults) option will list out the parameters
247: that may be set in a I<Defaults> line along with a short description
248: for each. This option is useful in conjunction with L<grep(1)>.
249:
1.10 millert 250: =item -l[l] [I<command>]
1.1 millert 251:
1.10 millert 252: If no I<command> is specified, the B<-l> (I<list>) option will list
253: the allowed (and forbidden) commands for the invoking user (or the
254: user specified by the B<-U> option) on the current host. If a
255: I<command> is specified and is permitted by I<sudoers>, the
256: fully-qualified path to the command is displayed along with any
257: command line arguments. If I<command> is specified but not allowed,
1.11 ! millert 258: B<sudo> will exit with a status value of 1. If the B<-l> option is
1.10 millert 259: specified with an B<l> argument (i.e. B<-ll>), or if B<-l>
260: is specified multiple times, a longer list format is used.
261:
262: =item -n
263:
264: The B<-n> (I<non-interactive>) option prevents B<sudo> from prompting
265: the user for a password. If a password is required for the command
266: to run, B<sudo> will display an error messages and exit.
1.1 millert 267:
268: =item -P
269:
1.6 millert 270: The B<-P> (I<preserve> I<group vector>) option causes B<sudo> to
1.1 millert 271: preserve the invoking user's group vector unaltered. By default,
272: B<sudo> will initialize the group vector to the list of groups the
273: target user is in. The real and effective group IDs, however, are
274: still set to match the target user.
275:
1.10 millert 276: =item -p I<prompt>
1.1 millert 277:
278: The B<-p> (I<prompt>) option allows you to override the default
279: password prompt and use a custom one. The following percent (`C<%>')
280: escapes are supported:
281:
1.6 millert 282: =over 4
1.1 millert 283:
284: =item C<%H>
285:
286: expanded to the local hostname including the domain name
287: (on if the machine's hostname is fully qualified or the I<fqdn>
288: I<sudoers> option is set)
289:
290: =item C<%h>
291:
292: expanded to the local hostname without the domain name
1.8 millert 293:
294: =item C<%p>
295:
296: expanded to the user whose password is being asked for (respects the
297: I<rootpw>, I<targetpw> and I<runaspw> flags in I<sudoers>)
1.1 millert 298:
299: =item C<%U>
300:
301: expanded to the login name of the user the command will
302: be run as (defaults to root)
303:
304: =item C<%u>
305:
306: expanded to the invoking user's login name
307:
308: =item C<%%>
309:
310: two consecutive C<%> characters are collapsed into a single C<%> character
311:
312: =back
313:
1.10 millert 314: The prompt specified by the B<-p> option will override the system
315: password prompt on systems that support PAM unless the
316: I<passprompt_override> flag is disabled in I<sudoers>.
317:
1.1 millert 318: =item -S
319:
320: The B<-S> (I<stdin>) option causes B<sudo> to read the password from
321: the standard input instead of the terminal device.
322:
1.10 millert 323: =item -s [command]
1.1 millert 324:
325: The B<-s> (I<shell>) option runs the shell specified by the I<SHELL>
1.10 millert 326: environment variable if it is set or the shell as specified in
327: L<passwd(5)>. If a command is specified, it is passed to the shell
328: for execution. Otherwise, an interactive shell is executed.
329:
330: =item -U I<user>
331:
332: The B<-U> (I<other user>) option is used in conjunction with the B<-l>
333: option to specify the user whose privileges should be listed. Only
334: root or a user with B<sudo> C<ALL> on the current host may use this
335: option.
1.1 millert 336:
1.10 millert 337: =item -u I<user>
1.1 millert 338:
1.6 millert 339: The B<-u> (I<user>) option causes B<sudo> to run the specified
340: command as a user other than I<root>. To specify a I<uid> instead
1.10 millert 341: of a I<user name>, use I<#uid>. When running commands as a I<uid>,
1.6 millert 342: many shells require that the '#' be escaped with a backslash ('\').
343: Note that if the I<targetpw> Defaults option is set (see L<sudoers(5)>)
344: it is not possible to run commands with a uid not listed in the
345: password database.
1.1 millert 346:
347: =item -V
348:
349: The B<-V> (I<version>) option causes B<sudo> to print the version
350: number and exit. If the invoking user is already root the B<-V>
351: option will print out a list of the defaults B<sudo> was compiled
352: with as well as the machine's local network addresses.
353:
354: =item -v
355:
356: If given the B<-v> (I<validate>) option, B<sudo> will update the
357: user's timestamp, prompting for the user's password if necessary.
358: This extends the B<sudo> timeout for another C<@timeout@> minutes
359: (or whatever the timeout is set to in I<sudoers>) but does not run
360: a command.
361:
362: =item --
363:
1.11 ! millert 364: The B<--> option indicates that B<sudo> should stop processing command
! 365: line arguments. It is most useful in conjunction with the B<-s> option.
1.1 millert 366:
367: =back
368:
369: Environment variables to be set for the command may also be passed
370: on the command line in the form of B<VAR>=I<value>, e.g.
371: B<LD_LIBRARY_PATH>=I</usr/local/pkg/lib>. Variables passed on the
372: command line are subject to the same restrictions as normal environment
373: variables with one important exception. If the I<setenv> option
1.7 millert 374: is set in I<sudoers>, the command to be run has the C<SETENV> tag
375: set or the command matched is C<ALL>, the user may set variables
376: that would overwise be forbidden. See L<sudoers(5)> for more information.
1.1 millert 377:
378: =head1 RETURN VALUES
379:
1.11 ! millert 380: Upon successful execution of a program, the exit status from B<sudo>
! 381: will simply be the exit status of the program that was executed.
1.1 millert 382:
383: Otherwise, B<sudo> quits with an exit value of 1 if there is a
384: configuration/permission problem or if B<sudo> cannot execute the
385: given command. In the latter case the error string is printed to
386: stderr. If B<sudo> cannot L<stat(2)> one or more entries in the user's
387: C<PATH> an error is printed on stderr. (If the directory does not
388: exist or if it is not really a directory, the entry is ignored and
389: no error is printed.) This should not happen under normal
390: circumstances. The most common reason for L<stat(2)> to return
391: "permission denied" is if you are running an automounter and one
392: of the directories in your C<PATH> is on a machine that is currently
393: unreachable.
394:
395: =head1 SECURITY NOTES
396:
397: B<sudo> tries to be safe when executing external commands.
398:
399: There are two distinct ways to deal with environment variables.
400: By default, the I<env_reset> I<sudoers> option is enabled.
401: This causes commands to be executed with a minimal environment
402: containing C<TERM>, C<PATH>, C<HOME>, C<SHELL>, C<LOGNAME>, C<USER>
403: and C<USERNAME> in addition to variables from the invoking process
404: permitted by the I<env_check> and I<env_keep> I<sudoers> options.
405: There is effectively a whitelist for environment variables.
406:
407: If, however, the I<env_reset> option is disabled in I<sudoers>, any
408: variables not explicitly denied by the I<env_check> and I<env_delete>
409: options are inherited from the invoking process. In this case,
410: I<env_check> and I<env_delete> behave like a blacklist. Since it
411: is not possible to blacklist all potentially dangerous environment
412: variables, use of the default I<env_reset> behavior is encouraged.
413:
414: In all cases, environment variables with a value beginning with
415: C<()> are removed as they could be interpreted as B<bash> functions.
416: The list of environment variables that B<sudo> allows or denies is
417: contained in the output of C<sudo -V> when run as root.
418:
419: Note that the dynamic linker on most operating systems will remove
420: variables that can control dynamic linking from the environment of
421: setuid executables, including B<sudo>. Depending on the operating
422: system this may include C<_RLD*>, C<DYLD_*>, C<LD_*>, C<LDR_*>,
423: C<LIBPATH>, C<SHLIB_PATH>, and others. These type of variables are
424: removed from the environment before B<sudo> even begins execution
425: and, as such, it is not possible for B<sudo> to preserve them.
426:
427: To prevent command spoofing, B<sudo> checks "." and "" (both denoting
428: current directory) last when searching for a command in the user's
429: PATH (if one or both are in the PATH). Note, however, that the
430: actual C<PATH> environment variable is I<not> modified and is passed
431: unchanged to the program that B<sudo> executes.
432:
433: B<sudo> will check the ownership of its timestamp directory
434: (F<@timedir@> by default) and ignore the directory's contents if
435: it is not owned by root or if it is writable by a user other than
436: root. On systems that allow non-root users to give away files via
437: L<chown(2)>, if the timestamp directory is located in a directory
438: writable by anyone (e.g., F</tmp>), it is possible for a user to
439: create the timestamp directory before B<sudo> is run. However,
440: because B<sudo> checks the ownership and mode of the directory and
441: its contents, the only damage that can be done is to "hide" files
442: by putting them in the timestamp dir. This is unlikely to happen
443: since once the timestamp dir is owned by root and inaccessible by
444: any other user, the user placing files there would be unable to get
445: them back out. To get around this issue you can use a directory
446: that is not world-writable for the timestamps (F</var/adm/sudo> for
447: instance) or create F<@timedir@> with the appropriate owner (root)
448: and permissions (0700) in the system startup files.
449:
450: B<sudo> will not honor timestamps set far in the future.
451: Timestamps with a date greater than current_time + 2 * C<TIMEOUT>
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:
456: Please note that B<sudo> will normally only log the command it
457: explicitly runs. If a user runs a command such as C<sudo su> or
458: C<sudo sh>, subsequent commands run from that shell will I<not> be
459: logged, nor will B<sudo>'s access control affect them. The same
460: is true for commands that offer shell escapes (including most
461: editors). Because of this, care must be taken when giving users
462: access to commands via B<sudo> to verify that the command does not
463: inadvertently give the user an effective root shell. For more
464: information, please see the C<PREVENTING SHELL ESCAPES> section in
465: L<sudoers(5)>.
466:
467: =head1 ENVIRONMENT
468:
469: B<sudo> utilizes the following environment variables:
470:
1.6 millert 471: =over 16
472:
473: =item C<EDITOR>
474:
1.10 millert 475: Default editor to use in B<-e> (sudoedit) mode if neither C<SUDO_EDITOR>
476: nor C<VISUAL> is set
1.6 millert 477:
478: =item C<HOME>
479:
480: In B<-s> or B<-H> mode (or if sudo was configured with the
481: --enable-shell-sets-home option), set to homedir of the target user
482:
483: =item C<PATH>
484:
485: Set to a sane value if the I<secure_path> sudoers option is set.
486:
487: =item C<SHELL>
1.1 millert 488:
1.6 millert 489: Used to determine shell to run with C<-s> option
1.1 millert 490:
1.10 millert 491: =item C<SUDO_ASKPASS>
1.1 millert 492:
1.10 millert 493: Specifies the path to a helper program used to read the password
494: if no terminal is available or if the C<-A> option is specified.
1.1 millert 495:
1.6 millert 496: =item C<SUDO_COMMAND>
1.1 millert 497:
1.6 millert 498: Set to the command run by sudo
1.1 millert 499:
1.10 millert 500: =item C<SUDO_EDITOR>
1.1 millert 501:
1.10 millert 502: Default editor to use in B<-e> (sudoedit) mode
1.1 millert 503:
1.10 millert 504: =item C<SUDO_GID>
1.1 millert 505:
1.10 millert 506: Set to the group ID of the user who invoked sudo
1.1 millert 507:
1.10 millert 508: =item C<SUDO_PROMPT>
1.1 millert 509:
1.10 millert 510: Used as the default password prompt
1.6 millert 511:
512: =item C<SUDO_PS1>
513:
1.10 millert 514: If set, C<PS1> will be set to its value for the program being run
515:
516: =item C<SUDO_UID>
517:
518: Set to the user ID of the user who invoked sudo
519:
520: =item C<SUDO_USER>
521:
522: Set to the login of the user who invoked sudo
1.6 millert 523:
524: =item C<USER>
525:
526: Set to the target user (root unless the B<-u> option is specified)
527:
528: =item C<VISUAL>
529:
1.10 millert 530: Default editor to use in B<-e> (sudoedit) mode if C<SUDO_EDITOR>
531: is not set
1.6 millert 532:
533: =back
1.1 millert 534:
535: =head1 FILES
536:
1.9 millert 537: =over 24
538:
539: =item F<@sysconfdir@/sudoers>
540:
541: List of who can run what
1.5 millert 542:
1.9 millert 543: =item F<@timedir@>
1.4 millert 544:
1.9 millert 545: Directory containing timestamps
1.5 millert 546:
1.10 millert 547: =item F</etc/environment>
548:
549: Initial environment for B<-i> mode on Linux and AIX
550:
1.5 millert 551: =back
1.1 millert 552:
553: =head1 EXAMPLES
554:
555: Note: the following examples assume suitable L<sudoers(5)> entries.
556:
557: To get a file listing of an unreadable directory:
558:
559: $ sudo ls /usr/local/protected
560:
561: To list the home directory of user yazza on a machine where the
562: file system holding ~yazza is not exported as root:
563:
564: $ sudo -u yazza ls ~yazza
565:
566: To edit the F<index.html> file as user www:
567:
568: $ sudo -u www vi ~www/htdocs/index.html
569:
570: To shutdown a machine:
571:
572: $ sudo shutdown -r +15 "quick reboot"
573:
574: To make a usage listing of the directories in the /home
575: partition. Note that this runs the commands in a sub-shell
576: to make the C<cd> and file redirection work.
577:
578: $ sudo sh -c "cd /home ; du -s * | sort -rn > USAGE"
579:
580: =head1 SEE ALSO
581:
1.9 millert 582: L<grep(1)>, L<su(1)>, L<stat(2)>,
583: L<login_cap(3)>,
584: L<passwd(5)>, L<sudoers(5)>, L<visudo(8)>
1.1 millert 585:
586: =head1 AUTHORS
587:
588: Many people have worked on B<sudo> over the years; this
589: version consists of code written primarily by:
590:
591: Todd C. Miller
592:
593: See the HISTORY file in the B<sudo> distribution or visit
594: http://www.sudo.ws/sudo/history.html for a short history
595: of B<sudo>.
596:
597: =head1 CAVEATS
598:
599: There is no easy way to prevent a user from gaining a root shell
600: if that user is allowed to run arbitrary commands via B<sudo>.
601: Also, many programs (such as editors) allow the user to run commands
602: via shell escapes, thus avoiding B<sudo>'s checks. However, on
603: most systems it is possible to prevent shell escapes with B<sudo>'s
604: I<noexec> functionality. See the L<sudoers(5)> manual
605: for details.
606:
607: It is not meaningful to run the C<cd> command directly via sudo, e.g.,
608:
609: $ sudo cd /usr/local/protected
610:
611: since when the command exits the parent process (your shell) will
612: still be the same. Please see the EXAMPLES section for more information.
613:
614: If users have sudo C<ALL> there is nothing to prevent them from
615: creating their own program that gives them a root shell regardless
616: of any '!' elements in the user specification.
617:
618: Running shell scripts via B<sudo> can expose the same kernel bugs that
619: make setuid shell scripts unsafe on some operating systems (if your OS
620: has a /dev/fd/ directory, setuid shell scripts are generally safe).
621:
622: =head1 BUGS
623:
624: If you feel you have found a bug in B<sudo>, please submit a bug report
625: at http://www.sudo.ws/sudo/bugs/
626:
627: =head1 SUPPORT
628:
629: Limited free support is available via the sudo-users mailing list,
630: see http://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or
631: search the archives.
632:
633: =head1 DISCLAIMER
634:
635: B<sudo> is provided ``AS IS'' and any express or implied warranties,
636: including, but not limited to, the implied warranties of merchantability
637: and fitness for a particular purpose are disclaimed. See the LICENSE
638: file distributed with B<sudo> or http://www.sudo.ws/sudo/license.html
639: for complete details.