Skip to content

Commit

Permalink
systemd: core/manager: run generators directly when we are in initrd
Browse files Browse the repository at this point in the history
lvm with latest systemd and dracut doesn't boot up.
Upstream issues for reference:
  - dracut: dracutdevs/dracut#2211
  - systemd: systemd/systemd#26488

Temporary patch applied until this issue is resolved
systemd/systemd#26494

See systemd/systemd#26488 (comment)

Change-Id: I1964ff2a82b7c2d6c53e02b4368a8d5d6f9a03a1
Signed-off-by: Tapas Kundu <tkundu@vmware.com>
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/20134
  • Loading branch information
ssahani authored and tapakund committed Mar 29, 2023
1 parent acf6c69 commit 4d59746
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
30 changes: 30 additions & 0 deletions SPECS/systemd/systemd-issue-26494.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
From 6b25470ee28843a49c50442e9d8a98edc842ceca Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Mon, 20 Feb 2023 12:00:30 +0900
Subject: [PATCH] core/manager: run generators directly when we are in initrd

Some initrd system write files at ourside of /run, /etc, or other
allowed places. This is a kind of workaround, but in most cases, such
sandboxing is not necessary as the filesystem is on ramfs when we are in
initrd.

Fixes #26488.
---
src/core/manager.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/core/manager.c b/src/core/manager.c
index 7b394794b0d4..306477c6e6c2 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -3822,8 +3822,8 @@ static int manager_run_generators(Manager *m) {
/* If we are the system manager, we fork and invoke the generators in a sanitized mount namespace. If
* we are the user manager, let's just execute the generators directly. We might not have the
* necessary privileges, and the system manager has already mounted /tmp/ and everything else for us.
- */
- if (MANAGER_IS_USER(m)) {
+ * If we are in initrd, let's also execute the generators directly, as we are in ramfs. */
+ if (MANAGER_IS_USER(m) || in_initrd()) {
r = manager_execute_generators(m, paths, /* remount_ro= */ false);
goto finish;
}
7 changes: 6 additions & 1 deletion SPECS/systemd/systemd.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Name: systemd
URL: http://www.freedesktop.org/wiki/Software/systemd
Version: 253
Release: 1%{?dist}
Release: 2%{?dist}
License: LGPLv2+ and GPLv2+ and MIT
Summary: System and Service Manager
Group: System Environment/Security
Expand All @@ -17,7 +17,9 @@ Source1: 99-vmware-hotplug.rules
Source2: 50-security-hardening.conf
Source3: %{name}.cfg
Source4: 99-dhcp-en.network
%ifarch x86_64
Source5: 10-rdrand-rng.conf
%endif
Source6: 10-defaults.preset

Source11: macros.sysusers
Expand All @@ -28,6 +30,7 @@ Source14: sysusers.generate-pre.sh
Patch0: enoX-uses-instance-number-for-vmware-hv.patch
Patch1: fetch-dns-servers-from-environment.patch
Patch2: use-bfq-scheduler.patch
Patch3: systemd-issue-26494.patch

Requires: Linux-PAM
Requires: bzip2
Expand Down Expand Up @@ -705,6 +708,8 @@ fi
%files lang -f ../%{name}.lang

%changelog
* Wed Mar 29 2023 Susant Sahani <ssahani@vmware.com> 253-2
- https://github.com/systemd/systemd/pull/26494.patch.
* Thu Feb 16 2023 Susant Sahani <ssahani@vmware.com> 253-1
- Version bump.
* Tue Feb 07 2023 Shreenidhi Shedi <sshedi@vmware.com> 252.4-9
Expand Down

0 comments on commit 4d59746

Please sign in to comment.