man-pages/man1/runuser.1.html
2021-03-31 01:06:50 +01:00

407 lines
8.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of RUNUSER</TITLE>
</HEAD><BODY>
<H1>RUNUSER</H1>
Section: User Commands (1)<BR>Updated: July 2014<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
runuser - run a command with substitute user and group ID
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>runuser</B> [options] <B>-u</B>
<I>user</I>
[[--] <I>command</I> [argument<I>...]]</I>
<P>
<B>runuser</B> [options] [<B>-</B>]
[<I>user</I> [<I>argument</I>...]]
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<B>runuser</B>
allows to run commands with a substitute user and group ID.
If the option <B>-u</B> is not given, it falls back to
<B>su</B>-compatible
semantics and a shell is executed.
The difference between the commands
<B>runuser</B>
and
<B>su</B>
is that
<B>runuser</B>
does not ask for a password (because it may be executed by the root user only) and
it uses a different PAM configuration.
The command
<B>runuser</B>
does not have to be installed with set-user-ID permissions.
<P>
If the PAM session is not required then recommended solution is to use
<B><A HREF="/cgi-bin/man/man2html?1+setpriv">setpriv</A></B>(1)
command.
<P>
When called without arguments,
<B>runuser</B>
defaults to running an interactive shell as
<I>root</I>.
<P>
For backward compatibility,
<B>runuser</B>
defaults to not change the current directory and to only set the
environment variables
<B>HOME</B>
and
<B>SHELL</B>
(plus
<B>USER</B>
and
<B>LOGNAME</B>
if the target
<I>user</I>
is not root).
This version of
<B>runuser</B>
uses PAM for session management.
<A NAME="lbAE">&nbsp;</A>
<H2>OPTIONS</H2>
<DL COMPACT>
<DT id="1"><B>-c</B>,<B> --command</B>=<B></B><I>command</I>
<DD>
Pass
<I>command</I>
to the shell with the
<B>-c</B>
option.
<DT id="2"><B>-f</B>,<B> --fast</B>
<DD>
Pass
<B>-f</B>
to the shell, which may or may not be useful depending on the
shell.
<DT id="3"><B>-g</B>,<B> --group</B>=<B></B><I>group</I>
<DD>
The primary group to be used. This option is allowed for the root user only.
<DT id="4"><B>-G</B>,<B> --supp-group</B>=<B></B><I>group</I>
<DD>
Specify a supplemental group. This option is available to the root user only. The first specified
supplementary group is also used as a primary group if the option <B>--group</B> is unspecified.
<DT id="5"><B>-</B>,<B> -l</B>,<B> --login</B>
<DD>
Start the shell as a login shell with an environment similar to a real
login:
<DL COMPACT><DT id="6"><DD>
<DL COMPACT>
<DT id="7">o<DD>
clears all the environment variables except for
<B>TERM</B>
and variables specified by <B>--whitelist-environment</B>
<DT id="8">o<DD>
initializes the environment variables
<B>HOME</B>,
<B>SHELL</B>,
<B>USER</B>,
<B>LOGNAME</B>,
<B>PATH</B>
<DT id="9">o<DD>
changes to the target user's home directory
<DT id="10">o<DD>
sets argv[0] of the shell to
'<B>-</B>'
in order to make the shell a login shell
</DL>
</DL>
<DT id="11"><B>-P</B>,<B> --pty</B>
<DD>
Create pseudo-terminal for the session. The independent terminal provides
better security as user does not share terminal with the original
session. This allow to avoid TIOCSTI ioctl terminal injection and another
security attacks against terminal file descriptors. The all session is also
possible to move to background (e.g. &quot;runuser --pty -u username -- command &amp;&quot;).
If the pseudo-terminal is enabled then runuser command works
as a proxy between the sessions (copy stdin and stdout).
<P>
This feature is mostly designed for interactive sessions. If the standard input
is not a terminal, but for example pipe (e.g. echo &quot;date&quot; | runuser --pty -u user)
than ECHO flag for the pseudo-terminal is disabled to avoid messy output.
<DT id="12"><B>-m</B>,<B> -p</B>,<B> --preserve-environment</B>
<DD>
Preserve the entire environment, i.e. it does not set
<B>HOME</B>,
<B>SHELL</B>,
<B>USER</B>
nor
<B>LOGNAME</B>.
The option is ignored if the option <B>--login</B> is specified.
<DT id="13"><B>-s</B>,<B> --shell</B>=<B></B><I>shell</I>
<DD>
Run the specified <I>shell</I> instead of the default. The shell to run is
selected according to the following rules, in order:
<DL COMPACT><DT id="14"><DD>
<DL COMPACT>
<DT id="15">o<DD>
the shell specified with
<B>--shell</B>
<DT id="16">o<DD>
the shell specified in the environment variable
<B>SHELL</B>
if the
<B>--preserve-environment</B>
option is used
<DT id="17">o<DD>
the shell listed in the passwd entry of the target user
<DT id="18">o<DD>
/bin/sh
</DL>
</DL>
<DT id="19"><DD>
If the target user has a restricted shell (i.e. not listed in
/etc/shells) the
<B>--shell</B>
option and the
<B>SHELL</B>
environment variables are ignored unless the calling user is root.
<DT id="20"><B>--session-command=</B><I>command</I>
<DD>
Same as
<B>-c ,</B>
but do not create a new session. (Discouraged.)
<DT id="21"><B>-w</B>,<B> --whitelist-environment</B>=<B></B><I>list</I>
<DD>
Don't reset environment variables specified in comma separated <I>list</I> when clears
environment for <B>--login</B>. The whitelist is ignored for the environment variables
<B>HOME</B>,
<B>SHELL</B>,
<B>USER</B>,
<B>LOGNAME</B>, and
<B>PATH</B>.
<DT id="22"><B>-V</B>,<B> --version</B>
<DD>
Display version information and exit.
<DT id="23"><B>-h</B>,<B> --help</B>
<DD>
Display help text and exit.
</DL>
<A NAME="lbAF">&nbsp;</A>
<H2>CONFIG FILES</H2>
<B>runuser</B>
reads the
<I>/etc/default/runuser</I>
and
<I>/etc/login.defs</I>
configuration files. The following configuration items are relevant
for
<B>runuser</B>:
<P>
<B>ENV_PATH</B>
(string)
<DL COMPACT><DT id="24"><DD>
Defines the PATH environment variable for a regular user. The
default value is
<I>/usr/local/bin::/bin::/usr/bin</I>.
</DL>
<P>
<B>ENV_ROOTPATH</B>
(string)
<BR>
<B>ENV_SUPATH</B>
(string)
<DL COMPACT><DT id="25"><DD>
Defines the PATH environment variable for root. ENV_SUPATH takes precedence. The default value is
<I>/usr/local/sbin::/usr/local/bin::/sbin::/bin::/usr/sbin::/usr/bin</I>.
</DL>
<P>
<B>ALWAYS_SET_PATH</B>
(boolean)
<DL COMPACT><DT id="26"><DD>
If set to
<I>yes</I>
and --login and --preserve-environment were not specified
<B>runuser</B>
initializes
<B>PATH</B>.
</DL>
<P>
The environment variable PATH may be different on systems where /bin and /sbin
are merged into /usr.
<A NAME="lbAG">&nbsp;</A>
<H2>EXIT STATUS</H2>
<B>runuser</B>
normally returns the exit status of the command it executed. If the
command was killed by a signal,
<B>runuser</B>
returns the number of the signal plus 128.
<P>
Exit status generated by
<B>runuser</B>
itself:
<DL COMPACT><DT id="27"><DD>
<DL COMPACT>
<DT id="28">1<DD>
Generic error before executing the requested command
<DT id="29">126<DD>
The requested command could not be executed
<DT id="30">127<DD>
The requested command was not found
</DL>
</DL>
<A NAME="lbAH">&nbsp;</A>
<H2>FILES</H2>
<DL COMPACT>
<DT id="31">/etc/pam.d/runuser<DD>
default PAM configuration file
<DT id="32">/etc/pam.d/runuser-l<DD>
PAM configuration file if --login is specified
<DT id="33">/etc/default/runuser<DD>
runuser specific logindef config file
<DT id="34">/etc/login.defs<DD>
global logindef config file
</DL>
<A NAME="lbAI">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?1+setpriv">setpriv</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?1+su">su</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?5+login.defs">login.defs</A></B>(5),
<B><A HREF="/cgi-bin/man/man2html?5+shells">shells</A></B>(5),
<B><A HREF="/cgi-bin/man/man2html?8+pam">pam</A></B>(8)
<A NAME="lbAJ">&nbsp;</A>
<H2>HISTORY</H2>
This <B> runuser</B> command was
derived from coreutils' <B>su</B>, which was based on an implementation by
David MacKenzie, and the Fedora <B>runuser</B> command by Dan Walsh.
<A NAME="lbAK">&nbsp;</A>
<H2>AVAILABILITY</H2>
The runuser command is part of the util-linux package and is
available from
Linux Kernel Archive
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="35"><A HREF="#lbAB">NAME</A><DD>
<DT id="36"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="37"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="38"><A HREF="#lbAE">OPTIONS</A><DD>
<DT id="39"><A HREF="#lbAF">CONFIG FILES</A><DD>
<DT id="40"><A HREF="#lbAG">EXIT STATUS</A><DD>
<DT id="41"><A HREF="#lbAH">FILES</A><DD>
<DT id="42"><A HREF="#lbAI">SEE ALSO</A><DD>
<DT id="43"><A HREF="#lbAJ">HISTORY</A><DD>
<DT id="44"><A HREF="#lbAK">AVAILABILITY</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:26 GMT, March 31, 2021
</BODY>
</HTML>