]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/core/execute.c
core: add [State|Runtime|Cache|Logs]Directory symlink as second parameter 20321/head
authorLuca Boccassi <luca.boccassi@microsoft.com>
Wed, 14 Jul 2021 17:22:21 +0000 (18:22 +0100)
committerLuca Boccassi <luca.boccassi@microsoft.com>
Thu, 28 Oct 2021 09:47:46 +0000 (10:47 +0100)
commit211a3d87fb1fe971dc42a47b4c5cc167def8ab4e
treef0e82b93e250abfab6b25a67af8a45bc9d4a2e45
parentdf61e79a5d9d6adfb8ea7f5f9dcb98fdda136910
core: add [State|Runtime|Cache|Logs]Directory symlink as second parameter

When combined with a tmpfs on /run or /var/lib, allows to create
arbitrary and ephemeral symlinks for StateDirectory or RuntimeDirectory.
This is especially useful when sharing these directories between
different services, to make the same state/runtime directory 'backend'
appear as different names to each service, so that they can be added/removed
to a sharing agreement transparently, without code changes.

An example (simplified, but real) use case:

foo.service:
StateDirectory=foo

bar.service:
StateDirectory=bar

foo.service.d/shared.conf:
StateDirectory=
StateDirectory=shared:foo

bar.service.d/shared.conf:
StateDirectory=
StateDirectory=shared:bar

foo and bar use respectively /var/lib/foo and /var/lib/bar. Then
the orchestration layer decides to stop this sharing, the drop-in
can be removed. The services won't need any update and will keep
working and being able to store state, transparently.

To keep backward compatibility, new DBUS messages are added.
man/org.freedesktop.systemd1.xml
man/systemd.exec.xml
src/core/dbus-execute.c
src/core/execute.c
src/core/execute.h
src/core/load-fragment-gperf.gperf.in
src/core/load-fragment.c
src/core/unit.c
src/shared/bus-unit-util.c
src/systemctl/systemctl-show.c
test/units/testsuite-34.sh