Don't assume /run/systemd exists when creating unit-root

When running tests in a mkosi container, /run/systemd might not
exist yet in the container which causes test-execute to fail.

Fixes #17842.
This commit is contained in:
Daan De Meyer 2020-12-03 23:08:21 +00:00
parent f1027d7c28
commit 77f16dbd6d
1 changed files with 5 additions and 0 deletions

View 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.