You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use cryptsetup --link-vk-to-keyring to save volume keys
cryptsetup open --link-vk-to-keyring (man cryptsetup-open) will link
volume key to specified keyring after successfully unlocking the volume.
Use this feature to save key to @U::%logon:cryptsetup:$UUID to support
the following cases
- volume is unlocked automatically say using TPM-sealed key
- ask user to input passphrase to unlock the volume
Signed-off-by: Coiby Xu <[email protected]>
ddebug "Attempting to unlock LUKS device. You have $_max_retries attempts."
1071
+
else
1072
+
# Not a terminal (e.g., running as system service), so only try once
1073
+
# for cases where volume key is sealed to TPM which doesn't need user
1074
+
# interaction.
1075
+
_max_retries=1
1076
+
ddebug "Attempting to unlock LUKS device (non-interactive mode)..."
1077
+
fi
1078
+
1079
+
while [ "$_attempt"-le"$_max_retries" ];do
1080
+
if cryptsetup open "UUID=$_devuuid" DUMMY "--link-vk-to-keyring=@u::%logon:$_key_des" --test-passphrase;then
1081
+
ddebug "Success: LUKS device unlocked."
1082
+
dwarn "To avoid manually running kdumpctl, ensure the link-volume-key=@u::%logon:$_key_des option is correctly set up in /etc/crypttab (see man crypttab)."
1083
+
return 0
1084
+
fi
1085
+
_attempt=$((_attempt +1))
1086
+
done
1087
+
1088
+
derror "Error: Could not unlock the LUKS device."
1089
+
return 1
1090
+
}
1091
+
1059
1092
prepare_luks()
1060
1093
{
1061
-
local _luks_dev _key_id _key_des
1094
+
local _luks_dev _key_id _key_des _luks_unlock_cmd
1062
1095
declare -a _luks_devs
1063
1096
1064
1097
mapfile -t _luks_devs <<(get_all_kdump_crypt_dev)
@@ -1077,12 +1110,19 @@ prepare_luks()
1077
1110
_key_dir=$LUKS_CONFIGFS/$_devuuid
1078
1111
_key_des=$LUKS_KEY_PRFIX$_devuuid
1079
1112
if _key_id=$(keyctl request logon "$_key_des"2> /dev/null);then
ddebug "Succesfully get @u::%logon:$_key_des after cryptsetup"
1082
1117
else
1083
-
derror "Failed to get logon key $_key_des. Ensure the link-volume-key option is correctly set up in /etc/crypttab (see man crypttab) and that the key is available."
1118
+
derror "Failed to get logon key $_key_des. Run 'kdumpctl restart' manually to start kdump."
0 commit comments