summaryrefslogtreecommitdiff
path: root/shim.c
diff options
context:
space:
mode:
authorMatthew Garrett <mjg@redhat.com>2012-10-23 13:01:25 -0400
committerMatthew Garrett <mjg@redhat.com>2012-10-23 13:01:25 -0400
commitd5a2d9ea083f329f71a9cc5c3aac45b60fa60b93 (patch)
treea0314a0fd5389ac7fa4c53b9ef6fe299310a0215 /shim.c
parent3a5933619965b4ba8c3aa0e3abbb4755bb80dc78 (diff)
downloadefi-boot-shim-d5a2d9ea083f329f71a9cc5c3aac45b60fa60b93.tar.gz
efi-boot-shim-d5a2d9ea083f329f71a9cc5c3aac45b60fa60b93.zip
Clean up checks for MokManager entry
Add a helper function and tidy up the calls for getting into MokManager
Diffstat (limited to 'shim.c')
-rw-r--r--shim.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/shim.c b/shim.c
index dbe5e849..9ff4b8be 100644
--- a/shim.c
+++ b/shim.c
@@ -1035,32 +1035,30 @@ done:
return efi_status;
}
-EFI_STATUS check_mok_request(EFI_HANDLE image_handle)
+static BOOLEAN check_var(CHAR16 *varname)
{
+ EFI_STATUS efi_status;
EFI_GUID shim_lock_guid = SHIM_LOCK_GUID;
- EFI_STATUS moknew_status, moksb_status, mokpw_status, efi_status;
UINTN size = sizeof(UINT32);
UINT32 MokVar;
UINT32 attributes;
- moknew_status = uefi_call_wrapper(RT->GetVariable, 5, L"MokNew",
- &shim_lock_guid, &attributes,
- &size, (void *)&MokVar);
+ efi_status = uefi_call_wrapper(RT->GetVariable, 5, varname,
+ &shim_lock_guid, &attributes,
+ &size, (void *)&MokVar);
- moksb_status = uefi_call_wrapper(RT->GetVariable, 5, L"MokSB",
- &shim_lock_guid, &attributes,
- &size, (void *)&MokVar);
+ if (efi_status == EFI_SUCCESS || efi_status == EFI_BUFFER_TOO_SMALL)
+ return TRUE;
+
+ return FALSE;
+}
- mokpw_status = uefi_call_wrapper(RT->GetVariable, 5, L"MokPW",
- &shim_lock_guid, &attributes,
- &size, (void *)&MokVar);
+EFI_STATUS check_mok_request(EFI_HANDLE image_handle)
+{
+ EFI_STATUS efi_status;
- if (moknew_status == EFI_SUCCESS ||
- moknew_status == EFI_BUFFER_TOO_SMALL ||
- moksb_status == EFI_SUCCESS ||
- moksb_status == EFI_BUFFER_TOO_SMALL ||
- mokpw_status == EFI_SUCCESS ||
- mokpw_status == EFI_BUFFER_TOO_SMALL) {
+ if (check_var(L"MokNew") || check_var(L"MokSB") ||
+ check_var(L"MokPW") || check_var(L"MokAuth")) {
efi_status = start_image(image_handle, MOK_MANAGER);
if (efi_status != EFI_SUCCESS) {