core: 添加安全启动判定

This commit is contained in:
bin456789 2023-12-22 23:45:06 +08:00
parent af99a3a70f
commit a8d5d63dca
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B

View File

@ -803,6 +803,18 @@ is_efi() {
fi
}
is_secure_boot_enabled() {
if is_efi; then
if is_in_windows; then
reg query 'HKLM\SYSTEM\CurrentControlSet\Control\SecureBoot\State' /v UEFISecureBootEnabled | grep 0x1 && return 0
else
# mokutil --sb-state
dmesg | grep -i 'Secure boot enabled' && return 0
fi
fi
return 1
}
is_use_grub() {
! { is_netboot_xyz && is_efi; }
}
@ -1341,15 +1353,20 @@ while true; do
esac
done
# 不支持容器虚拟化
assert_not_in_container
# 检查目标系统名
verify_os_name "$@"
# 检查必须的参数
verify_os_args
# 不支持容器虚拟化
assert_not_in_container
# 不支持安全启动
if is_secure_boot_enabled; then
error_and_exit "Not Supported with secure boot enabled."
fi
# win系统盘
if is_in_windows; then
c=$(echo $SYSTEMDRIVE | cut -c1)