]> git.ipfire.org Git - thirdparty/util-linux.git/blame - login-utils/runuser.1
su: be sensitive to another SIGCHLD ssi_codes
[thirdparty/util-linux.git] / login-utils / runuser.1
CommitLineData
b45413a8 1.TH RUNUSER 1 "July 2014" "util-linux" "User Commands"
7ec6adb1
KZ
2.SH NAME
3runuser \- run a command with substitute user and group ID
4.SH SYNOPSIS
b45413a8
BS
5.BR runuser " [options] " \-u
6.I user
281873b8 7.RI "[[\-\-] " command " ["argument "...]]"
7a7f9d38 8.LP
b45413a8
BS
9.BR runuser " [options] [" \- ]
10.RI [ user " [" argument "...]]"
7ec6adb1
KZ
11.SH DESCRIPTION
12.B runuser
b45413a8
BS
13allows to run commands with a substitute user and group ID.
14If the option \fB\-u\fR is not given, it falls back to
15.BR su -compatible
16semantics and a shell is executed.
7ec6adb1
KZ
17The difference between the commands
18.B runuser
19and
20.B su
21is that
22.B runuser
96b65fb3 23does not ask for a password (because it may be executed by the root user only) and
4f2c0b2d 24it uses a different PAM configuration.
7ec6adb1
KZ
25The command
26.B runuser
aedd46f6 27does not have to be installed with set-user-ID permissions.
7ec6adb1 28.PP
c424fd83
KZ
29If the PAM session is not required then recommended solution is to use
30.BR setpriv (1)
31command.
32.PP
96b65fb3 33When called without arguments,
7ec6adb1
KZ
34.B runuser
35defaults to running an interactive shell as
36.IR root .
37.PP
b45413a8 38For backward compatibility,
7ec6adb1
KZ
39.B runuser
40defaults to not change the current directory and to only set the
41environment variables
42.B HOME
43and
44.B SHELL
45(plus
46.B USER
47and
48.B LOGNAME
49if the target
50.I user
7a7f9d38 51is not root).
7ec6adb1
KZ
52This version of
53.B runuser
54uses PAM for session management.
55.SH OPTIONS
56.TP
b45413a8 57.BR \-c , " \-\-command" = \fIcommand
7ec6adb1
KZ
58Pass
59.I command
60to the shell with the
61.B \-c
62option.
63.TP
b45413a8 64.BR \-f , " \-\-fast"
7ec6adb1
KZ
65Pass
66.B \-f
96b65fb3 67to the shell, which may or may not be useful depending on the
7ec6adb1
KZ
68shell.
69.TP
b45413a8
BS
70.BR \-g , " \-\-group" = \fIgroup
71The primary group to be used. This option is allowed for the root user only.
7ec6adb1 72.TP
b06c1ca6 73.BR \-G , " \-\-supp\-group" = \fIgroup
c619d3d1
KZ
74Specify a supplemental group. This option is available to the root user only. The first specified
75supplementary group is also used as a primary group if the option \fB\-\-group\fR is unspecified.
7ec6adb1 76.TP
b45413a8
BS
77.BR \- , " \-l" , " \-\-login"
78Start the shell as a login shell with an environment similar to a real
7ec6adb1
KZ
79login:
80.RS 10
81.TP
82o
96b65fb3 83clears all the environment variables except for
7ec6adb1 84.B TERM
75efef98 85and variables specified by \fB\-\-whitelist\-environment\fR
7ec6adb1
KZ
86.TP
87o
88initializes the environment variables
89.BR HOME ,
90.BR SHELL ,
91.BR USER ,
92.BR LOGNAME ,
93.B PATH
94.TP
95o
96changes to the target user's home directory
97.TP
98o
99sets argv[0] of the shell to
100.RB ' \- '
101in order to make the shell a login shell
102.RE
103.TP
0b07e268
KZ
104.BR \-P , " \-\-pty"
105Create pseudo-terminal for the session. The independent terminal provides
106better security as user does not share terminal with the original
107session. This allow to avoid TIOCSTI ioctl terminal injection and another
108security attacks against terminal file descriptors. The all session is also
109possible to move to background (e.g. "runuser --pty -u username -- command &").
110If the pseudo-terminal is enabled then runuser command works
111as a proxy between the sessions (copy stdin and stdout).
112.TP
b06c1ca6 113.BR \-m , " \-p" , " \-\-preserve\-environment"
b45413a8 114Preserve the entire environment, i.e. it does not set
7ec6adb1
KZ
115.BR HOME ,
116.BR SHELL ,
117.B USER
118nor
119.BR LOGNAME .
9ba27b26 120The option is ignored if the option \fB\-\-login\fR is specified.
7ec6adb1 121.TP
b45413a8
BS
122.BR \-s , " \-\-shell" = \fIshell
123Run the specified \fIshell\fR instead of the default. The shell to run is
124selected according to the following rules, in order:
7ec6adb1
KZ
125.RS 10
126.TP
127o
128the shell specified with
129.B \-\-shell
130.TP
131o
b45413a8 132the shell specified in the environment variable
7ec6adb1
KZ
133.B SHELL
134if the
b06c1ca6 135.B \-\-preserve\-environment
b45413a8 136option is used
7ec6adb1
KZ
137.TP
138o
139the shell listed in the passwd entry of the target user
140.TP
141o
142/bin/sh
143.RE
144.IP
145If the target user has a restricted shell (i.e. not listed in
146/etc/shells) the
147.B \-\-shell
148option and the
149.B SHELL
150environment variables are ignored unless the calling user is root.
151.TP
b45413a8
BS
152.BI \-\-session\-command= command
153Same as
154.B \-c ,
155but do not create a new session. (Discouraged.)
7ec6adb1 156.TP
75efef98
KZ
157.BR \-w , " \-\-whitelist\-environment" = \fIlist
158Don't reset environment variables specified in comma separated \fIlist\fR when clears
159environment for \fB\-\-login\fR. The whitelist is ignored for the environment variables
160.BR HOME ,
161.BR SHELL ,
162.BR USER ,
163.BR LOGNAME ", and"
164.BR PATH "."
165.TP
b45413a8 166.BR \-V , " \-\-version"
7ec6adb1 167Display version information and exit.
b45413a8
BS
168.TP
169.BR \-h , " \-\-help"
170Display help text and exit.
7ec6adb1
KZ
171.SH CONFIG FILES
172.B runuser
173reads the
174.I /etc/default/runuser
175and
176.I /etc/login.defs
177configuration files. The following configuration items are relevant
178for
179.BR runuser :
180.PP
181.B ENV_PATH
182(string)
183.RS 4
184Defines the PATH environment variable for a regular user. The
185default value is
186.IR /usr/local/bin:\:/bin:\:/usr/bin .
187.RE
188.PP
189.B ENV_ROOTPATH
190(string)
191.br
192.B ENV_SUPATH
193(string)
194.RS 4
86f42e5a 195Defines the PATH environment variable for root. ENV_SUPATH takes precedence. The default value is
7ec6adb1
KZ
196.IR /usr/local/sbin:\:/usr/local/bin:\:/sbin:\:/bin:\:/usr/sbin:\:/usr/bin .
197.RE
198.PP
199.B ALWAYS_SET_PATH
200(boolean)
201.RS 4
202If set to
203.I yes
204and \-\-login and \-\-preserve\-environment were not specified
205.B runuser
206initializes
207.BR PATH .
208.RE
64d11d6b
KZ
209.sp
210The environment variable PATH may be different on systems where /bin and /sbin
211are merged into /usr.
7ec6adb1
KZ
212.SH EXIT STATUS
213.B runuser
214normally returns the exit status of the command it executed. If the
215command was killed by a signal,
216.B runuser
217returns the number of the signal plus 128.
218.PP
219Exit status generated by
220.B runuser
221itself:
222.RS 10
223.TP
2241
225Generic error before executing the requested command
226.TP
227126
228The requested command could not be executed
229.TP
230127
96b65fb3 231The requested command was not found
7ec6adb1
KZ
232.RE
233.SH FILES
234.PD 0
235.TP 17
236/etc/pam.d/runuser
237default PAM configuration file
238.TP
239/etc/pam.d/runuser-l
240PAM configuration file if \-\-login is specified
241.TP
242/etc/default/runuser
243runuser specific logindef config file
244.TP
245/etc/login.defs
246global logindef config file
247.PD 1
248.SH "SEE ALSO"
f053ff1e 249.BR setpriv (1),
c424fd83 250.BR su (1),
f053ff1e
MK
251.BR login.defs (5),
252.BR shells (5),
253.BR pam (8)
b45413a8
BS
254.SH HISTORY
255This \fB runuser\fR command was
a55f60a1 256derived from coreutils' \fBsu\fR, which was based on an implementation by
b45413a8 257David MacKenzie, and the Fedora \fBrunuser\fR command by Dan Walsh.
7ec6adb1
KZ
258.SH AVAILABILITY
259The runuser command is part of the util-linux package and is
260available from
d673b74e 261.UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
7ec6adb1
KZ
262Linux Kernel Archive
263.UE .