]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Don't assume /run/systemd exists when creating unit-root
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 3 Dec 2020 23:08:21 +0000 (23:08 +0000)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 5 Dec 2020 11:11:58 +0000 (11:11 +0000)
When running tests in a mkosi container, /run/systemd might not
exist yet in the container which causes test-execute to fail.

Fixes #17842.

src/core/namespace.c

index 0d30f17b9a05e1800c2401d6d7d7eddbc3f72002..cdf427a6ea9393939b21167e66c9c990186100e6 100644 (file)
@@ -1541,6 +1541,11 @@ int setup_namespace(
         if (root_directory)
                 root = root_directory;
         else {
+                /* /run/systemd should have been created by PID 1 early on already, but in some cases, like
+                 * when running tests (test-execute), it might not have been created yet so let's make sure
+                 * we create it if it doesn't already exist. */
+                (void) mkdir_p_label("/run/systemd", 0755);
+
                 /* Always create the mount namespace in a temporary directory, instead of operating
                  * directly in the root. The temporary directory prevents any mounts from being
                  * potentially obscured my other mounts we already applied.