2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 09:57:41 +00:00
sudo/sudo.pod

226 lines
7.8 KiB
Plaintext
Raw Normal View History

1996-01-22 01:53:52 +00:00
=cut
$Id$
=pod
=head1 NAME
sudo - execute a command as the superuser
=head1 SYNOPSIS
1996-10-07 04:59:08 +00:00
B<sudo> B<-V> | B<-h> | B<-l> | B<-v> | B<-k> | B<-s> | B<-H> |
[ B<-b> ] | [ B<-p> prompt ] [ B<-u> username/#uid] I<command>
1996-01-22 01:53:52 +00:00
=head1 DESCRIPTION
B<sudo> allows a permitted user to execute a I<command>
as the superuser (real and effective uid and gid are set
1996-01-22 06:55:26 +00:00
to C<0> and root's group as set in the passwd file respectively).
1996-01-22 01:53:52 +00:00
B<sudo> determines who is an authorized user by consulting the
1996-01-22 06:55:26 +00:00
file I</etc/sudoers>. By giving B<sudo> the C<-v> flag a user
1996-01-22 01:53:52 +00:00
can update the time stamp without running a I<command.>
The password prompt itself will also time out if the password is
not entered with N minutes (again, this is defined at installation
time and defaults to 5 minutes).
1996-01-22 06:55:26 +00:00
If an unauthorized user executes B<sudo>, mail will be sent from the
1996-01-22 01:53:52 +00:00
user to the local authorities (defined at installation time).
B<sudo> was designed to log via the 4.3 BSD syslog(3) facility but
can log to a file instead if so desired (or to both syslog and a file).
All preferences are defined at installation time and are derived from
the options.h and pathnames.h include files as well as as well as the
Makefile.
=head1 OPTIONS
B<sudo> accepts the following command line options:
=over 4
=item -V
1996-01-22 06:55:26 +00:00
The C<-V> (I<version>) option causes B<sudo> to print the
1996-01-22 01:53:52 +00:00
version number and exit.
=item -l
1996-01-22 06:55:26 +00:00
The C<-l> (I<list>) option will list out the allowed and
1996-01-22 01:53:52 +00:00
forbidden commands for the user on the current host.
=item -h
1996-01-22 06:55:26 +00:00
The C<-h> (I<help>) option causes B<sudo> to print the version
of B<sudo> and a usage message before exiting.
1996-01-22 01:53:52 +00:00
=item -v
1996-01-22 06:55:26 +00:00
If given the C<-v> (I<validate>) option, B<sudo> will update the
1996-01-22 01:53:52 +00:00
user's timestamp file, prompting for a password if necessary.
This extends the B<sudo> timeout to for another N minutes
(where N is defined at installation time and defaults to 5
minutes) but does not run a command.
=item -k
1996-01-22 06:55:26 +00:00
The C<-k> (I<kill>) option to B<sudo> removes the user's timestamp
1996-01-22 01:53:52 +00:00
file, thus requiring a password the next time B<sudo> is run.
1996-06-19 17:53:14 +00:00
This option does not require a password and was added to
1996-01-22 01:53:52 +00:00
allow a user to revoke B<sudo> permissions from a .logout file.
=item -b
1996-01-22 06:55:26 +00:00
The C<-b> (I<background>) option tells B<sudo> to run the given
command in the background. Note that if you use the C<-b>
1996-01-22 01:53:52 +00:00
option you cannot use shell job control to manipulate the command.
=item -p
1996-01-22 06:55:26 +00:00
The C<-p> (I<prompt>) option allows you to override the default
1996-08-30 04:24:21 +00:00
password prompt and use a custom one. If the password prompt
contains the C<%u> escape, C<%u> will be replaced by the user's
login name. Similarly, C<%h> will be replaced by the local
hostname.
1996-01-22 01:53:52 +00:00
1996-06-15 21:58:33 +00:00
=item -u
The C<-u> (I<user>) option causes sudo to run the specified command
as a user other than I<root>. To specify a I<uid> instead of a
I<username>, use "#uid".
1996-01-22 01:53:52 +00:00
=item -s
1996-01-22 06:55:26 +00:00
The C<-s> (I<shell>) option runs the shell specified by the I<SHELL>
1996-01-22 01:53:52 +00:00
environmental variable if it is set or the shell as specified
in passwd(5).
1996-10-07 04:59:08 +00:00
=item -H
The C<-H> (I<HOME>) option sets the I<HOME> environmental variable
to the homedir of the target user (root by default) as specified
in passwd(5).
1996-01-22 01:53:52 +00:00
=item --
1996-01-22 06:55:26 +00:00
The C<--> flag indicates that B<sudo> should stop processing command
line arguments. It is most useful in conjunction with the C<-s> flag.
=back
1996-01-22 01:53:52 +00:00
=head1 RETURN VALUES
B<sudo> quits with an exit value of 1 if there is a
configuration/permission problem or if B<sudo> cannot execute
the given command. In the latter case the error string is
1996-08-15 19:46:45 +00:00
printed to stderr via perror(3). If B<sudo> cannot stat(2)
1996-01-22 01:53:52 +00:00
one or more entries in the user's PATH the error is printed
1996-08-15 19:46:45 +00:00
on stderr via perror(3). (If the directory does not exist
1996-01-22 01:53:52 +00:00
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(3) to return
"permission denied" is if you are running an automounter and
one of the directories in your PATH is on a machine that is
currently unreachable.
=head1 SECURITY NOTES
B<sudo> tries to be safe when executing external commands.
1996-08-17 23:43:41 +00:00
Variables that control how dynamic loading and binding is
done can be used to subvert the program that B<sudo> runs.
To combat this the C<LD_*>, C<SHLIB_PATH> (HP-UX only),
1996-01-22 06:55:26 +00:00
C<LIBPATH> (AIX only), and C<_RLD_*> environmental variables are
removed from the environment passed on to all commands executed.
1996-08-17 23:43:41 +00:00
B<sudo> will also remove the C<IFS>, C<ENV>, C<BASH_ENV>
and C<KRB_CONF> variables as they too can pose a threat.
1996-01-22 01:53:52 +00:00
1996-01-22 06:55:26 +00:00
To prevent command spoofing, B<sudo> checks "." and "" (both
1996-01-22 01:53:52 +00:00
denoting current directory) last when searching for a command
in the user's PATH (if one or both are in the PATH).
Note, however, that the actual PATH environmental variable
is I<not> modified and is passed unchanged to the program that
B<sudo> executes.
For security reasons, if your OS supports shared libraries,
B<sudo> should always be statically linked unless the
dynamic loader disables user-defined library search paths
1996-03-11 01:58:02 +00:00
for setuid programs. (Most modern dynamic loaders do this.)
1996-01-22 01:53:52 +00:00
B<sudo> will check the ownership of its timestamp directory
1996-03-11 02:01:17 +00:00
(F</var/run/sudo> or F</tmp/.odus> by default) and ignore
1996-03-11 01:58:02 +00:00
the directory's contents if it is not owned by root and
only read, writable, and executable by root. On systems
that allow users to give files away to root (via chown),
if the timestamp directory is located in a directory writable
by anyone (ie: F</tmp>), it is possible for a user to create
the timestamp directory before B<sudo> is run.
1996-01-22 06:55:26 +00:00
However, because B<sudo> checks the ownership and mode of
1996-01-22 01:53:52 +00:00
the directory, the only damage that can be done is to "hide"
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
1996-03-11 01:58:02 +00:00
for the timestamps (F</var/adm/sudo> for instance).
1996-01-22 01:53:52 +00:00
1996-08-17 23:43:41 +00:00
C<sudo> will not honor timestamp files set far in the
future. Timestamp files with a date greater than
current_time + 2 * C<TIMEOUT> will be ignored and
sudo will log the anomaly. This is done to keep a user
from creating his/her own timestamp file with a bogus
date.
1996-01-22 01:53:52 +00:00
=head1 FILES
1996-02-05 21:10:04 +00:00
/etc/sudoers file of authorized users.
1996-01-22 01:53:52 +00:00
=head1 ENVIRONMENT VARIABLES
1996-02-05 21:10:04 +00:00
PATH Set to a sane value if SECURE_PATH is set
SHELL Used to determine shell to run with -s option
1996-08-18 00:02:28 +00:00
HOME In -s mode, set to homedir of root (or runas user)
1996-09-08 00:00:01 +00:00
if built with the SHELL_SETS_HOME option
SUDO_PROMPT Replaces the default password prompt
1996-02-05 21:10:04 +00:00
SUDO_COMMAND Set to the command run by sudo
SUDO_USER Set to the login of the user who invoked sudo
SUDO_UID Set to the uid of the user who invoked sudo
SUDO_GID Set to the gid of the user who invoked sudo
1996-10-07 04:59:08 +00:00
SUDO_PS1 If set, PS1 will be set to its value
1996-01-22 01:53:52 +00:00
=head1 AUTHORS
Many people have worked on B<sudo> over the years, this
version consists of code written primarily by:
Jeff Nieusma <nieusma@FirstLink.com>
David Hieb <davehieb@internetone.com>
1996-09-08 00:00:01 +00:00
Todd Miller <Todd.Miller@courtesan.com>
1996-01-22 01:53:52 +00:00
Chris Jepeway <jepeway@cs.utk.edu>
1996-01-22 06:55:26 +00:00
See the HISTORY file in the B<sudo> distribution for more details.
1996-01-22 01:53:52 +00:00
1996-09-08 00:00:01 +00:00
Please send all bugs, comments, and changes to sudo-bugs@courtesan.com.
1996-01-22 01:53:52 +00:00
=head1 DISCLAIMER
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
675 Mass Ave, Cambridge, MA 02139, USA.
=head1 CAVEATS
There is no easy way to prevent a user from gaining a root shell if
1996-06-15 21:58:33 +00:00
that user has access to commands allow shell escapes.
Running shell scripts via B<sudo> can expose the same kernel bugs
that make setuid shell scripts unsafe on some operating systems.
1996-01-22 01:53:52 +00:00
=head1 SEE ALSO
sudoers(5), visudo(8), su(1).