Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Sponsored in part by the Defense Advanced Research Projects
Agency (DARPA) and Air Force Research Laboratory, Air Force
Materiel Command, USAF, under agreement number F39502-99-1-0512.
$Sudo: sudo.pod,v 1.73 2004/09/08 18:34:38 millert Exp $
Automatically generated by Pod::Man v1.37, Pod::Parser v1.14
Standard preamble:
========================================================================
\\$1
.. ..
.... Set up some character translations and predefined strings. \*(-- will
give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
double quote, and \*(R" will give a right double quote. | will give a
real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` . ds C' 'br\} . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\}
If the F register is turned on, we'll generate index entries on stderr for
titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
entries marked with X<> in POD. Of course, you'll have to process the
output yourself in some meaningful fashion.
. de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\}
For nroff, turn off justification. Always turn off hyphenation; it makes
way too many mistakes in technical documents.
Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] .\} . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents . \" corrections for vroff . \" for low resolution devices (crt and lpr) \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} ========================================================================
Title "SUDO 8"
\fBsudo [-HPSb] [-a auth_type] [-c class|-] [-p prompt] [-u username|#uid] {-e file [...] | -i | -s | command}
\fBsudoedit [-S] [-a auth_type] [-p prompt] [-u username|#uid] file [...]
When invoked as sudoedit, the -e option (described below), is implied.
\fBsudo determines who is an authorized user by consulting the file \fI/etc/sudoers. By giving sudo the -v flag a user can update the time stamp without running a command. The password prompt itself will also time out if the user's password is not entered within \*(C`5\*(C' minutes (unless overridden via \fIsudoers).
If a user who is not listed in the sudoers file tries to run a command via sudo, mail is sent to the proper authorities, as defined at configure time or in the sudoers file (defaults to \f(CW\*(C`root\*(C'). Note that the mail will not be sent if an unauthorized user tries to run sudo with the -l or -v flags. This allows users to determine for themselves whether or not they are allowed to use sudo.
If sudo is run by root and the \*(C`SUDO_USER\*(C' environment variable is set, sudo will use this value to determine who the actual user is. This can be used by a user to log commands through sudo even when a root shell has been invoked. It also allows the -e flag to remain useful even when being run via a sudo-run script or program. Note however, that the sudoers lookup is still done for root, not the user specified by \*(C`SUDO_USER\*(C'.
\fBsudo can log both successful and unsuccessful attempts (as well as errors) to syslog\|(3), a log file, or both. By default sudo will log via syslog\|(3) but this is changeable at configure time or via the sudoers file.
.Sp If the specified file does not exist, it will be created. Note that unlike most commands run by sudo, the editor is run with the invoking user's environment unmodified. If, for some reason, \fBsudo is unable to update a file with its edited version, the user will receive a warning and the edited copy will remain in a temporary file.
Item "%u" expanded to the invoking user's login name Item "%U" expanded to the login name of the user the command will be run as (defaults to root) Item "%h" expanded to the local hostname without the domain name Item "%H" expanded to the local hostname including the domain name (on if the machine's hostname is fully qualified or the fqdn sudoers option is set) Item "%%" two consecutive \*(C`%\*(C' characters are collapsed into a single \*(C`%\*(C' character
Otherwise, sudo quits with an exit value of 1 if there is a configuration/permission problem or if sudo cannot execute the given command. In the latter case the error string is printed to stderr. If sudo cannot stat\|(2) one or more entries in the user's \f(CW\*(C`PATH\*(C' an error is printed on stderr. (If the directory does not exist or if it is not really a directory, the entry is ignored and no error is printed.) This should not happen under normal circumstances. The most common reason for stat\|(2) to return \*(L"permission denied\*(R" is if you are running an automounter and one of the directories in your \*(C`PATH\*(C' is on a machine that is currently unreachable.
To prevent command spoofing, sudo checks \*(L".\*(R" and "" (both denoting current directory) last when searching for a command in the user's \s-1PATH\s0 (if one or both are in the \s-1PATH\s0). Note, however, that the actual \*(C`PATH\*(C' environment variable is not modified and is passed unchanged to the program that sudo executes.
For security reasons, if your \s-1OS\s0 supports shared libraries and does not disable user-defined library search paths for setuid programs (most do), you should either use a linker option that disables this behavior or link sudo statically.
\fBsudo will check the ownership of its timestamp directory (/var/run/sudo by default) and ignore the directory's contents if it is not owned by root and only writable by root. On systems that allow non-root users to give away files via chown\|(2), if the timestamp directory is located in a directory writable by anyone (e.g.: /tmp), it is possible for a user to create the timestamp directory before \fBsudo is run. However, because sudo checks the ownership and mode of the directory and its contents, the only damage that can be done is to \*(L"hide\*(R" files by putting them in the timestamp dir. This is unlikely to happen since once the timestamp dir is owned by root and inaccessible by any other user the user placing files there would be unable to get them back out. To get around this issue you can use a directory that is not world-writable for the timestamps (/var/adm/sudo for instance) or create /var/run/sudo with the appropriate owner (root) and permissions (0700) in the system startup files.
\fBsudo will not honor timestamps set far in the future. Timestamps with a date greater than current_time + 2 * \*(C`TIMEOUT\*(C' will be ignored and sudo will log and complain. This is done to keep a user from creating his/her own timestamp with a bogus date on systems that allow users to give away files.
Please note that sudo will only log the command it explicitly runs. If a user runs a command such as \*(C`sudo su\*(C' or \*(C`sudo sh\*(C', subsequent commands run from that shell will not be logged, nor will sudo's access control affect them. The same is true for commands that offer shell escapes (including most editors). Because of this, care must be taken when giving users access to commands via sudo to verify that the command does not inadvertently give the user an effective root shell.
.Vb 2 EDITOR Default editor to use in -e (sudoedit) mode if VISUAL is not set .Ve
.Vb 3 HOME In -s or -H mode (or if sudo was configured with the --enable-shell-sets-home option), set to homedir of the target user .Ve
.Vb 2 PATH Set to a sane value if sudo was configured with the --with-secure-path option .Ve
.Vb 1 SHELL Used to determine shell to run with -s option .Ve
.Vb 1 SUDO_PROMPT Used as the default password prompt .Ve
.Vb 1 SUDO_COMMAND Set to the command run by sudo .Ve
.Vb 1 SUDO_USER Set to the login of the user who invoked sudo .Ve
.Vb 1 SUDO_UID Set to the uid of the user who invoked sudo .Ve
.Vb 1 SUDO_GID Set to the gid of the user who invoked sudo .Ve
.Vb 1 SUDO_PS1 If set, PS1 will be set to its value .Ve
.Vb 2 USER Set to the target user (root unless the -u option is specified) .Ve
.Vb 1 VISUAL Default editor to use in -e (sudoedit) mode .Ve
To get a file listing of an unreadable directory:
.Vb 1 $ sudo ls /usr/local/protected .Ve
To list the home directory of user yazza on a machine where the file system holding ~yazza is not exported as root:
.Vb 1 $ sudo -u yazza ls ~yazza .Ve
To edit the index.html file as user www:
.Vb 1 $ sudo -u www vi ~www/htdocs/index.html .Ve
To shutdown a machine:
.Vb 1 $ sudo shutdown -r +15 "quick reboot" .Ve
To make a usage listing of the directories in the /home partition. Note that this runs the commands in a sub-shell to make the \*(C`cd\*(C' and file redirection work.
.Vb 1 $ sudo sh -c "cd /home ; du -s * | sort -rn > USAGE" .Ve
.Vb 2 Todd Miller Chris Jepeway .Ve
See the \s-1HISTORY\s0 file in the sudo distribution or visit http://www.sudo.ws/sudo/history.html for a short history of sudo.
It is not meaningful to run the \*(C`cd\*(C' command directly via sudo, e.g.
.Vb 1 $ sudo cd /usr/local/protected .Ve
since when whe command exits the parent process (your shell) will still be the same. Please see the \s-1EXAMPLES\s0 section for more information.
If users have sudo \*(C`ALL\*(C' there is nothing to prevent them from creating their own program that gives them a root shell regardless of any '!' elements in the user specification.
Running shell scripts via sudo can expose the same kernel bugs that make setuid shell scripts unsafe on some operating systems (if your \s-1OS\s0 has a /dev/fd/ directory, setuid shell scripts are generally safe).
Limited free support is available via the sudo-users mailing list, see http://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or search the archives.