table of contents
| RUN0(1) | run0 | RUN0(1) |
NAME¶
run0 - Elevate privileges
SYNOPSIS¶
run0 [OPTIONS...] [COMMAND...]
DESCRIPTION¶
run0 may be used to temporarily and interactively acquire elevated or different privileges. It serves a similar purpose as sudo(8), but operates differently in a couple of key areas:
Altogether this should provide a safer and more robust alternative to the sudo mechanism, in particular in OS environments where SetUID/SetGID support is not available (for example by setting the NoNewPrivileges= variable in systemd-system.conf(5)).
Any session invoked via run0 will run through the "systemd-run0" PAM stack.
Note that run0 is implemented as an alternative multi-call invocation of systemd-run(1). That is, run0 is a symbolic link to systemd-run executable file, and it behaves as run0 if it is invoked through the symbolic link, otherwise behaves as systemd-run.
Note that TTY isolation as provided by the default value of the --pty option is a core feature of run0. Redirecting terminals must therefore be done with care, avoiding giving such control to untrusted programs.
OPTIONS¶
The following options are understood:
--unit=
Added in version 256.
--property=
Added in version 256.
--description=
Added in version 256.
--slice=
Added in version 256.
--slice-inherit
Example: consider run0 being invoked in the slice foo.slice, and the --slice= argument is bar. The unit will then be placed under foo-bar.slice.
Added in version 256.
--user=, -u, --group=, -g
Added in version 256.
--nice=
Added in version 256.
--chdir=, -D
Added in version 256.
--via-shell
Added in version 258.
-i
Added in version 258.
--setenv=NAME[=VALUE]
Added in version 256.
--background=COLOR
Example: "--background=44" for a blue background.
Added in version 256.
--pty, --pty-late, --pipe
As mentioned above, TTY isolation as implemented by the default value of this option is crucial for security, so care must be taken when overriding it.
--pty and --pipe were added in v257.
--pty-late was added in v258.
--shell-prompt-prefix=STRING
Added in version 257.
--lightweight=BOOLEAN
This ultimately controls the $XDG_SESSION_CLASS environment variable pam_systemd(8) respects.
Added in version 258.
--area=AREA
If this option is used, the default user to transition to changes from root to the calling user's (but --user= takes precedence, see above). Or in other words, just specifying an area without a user is a mechanism to create a new session of the calling user, just with a different area.
This ultimately controls the $XDG_AREA environment variable pam_systemd(8) respects.
For details on the area concept see pam_systemd_home(8).
Added in version 258.
--empower
Note that other (unprivileged) processes of the selected user will have privileges over the invoked process. Consider not using this option in an environment where there might be malicious processes running as the selected user.
Added in version 259.
--same-root-dir
Added in version 259.
--machine=
Added in version 256.
--no-ask-password
-h, --help
--version
All command line arguments after the first non-option argument become part of the command line of the launched process. If no command line is specified an interactive shell is invoked. The shell to invoke may be controlled through --via-shell - when specified the target user's shell is used - or --setenv=SHELL=.... By default, the originating user's shell is executed if operating locally, or /bin/sh when operating with --machine=.
Note that unlike sudo, run0 always spawns shells with login shell semantics, regardless of -i.
EXIT STATUS¶
On success, 0 is returned. If run0 failed to start the session or the specified command fails, a non-zero return value will be returned.
ENVIRONMENT VARIABLES¶
As with systemd-run, the session will inherit the system environment from the service manager. In addition, the following environment variables will be set:
$TERM
Added in version 256.
$SUDO_USER
Added in version 256.
$SUDO_UID
Added in version 256.
$SUDO_GID
Added in version 256.
$SHELL_PROMPT_PREFIX
Added in version 257.
The following variables may be passed to run0:
$SYSTEMD_RUN_SHELL_PROMPT_PREFIX
Added in version 257.
SEE ALSO¶
systemd(1), systemd-run(1), sudo(8), machinectl(1), pam_systemd(8)
NOTES¶
- 1.
- polkit
- 2.
- ANSI Escape Code (Wikipedia)
| systemd 261.4 |