setpriv - run a program with different Linux privilege settings
setpriv [options] program [arguments]
Sets or queries various Linux privilege settings that are inherited across execve(2).
In comparison to su(1) and runuser(1), setpriv neither uses PAM, nor does it prompt for a password. It is a simple, non-set-user-ID wrapper around execve(2), and can be used to drop privileges in the same way as setuidgid(8) from daemontools, chpst(8) from runit, or similar tools shipped by other service managers.
--inh-caps (+|-)cap..., --ambient-caps (+|-)cap..., --bounding-set (+|-)cap...
The set of capabilities starts out as the current inheritable set for --inh-caps, the current ambient set for --ambient-caps and the current bounding set for --bounding-set.
Note the following restrictions (detailed in capabilities(7)) regarding modifications to these capability sets:
If you drop a capability from the bounding set without also dropping it from the inheritable set, you are likely to become confused. Do not do that.
The no_new_privs bit is supported since Linux 3.5.
--rgid gid, --egid gid, --regid gid
For safety, you must specify one of --clear-groups, --groups, --keep-groups, or --init-groups if you set any primary gid.
--ruid uid, --euid uid, --reuid uid
Setting a uid or gid does not change capabilities, although the exec call at the end might change capabilities. This means that, if you are root, you probably want to do something like:
setpriv --reuid=1000 --regid=1000 --inh-caps=-all
The environment variable PATH may be different on systems where /bin and /sbin are merged into /usr. The environment variable SHELL defaults to /bin/sh if none is given in the user’s passwd entry.
If applying any specified option fails, program will not be run and setpriv will return with exit status 127.
Be careful with this tool — it may have unexpected security consequences. For example, setting no_new_privs and then execing a program that is SELinux-confined (as this tool would do) may prevent the SELinux restrictions from taking effect.
setpriv --reuid=1000 --regid=1000 --init-groups
If you want to mimic daemontools' setuid(8), try:
setpriv --reuid=1000 --regid=1000 --clear-groups
Andy Lutomirski <firstname.lastname@example.org>
For bug reports, use the issue tracker at <https://github.com/karelzak/util-linux/issues>.
The setpriv command is part of the util-linux package which can be downloaded from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.