xchpst(8) | System Manager's Manual | xchpst(8) |
xchpst
— eXtended
CHange Process STate
xchpst |
--help |
xchpst |
--version |
xchpst |
--exit [=retcode] |
xchpst |
[OPTIONS] [-- ]
command ... |
The xchpst
utility changes process state
according to the supplied options and then calls
exec
()
on a named executable with the positional arguments.
xchpst
is a backwards-compatible extension
to the chpst(8) tool which is supplied with runit.
xchpst
enables runit service scripts to take
advantage of hardening capabilities available with recent Linux kernels such
as namespaces and capabilities. xchpst
can set up
shadow subtrees within the filesystem hierarchy to isolate long-running
services from parts of the system to which they ought to need no access,
e.g. with private /tmp areas and read-only
/usr.
The extra options provided by xchpst
are
as follows:
--help
--exit
[=retcode]--mount-ns
--net-ns
--pid-ns
--fork-join
because a new process is needed to act as PID 1 and in order to be able to
mount a new procfs for the namespace.--fork-join
xchpst
process. This option is necessary to take advantage of PID namespaces. The
exit status is that of the child process.--user-ns
--adopt-net
path--new-root
--private-run
--private-tmp
--new-root
is also specified, the old
shared /run directory will still be accessible if the stacked mount is
removed.--protect-home
--new-root
is also specified, the old
shared host directories will still be accessible if the stacked mounts are
removed.--ro-sys
--caps-bs-keep
capability[,capability...]--caps-bs-drop
capability[,capability...]--caps-keep
capability[,capability...]--caps-drop
capability[,capability...]--no-new-privs
--scheduler
other | batch |
idle-s
bytes-a
bytes--memlock
bytes-@
xchpst
invocation into a command line for
chpst
if xchpst
is not
present on the system.The options compatible with classic chpst
are as follows:
-u
user[:group]...-U
user[:group]-u
but the environment variables
UID
and GID
are set
instead of changing the user. Supplementary groups are ignored.-b
argv0-e
dir-/
dir-C
dir-n
inc-l
fileexec
().-L
file-m
bytes-d
bytes-o
files-p
procs-f
bytes-c
bytes-t
seconds-v
-V
xchpst
version number.-P
-0
-1
-2
When invoked as chpst
,
envdir
, envuidgid
,
pgrphack
, setlock
,
setuidgid
, or softlimit
, the
xchpst
executable emulates the corresponding tools
from the “runit” or “daemontools” packages
respectively. As an additional feature, all these tools when so invoked,
accept the -v
option to increase verbosity.
--exit
is specified
is 0. This can be used for a quick test that
xchpst
is available on the system in shell
scripts.--exit
option takes an optional argument with
a return code to use.If there is no error and the intended application is
exec
()'d, the exit status will be that of the
application, not xchpst
.
Testing the emulation of ‘envdir’:
xchpst -b envdir --
xchpst
Launch with read-only filesystem if xchpst
is available, else use chpst
:
xchpst --exit && exec xchpst
--ro-sys -l /var/lock/ntpsec-ntpdate ntpd; exec chpst -l
/var/log/ntpsec-ntpdate ntpd
Drop a capability from the bounding set:
xchpst --cap-bs-drop CAP_SYS_ADMIN --
acmed
Drop user while retaining some capabilities:
xchpst -u :500:500 --caps-keep
CAP_DAC_OVERRIDE fakeroot /usr/sbin/gpm -D -m /dev/input/mice -t
exps2
xchpst
version 0.x has an unstable
interface for initial feature development.
xchpst
was written from scratch to be
backwards compatible with chpst
. The extent of the
planned extensions dwarfing the complexity of the original options led to
the decision to write a new tool rather than extending the existing one. The
new xchpst
tool is targeted at new versions of Linux
distributions so is written with a recent tooling and kernel baseline.
xchpst
has different design principles
from chpst
. Use xchpst
if
you need the additional options to harden runit-supervised tasks; use
chpst
if you do not need them, for a minimal
footprint.
Andrew Bower <andrew@bower.uk>
Please raise bug reports at: https://gitlab.com/abower/xchpst/-/issues
December 25, 2024 | Debian |