From 09d8bf9930dc3507fcc8f1b9b126e2db1d2cddca Mon Sep 17 00:00:00 2001 From: Jonathon Hall <jonathon.hall@puri.sm> Date: Fri, 30 Jun 2023 13:41:07 -0400 Subject: [PATCH] media-scan: Simplify implementation and improve RB message Since 'standard boot' was removed, empty "$option" only occurs due to error now. Die with a specific error. Now, we only proceed past ISO boot if no ISOs were present, meaning the disk might be a plain bootable medium. Present a specific error for restricted boot in that case. Signed-off-by: Jonathon Hall <jonathon.hall@puri.sm> --- initrd/bin/media-scan | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/initrd/bin/media-scan b/initrd/bin/media-scan index edf01a09..4a23a934 100755 --- a/initrd/bin/media-scan +++ b/initrd/bin/media-scan @@ -70,6 +70,10 @@ get_menu_option() { fi option=`head -n $option_index /tmp/iso_menu.txt | tail -1` + + if [ -z "$option" ]; then + die "Failed to find menu option $option_index" + fi } # create ISO menu options @@ -81,17 +85,17 @@ if [ `cat /tmp/iso_menu.txt | wc -l` -gt 0 ]; then get_menu_option done - if [ -n "$option" ]; then - MOUNTED_ISO=$option - ISO=${option:7} # remove /media/ to get device relative path - DO_WITH_DEBUG kexec-iso-init $MOUNTED_ISO $ISO $USB_BOOT_DEV + MOUNTED_ISO="$option" + ISO="${option:7}" # remove /media/ to get device relative path + DO_WITH_DEBUG kexec-iso-init "$MOUNTED_ISO" "$ISO" "$USB_BOOT_DEV" - die "Something failed in iso init" - fi + die "Something failed in iso init" fi +# No *.iso files on media, try ordinary bootable USB + if [ "$CONFIG_RESTRICTED_BOOT" = y ]; then - die "ISO boot failed in Restricted Boot mode." + die "No ISO files found, bootable USB not allowed with Restricted Boot." fi echo "!!! Could not find any ISO, trying bootable USB"