+CC Benjamin Drung

On Mon, Mar 03, 2025 at 08:30:38PM +0100, Chris Hofstaedtler wrote:
> 1) our builds run in a containerized environment, and thus have no /sys or
> /proc. This is /good/ for building Live images, as leaking anything from the
> build host would be wrong anyway.
> 
> 2) live-boot hook.live does "set -e" right at the start:
> https://sources.debian.org/src/live-boot/1%3A20250225/backend/initramfs-tools/live.hook/#L3
> 
> 3) hook-functions _call_dracut_install reads from 
> /sys/module/firmware_class/parameters/path
> without checking if the file exists (or otherwise allowing for set -e), and
> this causes the entire process to abort.
[..] 
> Please consider short-circuiting the read from 
> /sys/module/firmware_class/parameters/path
> somehow, and please for trixie.

Please find a patch attached, and a Merge Request here:

https://salsa.debian.org/kernel-team/initramfs-tools/-/merge_requests/160

Thanks,
Chris
>From 297a9e292aac2a629cc6e7e557952d67640e97d1 Mon Sep 17 00:00:00 2001
From: Chris Hofstaedtler <z...@debian.org>
Date: Tue, 4 Mar 2025 13:08:40 +0100
Subject: [PATCH] hook-functions: avoid aborting in chroots

chroots and other build environments often do not have /sys mounted.
Nevertheless they want to build initrds. As a complication, live-boot
calls these functions from a hook that has "set -e" turned on, turning
the ignored error from "read" into an abort of update-initramfs.

Fixes: b3e8cc4011334b6f39ba915149d5518b1644f87b
Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1099461
Signed-off-by: Chris Hofstaedtler <z...@debian.org>
---
 hook-functions | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/hook-functions b/hook-functions
index 5535a2f..c0d8a0a 100644
--- a/hook-functions
+++ b/hook-functions
@@ -62,7 +62,9 @@ add_firmware()
 
 	firmware="${1}"
 
-	read -r fw_path_para < /sys/module/firmware_class/parameters/path
+	if [ -e /sys/module/firmware_class/parameters/path ]; then
+		read -r fw_path_para < /sys/module/firmware_class/parameters/path
+	fi
 
 	for suffix in "" ".zst" ".xz"; do
 		for path in ${fw_path_para:+"$fw_path_para"} \
@@ -119,7 +121,9 @@ _call_dracut_install()
 		dracut_verbose=-v
 	fi
 
-	read -r fw_path_para < /sys/module/firmware_class/parameters/path
+	if [ -e /sys/module/firmware_class/parameters/path ]; then
+		read -r fw_path_para < /sys/module/firmware_class/parameters/path
+	fi
 	/usr/lib/dracut/dracut-install -D "$DESTDIR" --kerneldir "/lib/modules/${version?}" \
 		--firmwaredirs "${fw_path_para:+${fw_path_para}:}/lib/firmware/updates/${version?}:/lib/firmware/updates:/lib/firmware/${version?}:/lib/firmware" \
 		${dracut_verbose-} -o -m "$@"
-- 
2.47.2

Reply via email to