1997-01-09 14:43:05 +03:00
|
|
|
.\" Copyright (c) 1988, 1990, 1993, 1994
|
|
|
|
.\" The Regents of the University of California. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
.\"
|
|
|
|
.\" 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.
|
2003-08-07 15:13:06 +04:00
|
|
|
.\" 3. Neither the name of the University nor the names of its contributors
|
1993-03-21 12:45:37 +03: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.
|
|
|
|
.\"
|
1997-01-09 14:43:05 +03:00
|
|
|
.\" from: @(#)su.1 8.2 (Berkeley) 4/18/94
|
2009-05-18 13:37:44 +04:00
|
|
|
.\" $NetBSD: su.1,v 1.49 2009/05/18 09:37:44 wiz Exp $
|
1993-03-21 12:45:37 +03:00
|
|
|
.\"
|
2007-10-27 22:43:37 +04:00
|
|
|
.Dd October 27, 2007
|
1993-03-21 12:45:37 +03:00
|
|
|
.Dt SU 1
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm su
|
|
|
|
.Nd substitute user identity
|
|
|
|
.Sh SYNOPSIS
|
1997-07-02 09:42:11 +04:00
|
|
|
.Nm
|
2009-05-18 13:37:44 +04:00
|
|
|
.Op Fl dfKlm
|
2000-01-14 05:39:14 +03:00
|
|
|
.Op Fl c Ar login-class
|
2007-10-27 22:42:42 +04:00
|
|
|
.Oo
|
|
|
|
.Ar login Ns Op : Ns Ar group
|
|
|
|
.Op Ar "shell arguments"
|
|
|
|
.Oc
|
|
|
|
.Nm
|
2009-05-18 13:37:44 +04:00
|
|
|
.Op Fl dfKlm
|
2007-10-27 22:42:42 +04:00
|
|
|
.Op Fl c Ar login-class
|
|
|
|
.Oo
|
|
|
|
.Ns : Ns Ar group
|
|
|
|
.Op Ar "shell arguments"
|
|
|
|
.Oc
|
1993-03-21 12:45:37 +03:00
|
|
|
.Sh DESCRIPTION
|
1997-07-02 09:42:11 +04:00
|
|
|
.Nm
|
2005-12-15 08:26:36 +03:00
|
|
|
allows one user to become another user
|
|
|
|
.Ar login
|
|
|
|
without logging out and in as
|
2007-10-18 01:05:39 +04:00
|
|
|
the new user.
|
2007-10-27 22:42:42 +04:00
|
|
|
If a
|
|
|
|
.Ar group
|
|
|
|
is specified and
|
|
|
|
.Ar login
|
|
|
|
is a member of
|
|
|
|
.Ar group ,
|
|
|
|
then the group is changed to
|
|
|
|
.Ar group
|
|
|
|
rather than to
|
|
|
|
.Ar login Ns 's
|
|
|
|
primary group.
|
|
|
|
If
|
|
|
|
.Ar login
|
|
|
|
is omitted and
|
|
|
|
.Ar group
|
|
|
|
is provided (form two above), then
|
|
|
|
.Ar login
|
|
|
|
is assumed to be the current username.
|
2005-12-15 08:26:36 +03:00
|
|
|
.Pp
|
2007-10-18 01:05:39 +04:00
|
|
|
When executed by a user, the
|
|
|
|
.Ar login
|
2005-12-15 08:26:36 +03:00
|
|
|
user's password is requested.
|
|
|
|
When using Kerberos, the password for
|
1993-03-21 12:45:37 +03:00
|
|
|
.Ar login
|
|
|
|
(or for
|
|
|
|
.Dq Ar login Ns .root ,
|
2005-12-15 08:26:36 +03:00
|
|
|
if no login is provided) is requested, and
|
|
|
|
.Nm
|
|
|
|
switches to that user and group ID after obtaining a Kerberos ticket
|
|
|
|
granting ticket.
|
1994-09-05 04:27:10 +04:00
|
|
|
A shell is then executed, and any additional
|
|
|
|
.Ar "shell arguments"
|
2002-10-13 04:55:17 +04:00
|
|
|
after the login name are passed to the shell.
|
1997-07-02 09:42:11 +04:00
|
|
|
.Nm
|
1993-03-21 12:45:37 +03:00
|
|
|
will resort to the local password file to find the password for
|
|
|
|
.Ar login
|
|
|
|
if there is a Kerberos error.
|
|
|
|
If
|
1997-07-02 09:42:11 +04:00
|
|
|
.Nm
|
1993-03-21 12:45:37 +03:00
|
|
|
is executed by root, no password is requested and a shell
|
|
|
|
with the appropriate user ID is executed; no additional Kerberos tickets
|
|
|
|
are obtained.
|
|
|
|
.Pp
|
1997-03-08 17:13:54 +03:00
|
|
|
Alternatively, if the user enters the password "s/key", authentication
|
|
|
|
will use the S/Key one-time password system as described in
|
1994-05-24 10:52:17 +04:00
|
|
|
.Xr skey 1 .
|
|
|
|
S/Key is a Trademark of Bellcore.
|
|
|
|
.Pp
|
1993-03-21 12:45:37 +03:00
|
|
|
By default, the environment is unmodified with the exception of
|
2005-07-06 00:15:13 +04:00
|
|
|
.Ev LOGNAME ,
|
1993-03-21 12:45:37 +03:00
|
|
|
.Ev USER ,
|
|
|
|
.Ev HOME ,
|
2000-02-11 03:30:07 +03:00
|
|
|
.Ev SHELL ,
|
1993-03-21 12:45:37 +03:00
|
|
|
and
|
2000-02-11 03:30:07 +03:00
|
|
|
.Ev SU_FROM .
|
1993-03-21 12:45:37 +03:00
|
|
|
.Ev HOME
|
|
|
|
and
|
|
|
|
.Ev SHELL
|
|
|
|
are set to the target login's default values.
|
2005-07-06 00:15:13 +04:00
|
|
|
.Ev LOGNAME
|
|
|
|
and
|
1993-03-21 12:45:37 +03:00
|
|
|
.Ev USER
|
2005-07-06 00:15:13 +04:00
|
|
|
are set to the target login, unless the target login has a user ID of 0,
|
|
|
|
in which case they are unmodified.
|
2000-02-11 03:30:07 +03:00
|
|
|
.Ev SU_FROM
|
|
|
|
is set to the caller's login.
|
1993-03-21 12:45:37 +03:00
|
|
|
The invoked shell is the target login's.
|
2000-02-11 03:30:07 +03:00
|
|
|
With the exception of
|
|
|
|
.Ev SU_FROM
|
|
|
|
this is the traditional behavior of
|
2003-02-25 13:34:36 +03:00
|
|
|
.Nm .
|
1993-03-21 12:45:37 +03:00
|
|
|
.Pp
|
|
|
|
The options are as follows:
|
|
|
|
.Bl -tag -width Ds
|
2000-01-14 05:39:14 +03:00
|
|
|
.It Fl c
|
|
|
|
Specify a login class.
|
|
|
|
You may only override the default class if you're already root.
|
2002-10-05 18:07:04 +04:00
|
|
|
See
|
|
|
|
.Xr login.conf 5
|
|
|
|
for details.
|
2003-04-27 12:46:25 +04:00
|
|
|
.It Fl d
|
|
|
|
Same as
|
|
|
|
.Fl l ,
|
|
|
|
but does not change the current directory.
|
1993-03-21 12:45:37 +03:00
|
|
|
.It Fl f
|
|
|
|
If the invoked shell is
|
|
|
|
.Xr csh 1 ,
|
|
|
|
this option prevents it from reading the
|
|
|
|
.Dq Pa .cshrc
|
|
|
|
file.
|
2003-04-21 00:13:20 +04:00
|
|
|
If the invoked shell is
|
|
|
|
.Xr sh 1 ,
|
2003-04-27 15:09:29 +04:00
|
|
|
or
|
2003-04-21 00:13:20 +04:00
|
|
|
.Xr ksh 1 ,
|
|
|
|
this option unsets
|
|
|
|
.Ev ENV ,
|
|
|
|
thus preventing the shell from executing the startup file pointed to by
|
|
|
|
this variable.
|
2009-05-18 13:37:44 +04:00
|
|
|
.It Fl K
|
|
|
|
Do not attempt to use Kerberos to authenticate the user.
|
1993-03-21 12:45:37 +03:00
|
|
|
.It Fl l
|
|
|
|
Simulate a full login.
|
|
|
|
The environment is discarded except for
|
|
|
|
.Ev HOME ,
|
|
|
|
.Ev SHELL ,
|
|
|
|
.Ev PATH ,
|
|
|
|
.Ev TERM ,
|
2005-07-06 00:15:13 +04:00
|
|
|
.Ev LOGNAME ,
|
2000-02-11 03:30:07 +03:00
|
|
|
.Ev USER ,
|
1993-03-21 12:45:37 +03:00
|
|
|
and
|
2000-02-11 03:30:07 +03:00
|
|
|
.Ev SU_FROM .
|
2003-09-17 09:34:15 +04:00
|
|
|
.Ev HOME ,
|
2000-02-11 03:30:07 +03:00
|
|
|
.Ev SHELL ,
|
1993-03-21 12:45:37 +03:00
|
|
|
and
|
2000-02-11 03:30:07 +03:00
|
|
|
.Ev SU_FROM
|
1993-03-21 12:45:37 +03:00
|
|
|
are modified as above.
|
2005-07-06 00:15:13 +04:00
|
|
|
.Ev LOGNAME
|
|
|
|
and
|
1993-03-21 12:45:37 +03:00
|
|
|
.Ev USER
|
2005-07-06 00:15:13 +04:00
|
|
|
are set to the target login.
|
1993-03-21 12:45:37 +03:00
|
|
|
.Ev PATH
|
2000-01-14 05:39:14 +03:00
|
|
|
is set to the path specified in the
|
|
|
|
.Pa /etc/login.conf
|
|
|
|
file (or to the default of
|
2001-03-08 05:59:25 +03:00
|
|
|
.Dq Pa /usr/bin:/bin:/usr/pkg/bin:/usr/local/bin
|
2000-01-14 05:39:14 +03:00
|
|
|
).
|
1993-03-21 12:45:37 +03:00
|
|
|
.Ev TERM
|
|
|
|
is imported from your current environment.
|
|
|
|
The invoked shell is the target login's, and
|
1997-07-02 09:42:11 +04:00
|
|
|
.Nm
|
1993-03-21 12:45:37 +03:00
|
|
|
will change directory to the target login's home directory.
|
1999-09-27 23:41:33 +04:00
|
|
|
.It Fl
|
|
|
|
Same as
|
2003-02-21 14:17:50 +03:00
|
|
|
.Fl l .
|
1993-03-21 12:45:37 +03: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-07-02 09:42:11 +04:00
|
|
|
.Nm
|
1993-03-21 12:45:37 +03:00
|
|
|
will fail.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fl l
|
|
|
|
and
|
|
|
|
.Fl m
|
|
|
|
options are mutually exclusive; the last one specified
|
|
|
|
overrides any previous ones.
|
|
|
|
.Pp
|
1997-07-02 09:42:11 +04:00
|
|
|
Only users in group
|
|
|
|
.Dq wheel
|
|
|
|
(normally gid 0),
|
|
|
|
as listed in
|
|
|
|
.Pa /etc/group ,
|
1993-03-21 12:45:37 +03:00
|
|
|
can
|
1997-07-02 09:42:11 +04:00
|
|
|
.Nm
|
1993-03-21 12:45:37 +03:00
|
|
|
to
|
1997-02-01 02:12:17 +03:00
|
|
|
.Dq root ,
|
1997-07-02 09:42:11 +04:00
|
|
|
unless group wheel does not exist or has no members.
|
|
|
|
(If you do not want anybody to be able to
|
|
|
|
.Nm
|
1997-02-01 02:12:17 +03:00
|
|
|
to
|
|
|
|
.Dq root ,
|
|
|
|
make
|
|
|
|
.Dq root
|
|
|
|
the only member of group
|
|
|
|
.Dq wheel ,
|
|
|
|
which is the default.)
|
1993-03-21 12:45:37 +03:00
|
|
|
.Pp
|
2001-01-11 00:33:13 +03:00
|
|
|
For sites with very large user populations, group
|
|
|
|
.Dq wheel
|
|
|
|
can contain the names of other groups that will be considered authorized
|
|
|
|
to
|
|
|
|
.Nm
|
|
|
|
to
|
|
|
|
.Dq root .
|
|
|
|
.Pp
|
1993-03-21 12:45:37 +03: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.
|
2005-04-05 22:46:33 +04:00
|
|
|
.Sh CUSTOMIZATION
|
|
|
|
.Bl -tag -width ""
|
|
|
|
.It Changing required group
|
|
|
|
For the
|
|
|
|
.Xr pam 8
|
|
|
|
version of
|
|
|
|
.Nm
|
|
|
|
the name of the required group can be changed by setting
|
|
|
|
.Ar gname
|
2005-06-19 21:26:30 +04:00
|
|
|
in
|
2005-04-05 22:46:33 +04:00
|
|
|
.Xr pam.conf 5 :
|
2005-06-19 21:34:03 +04:00
|
|
|
.Bd -literal
|
|
|
|
auth requisite pam_group.so no_warn group=gname root_only fail_safe
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2005-04-05 22:46:33 +04:00
|
|
|
For the non
|
|
|
|
.Xr pam 8
|
|
|
|
version of
|
|
|
|
.Nm
|
|
|
|
the same can be achieved by compiling with
|
|
|
|
.Dv SU_GROUP
|
|
|
|
set to the desired group name.
|
|
|
|
.It Supplying own password
|
|
|
|
.Nm
|
|
|
|
can be configured so that users in a particular group can supply their
|
|
|
|
own password to become
|
|
|
|
.Dq root .
|
|
|
|
For the
|
|
|
|
.Xr pam 8
|
|
|
|
version of
|
|
|
|
.Nm
|
2005-06-19 21:26:30 +04:00
|
|
|
this can be done by adding a line to
|
2005-04-05 22:46:33 +04:00
|
|
|
.Xr pam.conf 5
|
|
|
|
such as:
|
2005-06-19 21:34:03 +04:00
|
|
|
.Bd -literal
|
|
|
|
auth sufficient pam_group.so no_warn group=gname root_only authenticate
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2005-04-05 22:46:33 +04:00
|
|
|
where
|
|
|
|
.Ar gname
|
|
|
|
is the name of the desired group.
|
|
|
|
For the non
|
|
|
|
.Xr pam 8
|
|
|
|
version of
|
|
|
|
.Nm
|
|
|
|
the same can be achieved by compiling with
|
|
|
|
.Dv SU_ROOTAUTH
|
|
|
|
set to the desired group name.
|
|
|
|
.It Indirect groups
|
|
|
|
This option is not available with the
|
|
|
|
.Xr pam 8
|
|
|
|
version of
|
|
|
|
.Nm .
|
|
|
|
For the non
|
|
|
|
.Xr pam 8
|
|
|
|
version of
|
|
|
|
.Nm ,
|
2005-06-19 21:26:30 +04:00
|
|
|
if
|
2005-04-05 22:46:33 +04:00
|
|
|
.Dv SU_INDIRECT_GROUP
|
|
|
|
is defined, the
|
2003-08-20 18:11:17 +04:00
|
|
|
.Ar SU_GROUP
|
2003-08-24 02:31:24 +04:00
|
|
|
and
|
2003-08-20 18:11:17 +04:00
|
|
|
.Ar SU_ROOTAUTH
|
|
|
|
groups are treated as indirect groups.
|
2003-08-24 02:31:24 +04:00
|
|
|
The group members of those two groups are treated as groups themselves.
|
2005-02-28 05:30:54 +03:00
|
|
|
.El
|
2003-01-19 22:15:38 +03:00
|
|
|
.Sh EXIT STATUS
|
|
|
|
.Nm
|
|
|
|
returns the exit status of the executed subshell, or 1 if any error
|
|
|
|
occurred while switching privileges.
|
2001-12-08 22:17:03 +03:00
|
|
|
.Sh ENVIRONMENT
|
|
|
|
Environment variables used by
|
2003-02-25 13:34:36 +03:00
|
|
|
.Nm :
|
2001-12-08 22:17:03 +03:00
|
|
|
.Bl -tag -width "HOME"
|
|
|
|
.It Ev HOME
|
|
|
|
Default home directory of real user ID unless modified as
|
|
|
|
specified above.
|
2005-07-06 00:15:13 +04:00
|
|
|
.It Ev LOGNAME
|
|
|
|
The user ID is always the effective ID (the target user ID) after an
|
|
|
|
.Nm
|
|
|
|
unless the user ID is 0 (root).
|
2001-12-08 22:17:03 +03:00
|
|
|
.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
|
|
|
|
.Nm
|
|
|
|
unless the user ID is 0 (root).
|
|
|
|
.El
|
2000-05-10 23:04:36 +04:00
|
|
|
.Sh EXAMPLES
|
2001-03-08 05:59:25 +03:00
|
|
|
To become user username and use the same environment as in original shell, execute:
|
2000-05-10 23:04:36 +04:00
|
|
|
.Bd -literal -offset indent
|
|
|
|
su username
|
|
|
|
.Ed
|
2001-12-08 22:17:03 +03:00
|
|
|
.Pp
|
2000-05-10 23:04:36 +04:00
|
|
|
To become user username and use environment as if full login would be performed,
|
|
|
|
execute:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
su -l username
|
|
|
|
.Ed
|
2001-12-08 22:17:03 +03:00
|
|
|
.Pp
|
2002-10-05 18:07:04 +04:00
|
|
|
When a
|
|
|
|
.Fl c
|
|
|
|
option is included
|
|
|
|
.Em after
|
|
|
|
the
|
|
|
|
.Ar login
|
|
|
|
name it is not a
|
|
|
|
.Nm
|
|
|
|
option, because any arguments after the
|
|
|
|
.Ar login
|
2002-10-13 04:55:17 +04:00
|
|
|
are passed to the shell.
|
|
|
|
(See
|
2002-10-05 18:07:04 +04:00
|
|
|
.Xr csh 1 ,
|
|
|
|
.Xr ksh 1
|
|
|
|
or
|
|
|
|
.Xr sh 1
|
|
|
|
for details.)
|
2002-10-13 04:55:17 +04:00
|
|
|
To execute arbitrary command with privileges of user
|
2002-10-05 18:07:04 +04:00
|
|
|
.Em username ,
|
|
|
|
execute:
|
2000-05-10 23:04:36 +04:00
|
|
|
.Bd -literal -offset indent
|
|
|
|
su username -c "command args"
|
|
|
|
.Ed
|
1993-03-21 12:45:37 +03:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr csh 1 ,
|
2001-04-04 13:44:35 +04:00
|
|
|
.Xr kinit 1 ,
|
1993-03-21 12:45:37 +03:00
|
|
|
.Xr login 1 ,
|
|
|
|
.Xr sh 1 ,
|
1994-05-24 10:52:17 +04:00
|
|
|
.Xr skey 1 ,
|
2000-01-14 05:39:14 +03:00
|
|
|
.Xr setusercontext 3 ,
|
2001-12-08 22:17:03 +03:00
|
|
|
.Xr group 5 ,
|
2000-01-14 05:39:14 +03:00
|
|
|
.Xr login.conf 5 ,
|
1993-03-21 12:45:37 +03:00
|
|
|
.Xr passwd 5 ,
|
2001-04-04 13:44:35 +04:00
|
|
|
.Xr environ 7 ,
|
|
|
|
.Xr kerberos 8
|
1993-03-21 12:45:37 +03:00
|
|
|
.Sh HISTORY
|
|
|
|
A
|
|
|
|
.Nm
|
2001-03-08 05:59:25 +03:00
|
|
|
command existed in
|
|
|
|
.At v5
|
|
|
|
(and probably earlier).
|