4bdd16e
From 6b25470ee28843a49c50442e9d8a98edc842ceca Mon Sep 17 00:00:00 2001
4bdd16e
From: Yu Watanabe <watanabe.yu+github@gmail.com>
4bdd16e
Date: Mon, 20 Feb 2023 12:00:30 +0900
4bdd16e
Subject: [PATCH] core/manager: run generators directly when we are in initrd
4bdd16e
4bdd16e
Some initrd system write files at ourside of /run, /etc, or other
4bdd16e
allowed places. This is a kind of workaround, but in most cases, such
4bdd16e
sandboxing is not necessary as the filesystem is on ramfs when we are in
4bdd16e
initrd.
4bdd16e
4bdd16e
Fixes #26488.
4bdd16e
---
4bdd16e
 src/core/manager.c | 4 ++--
4bdd16e
 1 file changed, 2 insertions(+), 2 deletions(-)
4bdd16e
4bdd16e
diff --git a/src/core/manager.c b/src/core/manager.c
4bdd16e
index 7b394794b0d4..306477c6e6c2 100644
4bdd16e
--- a/src/core/manager.c
4bdd16e
+++ b/src/core/manager.c
4bdd16e
@@ -3822,8 +3822,8 @@ static int manager_run_generators(Manager *m) {
4bdd16e
         /* If we are the system manager, we fork and invoke the generators in a sanitized mount namespace. If
4bdd16e
          * we are the user manager, let's just execute the generators directly. We might not have the
4bdd16e
          * necessary privileges, and the system manager has already mounted /tmp/ and everything else for us.
4bdd16e
-         */
4bdd16e
-        if (MANAGER_IS_USER(m)) {
4bdd16e
+         * If we are in initrd, let's also execute the generators directly, as we are in ramfs. */
4bdd16e
+        if (MANAGER_IS_USER(m) || in_initrd()) {
4bdd16e
                 r = manager_execute_generators(m, paths, /* remount_ro= */ false);
4bdd16e
                 goto finish;
4bdd16e
         }