]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix(dmsquash-live): do not check ISO md5 if image filesystem
authorFederico Vaga <federico.vaga@cern.ch>
Wed, 20 Dec 2023 11:02:15 +0000 (12:02 +0100)
committerLaszlo Gombos <laszlo.gombos@gmail.com>
Tue, 23 Apr 2024 22:59:40 +0000 (18:59 -0400)
The ISO checksum code was executed independently of the provided
`$livedev`. Often, this is a loop device pointing to an ISO image, but
in other cases `dmsquash-live-root` receives the path to a filesystem
image. In this case, we can't use `udevadm` to extract information
because it is not a device, and trying to do that leads to `udevadm`
error messages (but not blocking).

Therefore, the ISO checksum check must be performed only if the provided
`$livedev` is **not** a regular file.

Signed-off-by: Federico Vaga <federico.vaga@cern.ch>
modules.d/90dmsquash-live/dmsquash-live-root.sh

index 1e84714c2140dfe0b76277b77afa7938e7afa1af..4518852bddd64553243f534bc34ededab98275da 100755 (executable)
@@ -59,29 +59,34 @@ get_check_dev() {
     echo "$_udevinfo" | grep "DEVNAME=" | sed 's/DEVNAME=//'
 }
 
-# Find the right device to run check on
-check_dev=$(get_check_dev "$livedev")
-# CD/DVD media check
-[ -b "$check_dev" ] && fs=$(det_fs "$check_dev")
-if [ "$fs" = "iso9660" -o "$fs" = "udf" ]; then
-    check="yes"
-fi
-getarg rd.live.check -d check || check=""
-if [ -n "$check" ]; then
-    type plymouth > /dev/null 2>&1 && plymouth --hide-splash
-    if [ -n "$DRACUT_SYSTEMD" ]; then
-        p=$(dev_unit_name "$check_dev")
-        systemctl start checkisomd5@"${p}".service
-    else
-        checkisomd5 --verbose "$check_dev"
+# Check ISO checksum only if we have a path to a block device (or just its name
+# without '/dev'). In other words, in this context, we perform the check only
+# if the given $livedev is not a filesystem file image.
+if [ ! -f "$livedev" ]; then
+    # Find the right device to run check on
+    check_dev=$(get_check_dev "$livedev")
+    # CD/DVD media check
+    [ -b "$check_dev" ] && fs=$(det_fs "$check_dev")
+    if [ "$fs" = "iso9660" -o "$fs" = "udf" ]; then
+        check="yes"
     fi
-    if [ $? -eq 1 ]; then
-        warn "Media check failed! We do not recommend using this medium. System will halt in 12 hours"
-        sleep 43200
-        die "Media check failed!"
-        exit 1
+    getarg rd.live.check -d check || check=""
+    if [ -n "$check" ]; then
+        type plymouth > /dev/null 2>&1 && plymouth --hide-splash
+        if [ -n "$DRACUT_SYSTEMD" ]; then
+            p=$(dev_unit_name "$check_dev")
+            systemctl start checkisomd5@"${p}".service
+        else
+            checkisomd5 --verbose "$check_dev"
+        fi
+        if [ $? -eq 1 ]; then
+            warn "Media check failed! We do not recommend using this medium. System will halt in 12 hours"
+            sleep 43200
+            die "Media check failed!"
+            exit 1
+        fi
+        type plymouth > /dev/null 2>&1 && plymouth --show-splash
     fi
-    type plymouth > /dev/null 2>&1 && plymouth --show-splash
 fi
 
 ln -s "$livedev" /run/initramfs/livedev