diff --git a/src/core/manager.c b/src/core/manager.c index ccc3e254fd..be44ab3778 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -1336,13 +1336,6 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) { if (r < 0) return r; - /* Make sure the transient directory always exists, so that it remains - * in the search path */ - r = mkdir_p_label(m->lookup_paths.transient, 0755); - if (r < 0) - return log_error_errno(r, "Failed to create transient generator directory \"%s\": %m", - m->lookup_paths.transient); - dual_timestamp_get(m->timestamps + MANAGER_TIMESTAMP_GENERATORS_START); r = manager_run_generators(m); dual_timestamp_get(m->timestamps + MANAGER_TIMESTAMP_GENERATORS_FINISH); diff --git a/src/core/unit.c b/src/core/unit.c index 4d0cd6e65d..a12d24b90b 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -4285,7 +4285,7 @@ int unit_write_setting(Unit *u, UnitWriteFlags flags, const char *name, const ch if (r < 0) return r; - (void) mkdir_p(p, 0755); + (void) mkdir_p_label(p, 0755); r = write_string_file_atomic_label(q, wrapped); if (r < 0) return r; @@ -4333,6 +4333,8 @@ int unit_make_transient(Unit *u) { if (!UNIT_VTABLE(u)->can_transient) return -EOPNOTSUPP; + (void) mkdir_p_label(u->manager->lookup_paths.transient, 0755); + path = strjoin(u->manager->lookup_paths.transient, "/", u->id); if (!path) return -ENOMEM; diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c index b40887bfbd..57e0757529 100644 --- a/src/shared/path-lookup.c +++ b/src/shared/path-lookup.c @@ -736,6 +736,14 @@ int lookup_paths_reduce(LookupPaths *p) { struct stat st; unsigned k; + /* Never strip the transient and control directories from the path */ + if (path_equal_ptr(p->search_path[c], p->transient) || + path_equal_ptr(p->search_path[c], p->persistent_control) || + path_equal_ptr(p->search_path[c], p->runtime_control)) { + c++; + continue; + } + if (p->root_dir) r = lstat(p->search_path[c], &st); else