summaryrefslogtreecommitdiff
path: root/src/systemctl
diff options
context:
space:
mode:
authorLuca Boccassi <luca.boccassi@microsoft.com>2021-07-14 18:22:21 +0100
committerLuca Boccassi <luca.boccassi@microsoft.com>2021-10-28 10:47:46 +0100
commit211a3d87fb1fe971dc42a47b4c5cc167def8ab4e (patch)
treef0e82b93e250abfab6b25a67af8a45bc9d4a2e45 /src/systemctl
parentdf61e79a5d9d6adfb8ea7f5f9dcb98fdda136910 (diff)
downloadsystemd-211a3d87fb1fe971dc42a47b4c5cc167def8ab4e.tar.gz
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.
Diffstat (limited to 'src/systemctl')
-rw-r--r--src/systemctl/systemctl-show.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c
index 7e4432d324..1c49158d83 100644
--- a/src/systemctl/systemctl-show.c
+++ b/src/systemctl/systemctl-show.c
@@ -1774,6 +1774,24 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m
return bus_log_parse_error(r);
return 1;
+ } else if (STR_IN_SET(name, "StateDirectorySymlink", "RuntimeDirectorySymlink", "CacheDirectorySymlink", "LogsDirectorySymlink")) {
+ const char *a, *p;
+ uint64_t symlink_flags;
+
+ r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "(sst)");
+ if (r < 0)
+ return bus_log_parse_error(r);
+
+ while ((r = sd_bus_message_read(m, "(sst)", &a, &p, &symlink_flags)) > 0)
+ bus_print_property_valuef(name, expected_value, flags, "%s:%s", a, p);
+ if (r < 0)
+ return bus_log_parse_error(r);
+
+ r = sd_bus_message_exit_container(m);
+ if (r < 0)
+ return bus_log_parse_error(r);
+
+ return 1;
}
break;