mirror of
https://git.proxmox.com/git/efi-boot-shim
synced 2025-10-19 10:49:52 +00:00
Erase stored keys when there is no key in the new key list
This commit is contained in:
parent
ce2384495c
commit
f42825e60e
56
MokManager.c
56
MokManager.c
@ -449,7 +449,24 @@ static UINT8 mok_enrollment_prompt (void *MokNew, UINTN MokNewSize)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static EFI_STATUS enroll_mok (void *MokNew, UINT32 MokNewSize)
|
static UINT8 mok_deletion_prompt () {
|
||||||
|
EFI_INPUT_KEY key;
|
||||||
|
|
||||||
|
Print(L"Erase all stored keys? (y/N): ");
|
||||||
|
|
||||||
|
key = get_keystroke();
|
||||||
|
Print(L"%c\n", key.UnicodeChar);
|
||||||
|
|
||||||
|
if (key.UnicodeChar == 'Y' || key.UnicodeChar == 'y') {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Print(L"Abort\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static EFI_STATUS store_keys (void *MokNew, UINTN MokNewSize)
|
||||||
{
|
{
|
||||||
EFI_GUID shim_lock_guid = SHIM_LOCK_GUID;
|
EFI_GUID shim_lock_guid = SHIM_LOCK_GUID;
|
||||||
EFI_STATUS efi_status;
|
EFI_STATUS efi_status;
|
||||||
@ -462,11 +479,10 @@ static EFI_STATUS enroll_mok (void *MokNew, UINT32 MokNewSize)
|
|||||||
MokNewSize, MokNew);
|
MokNewSize, MokNew);
|
||||||
if (efi_status != EFI_SUCCESS) {
|
if (efi_status != EFI_SUCCESS) {
|
||||||
Print(L"Failed to set variable %d\n", efi_status);
|
Print(L"Failed to set variable %d\n", efi_status);
|
||||||
goto error;
|
return efi_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
error:
|
return EFI_SUCCESS;
|
||||||
return efi_status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static EFI_STATUS check_mok_request(EFI_HANDLE image_handle)
|
static EFI_STATUS check_mok_request(EFI_HANDLE image_handle)
|
||||||
@ -475,7 +491,7 @@ static EFI_STATUS check_mok_request(EFI_HANDLE image_handle)
|
|||||||
EFI_STATUS efi_status;
|
EFI_STATUS efi_status;
|
||||||
UINTN MokNewSize = 0;
|
UINTN MokNewSize = 0;
|
||||||
void *MokNew = NULL;
|
void *MokNew = NULL;
|
||||||
UINT32 attributes;
|
UINT32 attributes, MokNum;
|
||||||
UINT8 confirmed;
|
UINT8 confirmed;
|
||||||
|
|
||||||
efi_status = get_variable(L"MokNew", shim_lock_guid, &attributes,
|
efi_status = get_variable(L"MokNew", shim_lock_guid, &attributes,
|
||||||
@ -485,18 +501,32 @@ static EFI_STATUS check_mok_request(EFI_HANDLE image_handle)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
confirmed = mok_enrollment_prompt(MokNew, MokNewSize);
|
CopyMem(&MokNum, MokNew, sizeof(UINT32));
|
||||||
|
if (MokNum == 0) {
|
||||||
|
confirmed = mok_deletion_prompt();
|
||||||
|
|
||||||
if (!confirmed)
|
if (!confirmed)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
efi_status = enroll_mok(MokNew, MokNewSize);
|
efi_status = store_keys(MokNew, sizeof(UINT32));
|
||||||
|
|
||||||
if (efi_status != EFI_SUCCESS) {
|
if (efi_status != EFI_SUCCESS) {
|
||||||
Print(L"Failed to enroll MOK\n");
|
Print(L"Failed to erase keys\n");
|
||||||
goto error;
|
goto error;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
confirmed = mok_enrollment_prompt(MokNew, MokNewSize);
|
||||||
|
|
||||||
|
if (!confirmed)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
efi_status = store_keys(MokNew, MokNewSize);
|
||||||
|
|
||||||
|
if (efi_status != EFI_SUCCESS) {
|
||||||
|
Print(L"Failed to enroll MOK\n");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (MokNew) {
|
if (MokNew) {
|
||||||
if (delete_variable(L"MokNew", shim_lock_guid) != EFI_SUCCESS) {
|
if (delete_variable(L"MokNew", shim_lock_guid) != EFI_SUCCESS) {
|
||||||
|
Loading…
Reference in New Issue
Block a user