From 61b7447e18fa6d7d9896541355a23752fc9f1544 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Sat, 18 Jul 2020 17:00:46 +0200 Subject: [PATCH] Avoid executing memdiskfind under Secure Boot memdiskfind displays an ugly error message when running under Secure Boot where access to /dev/mem is restricted: | cannt open /dev/mem: Operation not permitted If we can read from /dev/mem then skip the memdiskfind and instead display a warning message. --- components/9990-main.sh | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/components/9990-main.sh b/components/9990-main.sh index b0e2a7b..7fb7ed3 100755 --- a/components/9990-main.sh +++ b/components/9990-main.sh @@ -52,25 +52,31 @@ Live () else if [ -x /usr/bin/memdiskfind ] then - if MEMDISK=$(/usr/bin/memdiskfind) + if ! dd if=/dev/mem of=/dev/zero bs=1 count=1 >/dev/null 2>&1 then - # We found a memdisk, set up phram - # Sometimes "modprobe phram" can not successfully create /dev/mtd0. - # Have to try several times. - max_try=20 - while [ ! -c /dev/mtd0 ] && [ "$max_try" -gt 0 ]; do - modprobe phram "phram=memdisk,${MEMDISK}" - sleep 0.2 - if [ -c /dev/mtd0 ]; then - break - else - rmmod phram - fi - max_try=$((max_try - 1)) - done - - # Load mtdblock, the memdisk will be /dev/mtdblock0 - modprobe mtdblock + log_begin_msg "access to /dev/mem is restriced, skipping memdiskfind" + log_end_msg + else + if MEMDISK=$(/usr/bin/memdiskfind) + then + # We found a memdisk, set up phram + # Sometimes "modprobe phram" can not successfully create /dev/mtd0. + # Have to try several times. + max_try=20 + while [ ! -c /dev/mtd0 ] && [ "$max_try" -gt 0 ]; do + modprobe phram "phram=memdisk,${MEMDISK}" + sleep 0.2 + if [ -c /dev/mtd0 ]; then + break + else + rmmod phram + fi + max_try=$((max_try - 1)) + done + + # Load mtdblock, the memdisk will be /dev/mtdblock0 + modprobe mtdblock + fi fi fi -- 2.1.4