]> 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)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 8 Dec 2020 17:08:31 +0000 (18:08 +0100)
When running tests in a mkosi container, /run/systemd might not
exist yet in the container which causes test-execute to fail.

Fixes #17842.

(cherry picked from commit 77f16dbd6d93f2b4a96984254cca25cab03479af)

src/core/namespace.c

index bddcb1e180f0f6b49a22d9324ed2cc7b6516fbfe..2c3c09417bcd13b78566212f2f9ed82d5fe9eb44 100644 (file)
@@ -1353,6 +1353,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.