1994-05-27 12:33:43 +00:00
|
|
|
.\" Copyright (c) 1988, 1990, 1993, 1994
|
|
|
|
.\" The Regents of the University of California. All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
2017-02-28 23:42:47 +00:00
|
|
|
.\" 3. Neither the name of the University nor the names of its contributors
|
1994-05-27 12:33:43 +00:00
|
|
|
.\" may be used to endorse or promote products derived from this software
|
|
|
|
.\" without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" @(#)su.1 8.2 (Berkeley) 4/18/94
|
1999-08-28 01:08:13 +00:00
|
|
|
.\" $FreeBSD$
|
1994-05-27 12:33:43 +00:00
|
|
|
.\"
|
2020-03-26 17:58:52 +00:00
|
|
|
.Dd March 26, 2020
|
1994-05-27 12:33:43 +00:00
|
|
|
.Dt SU 1
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm su
|
|
|
|
.Nd substitute user identity
|
|
|
|
.Sh SYNOPSIS
|
1997-08-12 06:45:43 +00:00
|
|
|
.Nm
|
2000-08-05 23:03:12 +00:00
|
|
|
.Op Fl
|
2001-07-15 08:06:20 +00:00
|
|
|
.Op Fl c Ar class
|
2013-08-11 11:06:49 +00:00
|
|
|
.Op Fl flms
|
1995-09-06 12:38:53 +00:00
|
|
|
.Op Ar login Op Ar args
|
1994-05-27 12:33:43 +00:00
|
|
|
.Sh DESCRIPTION
|
2002-04-20 12:18:28 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility requests appropriate user credentials via PAM
|
2001-05-26 09:52:36 +00:00
|
|
|
and switches to that user ID
|
|
|
|
(the default user is the superuser).
|
1994-05-27 12:33:43 +00:00
|
|
|
A shell is then executed.
|
2001-05-26 09:52:36 +00:00
|
|
|
.Pp
|
2006-01-28 01:11:11 +00:00
|
|
|
PAM is used to set the policy
|
|
|
|
.Xr su 1
|
|
|
|
will use.
|
|
|
|
In particular, by default only users in the
|
|
|
|
.Dq Li wheel
|
|
|
|
group can switch to UID 0
|
|
|
|
.Pq Dq Li root .
|
2006-09-29 15:20:48 +00:00
|
|
|
This group requirement may be changed by modifying the
|
2006-01-28 01:11:11 +00:00
|
|
|
.Dq Li pam_group
|
2006-09-29 15:20:48 +00:00
|
|
|
section of
|
2006-01-28 01:11:11 +00:00
|
|
|
.Pa /etc/pam.d/su .
|
2006-09-29 15:20:48 +00:00
|
|
|
See
|
2006-01-28 01:11:11 +00:00
|
|
|
.Xr pam_group 8
|
|
|
|
for details on how to modify this setting.
|
1994-05-27 12:33:43 +00:00
|
|
|
.Pp
|
|
|
|
By default, the environment is unmodified with the exception of
|
|
|
|
.Ev USER ,
|
|
|
|
.Ev HOME ,
|
|
|
|
and
|
|
|
|
.Ev SHELL .
|
|
|
|
.Ev HOME
|
|
|
|
and
|
|
|
|
.Ev SHELL
|
|
|
|
are set to the target login's default values.
|
|
|
|
.Ev USER
|
|
|
|
is set to the target login, unless the target login has a user ID of 0,
|
|
|
|
in which case it is unmodified.
|
2001-04-28 13:40:52 +00:00
|
|
|
The invoked shell is the one belonging to the target login.
|
1994-05-27 12:33:43 +00:00
|
|
|
This is the traditional behavior of
|
2000-11-20 19:21:22 +00:00
|
|
|
.Nm .
|
1997-01-13 06:52:24 +00:00
|
|
|
Resource limits and session priority applicable to the original user's
|
2003-06-08 13:51:40 +00:00
|
|
|
login class (see
|
1997-01-13 06:52:24 +00:00
|
|
|
.Xr login.conf 5 )
|
2002-03-30 11:47:18 +00:00
|
|
|
are also normally retained unless the target login has a user ID of 0.
|
1994-05-27 12:33:43 +00:00
|
|
|
.Pp
|
|
|
|
The options are as follows:
|
|
|
|
.Bl -tag -width Ds
|
2013-08-11 11:06:49 +00:00
|
|
|
.It Fl c Ar class
|
|
|
|
Use the settings of the specified login class.
|
|
|
|
The login class must be defined in
|
|
|
|
.Xr login.conf 5 .
|
|
|
|
Only allowed for the super-user.
|
1994-05-27 12:33:43 +00:00
|
|
|
.It Fl f
|
|
|
|
If the invoked shell is
|
|
|
|
.Xr csh 1 ,
|
|
|
|
this option prevents it from reading the
|
|
|
|
.Dq Pa .cshrc
|
|
|
|
file.
|
|
|
|
.It Fl l
|
|
|
|
Simulate a full login.
|
|
|
|
The environment is discarded except for
|
|
|
|
.Ev HOME ,
|
|
|
|
.Ev SHELL ,
|
|
|
|
.Ev PATH ,
|
|
|
|
.Ev TERM ,
|
|
|
|
and
|
|
|
|
.Ev USER .
|
|
|
|
.Ev HOME
|
|
|
|
and
|
|
|
|
.Ev SHELL
|
|
|
|
are modified as above.
|
|
|
|
.Ev USER
|
|
|
|
is set to the target login.
|
|
|
|
.Ev PATH
|
|
|
|
is set to
|
|
|
|
.Dq Pa /bin:/usr/bin .
|
|
|
|
.Ev TERM
|
|
|
|
is imported from your current environment.
|
1997-08-30 12:22:49 +00:00
|
|
|
Environment variables may be set or overridden from the login class
|
1997-01-13 06:52:24 +00:00
|
|
|
capabilities database according to the class of the target login.
|
1994-05-27 12:33:43 +00:00
|
|
|
The invoked shell is the target login's, and
|
1997-08-12 06:45:43 +00:00
|
|
|
.Nm
|
1994-05-27 12:33:43 +00:00
|
|
|
will change directory to the target login's home directory.
|
1997-01-13 06:52:24 +00:00
|
|
|
Resource limits and session priority are modified to that for the
|
|
|
|
target account's login class.
|
2000-08-05 23:03:12 +00:00
|
|
|
.It Fl
|
|
|
|
(no letter) The same as
|
|
|
|
.Fl l .
|
1994-05-27 12:33:43 +00:00
|
|
|
.It Fl m
|
|
|
|
Leave the environment unmodified.
|
|
|
|
The invoked shell is your login shell, and no directory changes are made.
|
|
|
|
As a security precaution, if the target user's shell is a non-standard
|
|
|
|
shell (as defined by
|
|
|
|
.Xr getusershell 3 )
|
|
|
|
and the caller's real uid is
|
|
|
|
non-zero,
|
1997-08-12 06:45:43 +00:00
|
|
|
.Nm
|
1994-05-27 12:33:43 +00:00
|
|
|
will fail.
|
2002-10-23 03:19:34 +00:00
|
|
|
.It Fl s
|
|
|
|
Set the MAC label to the user's default label as part of the user
|
|
|
|
credential setup.
|
|
|
|
Setting the MAC label may fail if the MAC label of the invoking process
|
2002-11-26 17:33:37 +00:00
|
|
|
is not sufficient to transition to the user's default MAC label.
|
2002-10-23 03:19:34 +00:00
|
|
|
If the label cannot be set,
|
|
|
|
.Nm
|
|
|
|
will fail.
|
1994-05-27 12:33:43 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fl l
|
2000-08-05 23:03:12 +00:00
|
|
|
(or
|
2001-08-10 17:35:21 +00:00
|
|
|
.Fl )
|
1994-05-27 12:33:43 +00:00
|
|
|
and
|
|
|
|
.Fl m
|
|
|
|
options are mutually exclusive; the last one specified
|
|
|
|
overrides any previous ones.
|
|
|
|
.Pp
|
1995-09-06 12:38:53 +00:00
|
|
|
If the optional
|
|
|
|
.Ar args
|
|
|
|
are provided on the command line, they are passed to the login shell of
|
1998-06-08 05:29:51 +00:00
|
|
|
the target login.
|
2003-09-28 17:54:48 +00:00
|
|
|
Note that all command line arguments before the target login name are
|
|
|
|
processed by
|
|
|
|
.Nm
|
2004-05-19 09:53:41 +00:00
|
|
|
itself, everything after the target login name gets passed to the login
|
2003-09-28 17:54:48 +00:00
|
|
|
shell.
|
1995-09-06 12:38:53 +00:00
|
|
|
.Pp
|
1997-10-27 22:05:12 +00:00
|
|
|
By default (unless the prompt is reset by a startup file) the super-user
|
|
|
|
prompt is set to
|
|
|
|
.Dq Sy \&#
|
|
|
|
to remind one of its awesome power.
|
1994-05-27 12:33:43 +00:00
|
|
|
.Sh ENVIRONMENT
|
|
|
|
Environment variables used by
|
2000-11-20 19:21:22 +00:00
|
|
|
.Nm :
|
1994-05-27 12:33:43 +00:00
|
|
|
.Bl -tag -width HOME
|
|
|
|
.It Ev HOME
|
|
|
|
Default home directory of real user ID unless modified as
|
|
|
|
specified above.
|
|
|
|
.It Ev PATH
|
|
|
|
Default search path of real user ID unless modified as specified above.
|
|
|
|
.It Ev TERM
|
|
|
|
Provides terminal type which may be retained for the substituted
|
|
|
|
user ID.
|
|
|
|
.It Ev USER
|
|
|
|
The user ID is always the effective ID (the target user ID) after an
|
1997-08-12 06:45:43 +00:00
|
|
|
.Nm
|
1994-05-27 12:33:43 +00:00
|
|
|
unless the user ID is 0 (root).
|
|
|
|
.El
|
2005-01-18 13:43:56 +00:00
|
|
|
.Sh FILES
|
2020-03-26 17:58:52 +00:00
|
|
|
.Bl -tag -width "/etc/pam.d/su" -compact
|
2005-01-18 13:43:56 +00:00
|
|
|
.It Pa /etc/pam.d/su
|
|
|
|
PAM configuration for
|
|
|
|
.Nm .
|
|
|
|
.El
|
1995-09-06 12:38:53 +00:00
|
|
|
.Sh EXAMPLES
|
|
|
|
.Bl -tag -width 5n -compact
|
2017-09-13 16:35:16 +00:00
|
|
|
.It Li "su -m operator -c poweroff"
|
2011-06-06 15:17:55 +00:00
|
|
|
Starts a shell as user
|
2017-09-13 16:35:16 +00:00
|
|
|
.Li operator ,
|
2011-06-06 15:17:55 +00:00
|
|
|
and runs the command
|
2017-09-13 16:35:16 +00:00
|
|
|
.Li poweroff .
|
|
|
|
You will be asked for operator's password unless your real UID is 0.
|
2008-07-01 20:56:23 +00:00
|
|
|
Note that the
|
|
|
|
.Fl m
|
|
|
|
option is required since user
|
2017-09-13 16:35:16 +00:00
|
|
|
.Dq operator
|
2008-07-01 20:56:23 +00:00
|
|
|
does not have a valid shell by default.
|
2011-06-06 19:33:19 +00:00
|
|
|
In this example,
|
|
|
|
.Fl c
|
|
|
|
is passed to the shell of the user
|
2017-09-13 16:35:16 +00:00
|
|
|
.Dq operator ,
|
2011-06-06 19:33:19 +00:00
|
|
|
and is not interpreted as an argument to
|
|
|
|
.Nm .
|
2017-09-13 16:35:16 +00:00
|
|
|
.It Li "su -m operator -c 'shutdown -p now'"
|
2002-03-30 11:47:18 +00:00
|
|
|
Same as above, but the target command consists of more than a
|
2001-07-15 08:06:20 +00:00
|
|
|
single word and hence is quoted for use with the
|
1998-06-08 05:29:51 +00:00
|
|
|
.Fl c
|
2004-07-02 22:22:35 +00:00
|
|
|
option being passed to the shell.
|
|
|
|
(Most shells expect the argument to
|
1998-06-08 05:29:51 +00:00
|
|
|
.Fl c
|
|
|
|
to be a single word).
|
2017-09-13 16:35:16 +00:00
|
|
|
.It Li "su -m -c staff operator -c 'shutdown -p now'"
|
2001-07-15 08:06:20 +00:00
|
|
|
Same as above, but the target command is run with the resource limits of
|
|
|
|
the login class
|
1998-06-08 05:29:51 +00:00
|
|
|
.Dq staff .
|
2001-07-15 08:06:20 +00:00
|
|
|
Note: in this example, the first
|
1998-06-08 05:29:51 +00:00
|
|
|
.Fl c
|
|
|
|
option applies to
|
|
|
|
.Nm
|
|
|
|
while the second is an argument to the shell being invoked.
|
1995-09-06 12:38:53 +00:00
|
|
|
.It Li "su -l foo"
|
2000-08-05 23:03:12 +00:00
|
|
|
Simulate a login for user foo.
|
|
|
|
.It Li "su - foo"
|
|
|
|
Same as above.
|
2004-07-03 00:24:45 +00:00
|
|
|
.It Li "su -"
|
2000-08-05 23:03:12 +00:00
|
|
|
Simulate a login for root.
|
1995-09-06 12:38:53 +00:00
|
|
|
.El
|
2005-01-18 13:43:56 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr csh 1 ,
|
|
|
|
.Xr sh 1 ,
|
|
|
|
.Xr group 5 ,
|
|
|
|
.Xr login.conf 5 ,
|
|
|
|
.Xr passwd 5 ,
|
|
|
|
.Xr environ 7 ,
|
2006-01-28 01:11:11 +00:00
|
|
|
.Xr pam_group 8
|
1994-05-27 12:33:43 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
A
|
|
|
|
.Nm
|
|
|
|
command appeared in
|
1996-08-29 18:06:19 +00:00
|
|
|
.At v1 .
|