]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/core/service.c
service: add ability to pin fd store
authorLennart Poettering <lennart@poettering.net>
Wed, 29 Mar 2023 20:07:22 +0000 (22:07 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 13 Apr 2023 04:44:27 +0000 (06:44 +0200)
commitb9c1883a9cd9b5126fe648f3e198143dc19a222d
treef31bf560425d33c0d6933b20fe724e11942d6206
parentc25fac9a17b95271bb6f8d967d33c5a9aa9e4bc9
service: add ability to pin fd store

Oftentimes it is useful to allow the per-service fd store to survive
longer than for a restart. This is useful in various scenarios:

1. An fd to some security relevant object needs to be stashed somewhere,
   that should not be cleaned automatically, because the security
   enforcement would be dropped then.

2. A user namespace fd should be allocated on first invocation and be
   kept around until the user logs out (i.e. systemd --user ends), รก la
   #16328 (This does not implement what #16318 asks for, but should
   solve the use-case discussed there.)

3. There's interest in allow a concept of "userspace reboots" where the
   kernel stays running, and userspace is swapped out (i.e. all services
   exit, and the rootfs transitioned into a new version of it) while
   keeping some select resources pinned, very similar to how we
   implement a switch root. Thus it is useful to allow services to exit,
   while leaving their fds around till the very end.

This is exposed through a new FileDescriptorStorePreserve= setting that
is closely modelled after RuntimeDirectoryPreserve= (in fact it reused
the same internal type), since we want similar behaviour in the end, and
quite often they probably want to be used together.
13 files changed:
man/org.freedesktop.systemd1.xml
man/systemd.service.xml
src/basic/unit-def.c
src/basic/unit-def.h
src/core/dbus-execute.c
src/core/dbus-execute.h
src/core/dbus-service.c
src/core/load-fragment-gperf.gperf.in
src/core/load-fragment.c
src/core/load-fragment.h
src/core/service.c
src/core/service.h
src/shared/bus-unit-util.c