commit:     f8a26eeba219c4027848fd50a2ae4e9d22029168
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 15 05:44:32 2021 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Mon Feb 15 05:51:59 2021 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=f8a26eeb

initrd.scripts: openLUKS(): differentiate LUKS_DEVICE errors

If LUKS_DEVICE was not found user can either have not set
crypt_{root,swap}, set crypt_{root,swap} to an invalid value
or kernel is lacking storage support (i.e. missing controller driver).

Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 defaults/initrd.scripts | 8 +++++++-
 defaults/unlock-luks.sh | 8 +++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 2fcc593..f7e6c3d 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -1783,6 +1783,12 @@ openLUKS() {
        local DEV_ERROR=0 KEY_ERROR=0 KEYDEV_ERROR=0
        local mntkey="/mnt/key/" crypt_filter_ret=
 
+       if [ -z "${LUKS_DEVICE}" ]
+       then
+               bad_msg "'crypt_${1}' kernel command-line argument is not set!"
+               exit 1
+       fi
+
        while true
        do
                local gpg_cmd=""
@@ -1810,7 +1816,7 @@ openLUKS() {
                        LUKS_DEVICE=$(find_real_device "${LUKS_DEVICE}")
                        if [ -z "${LUKS_DEVICE}" ]
                        then
-                               bad_msg "Looks like CRYPT_${TYPE} kernel 
cmdline argument is not set." ${CRYPT_SILENT}
+                               bad_msg "Failed to find LUKS device. If 
crypt_${1} kernel command-line argument is correct you are probably missing 
kernel support for your storage!" ${CRYPT_SILENT}
                                DEV_ERROR=1
                                continue
                        fi

diff --git a/defaults/unlock-luks.sh b/defaults/unlock-luks.sh
index 59e086a..4c99a1f 100644
--- a/defaults/unlock-luks.sh
+++ b/defaults/unlock-luks.sh
@@ -49,6 +49,12 @@ main() {
        eval local cryptsetup_options='"${CRYPT_'${TYPE}'_OPTIONS}"'
        eval local OPENED_LOCKFILE='"${CRYPT_'${TYPE}'_OPENED_LOCKFILE}"'
 
+       if [ -z "${LUKS_DEVICE}" ]
+       then
+               bad_msg "'crypt_${NAME}' kernel command-line argument is not 
set!"
+               exit 1
+       fi
+
        while true
        do
                local gpg_cmd crypt_filter_ret
@@ -61,7 +67,7 @@ main() {
                        LUKS_DEVICE=$(find_real_device "${LUKS_DEVICE}")
                        if [ -z "${LUKS_DEVICE}" ]
                        then
-                               bad_msg "Looks like CRYPT_${TYPE} kernel 
cmdline argument is not set." "${CRYPT_SILENT}"
+                               bad_msg "Failed to find LUKS device. If 
crypt_${NAME} kernel command-line argument is correct you are probably missing 
kernel support for your storage!" ${CRYPT_SILENT}
                                exit 1
                        fi
 

Reply via email to