summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-04-08 16:08:35 +0200
committerLennart Poettering <lennart@poettering.net>2020-04-08 16:29:25 +0200
commitf3b7a79b973a28af4f7a592a8b2e199cc194218b (patch)
tree49875554cb2d489a89062e685b6d14e2ef14ccea /src
parentunits: pull in systemd-pstore.service from sysinit.target (diff)
downloadsystemd-f3b7a79b973a28af4f7a592a8b2e199cc194218b.tar.xz
systemd-f3b7a79b973a28af4f7a592a8b2e199cc194218b.zip
core: automatically add dependency on systemd-remount-fs.service if StateDirectory= is used
And similar for other settings that require a writable /var/. Rationale: if these options are used for early-boot services (such as systemd-pstore.service) we need /var/ writable. And if /var/ is on the root fs, then systemd-remount-fs.service is the service that ensures that /var/ is writable. This allows us to remove explicit deps in services such as systemd-pstore.service.
Diffstat (limited to 'src')
-rw-r--r--src/core/unit.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index 96e1a6c320..17baea3117 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1047,6 +1047,16 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
if (!MANAGER_IS_SYSTEM(u->manager))
return 0;
+ /* For the following three directory types we need write access, and /var/ is possibly on the root
+ * fs. Hence order after systemd-remount-fs.service, to ensure things are writable. */
+ if (!strv_isempty(c->directories[EXEC_DIRECTORY_STATE].paths) ||
+ !strv_isempty(c->directories[EXEC_DIRECTORY_CACHE].paths) ||
+ !strv_isempty(c->directories[EXEC_DIRECTORY_LOGS].paths)) {
+ r = unit_add_dependency_by_name(u, UNIT_AFTER, SPECIAL_REMOUNT_FS_SERVICE, true, UNIT_DEPENDENCY_FILE);
+ if (r < 0)
+ return r;
+ }
+
if (c->private_tmp) {
const char *p;