summaryrefslogtreecommitdiff
path: root/MokManager.c
diff options
context:
space:
mode:
authorMatthew Garrett <mjg@redhat.com>2012-10-08 17:35:50 -0400
committerMatthew Garrett <mjg@redhat.com>2012-10-08 17:35:50 -0400
commitd1c2586c237f14a275eff0aa099178b7104ab7d1 (patch)
tree6986f5c796be523b7dcdc78a6a4ad99f45f70ede /MokManager.c
parent1e9de96f8ad0eefb88fb18e7107a37714b6fc4ba (diff)
downloadefi-boot-shim-d1c2586c237f14a275eff0aa099178b7104ab7d1.tar.gz
efi-boot-shim-d1c2586c237f14a275eff0aa099178b7104ab7d1.zip
Fix filesystem enrollment
We would always enrol a single key, deleting any existing keys in the database. Fix that up.
Diffstat (limited to 'MokManager.c')
-rw-r--r--MokManager.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/MokManager.c b/MokManager.c
index 3a447a4d..88785e6e 100644
--- a/MokManager.c
+++ b/MokManager.c
@@ -678,6 +678,7 @@ static void run_menu (struct menu_item *items, UINTN count) {
}
static UINTN file_callback (void *data, void *data2) {
+ EFI_GUID shim_lock_guid = SHIM_LOCK_GUID;
EFI_FILE_INFO *buffer = NULL;
UINTN buffersize = 0, readsize;
EFI_STATUS status;
@@ -685,8 +686,12 @@ static UINTN file_callback (void *data, void *data2) {
CHAR16 *filename = data;
EFI_FILE *parent = data2;
EFI_GUID file_info_guid = EFI_FILE_INFO_ID;
- void *mokbuffer = NULL;
- void *filebuffer;
+ void *mokbuffer = NULL, *mok;
+ UINTN MokSize = 0, MokNewSize;
+ MokListNode *MokNew;
+ int i;
+
+ mok = LibGetVariableAndSize(L"MokList", &shim_lock_guid, &MokSize);
status = uefi_call_wrapper(parent->Open, 5, parent, &file, filename,
EFI_FILE_MODE_READ, 0);
@@ -709,21 +714,34 @@ static UINTN file_callback (void *data, void *data2) {
readsize = buffer->FileSize;
- mokbuffer = AllocateZeroPool(readsize + (2 * sizeof(UINT32)));
- if (!mokbuffer)
- goto out;
+ if (mok) {
+ MokNewSize = MokSize + readsize + sizeof(UINT32);
+ mokbuffer = AllocateZeroPool(MokNewSize);
+
+ if (!mokbuffer)
+ goto out;
+
+ CopyMem(mokbuffer, mok, MokSize);
+ ((UINT32 *)mokbuffer)[0]++;
+ MokNew = (MokListNode *)(((char *)mokbuffer) + MokSize);
+ } else {
+ MokNewSize = readsize + (2 * sizeof(UINT32));
+ mokbuffer = AllocateZeroPool(MokNewSize);
+
+ if (!mokbuffer)
+ goto out;
+ ((UINT32 *)mokbuffer)[0]=1;
+ MokNew = (MokListNode *)(((UINT32 *)mokbuffer) + 1);
+ }
- ((UINT32 *)mokbuffer)[0] = 1;
- ((UINT32 *)mokbuffer)[1] = readsize;
- filebuffer = (UINT32 *)mokbuffer + 2;
+ MokNew->MokSize = readsize;
- status = uefi_call_wrapper(file->Read, 3, file, &readsize, filebuffer);
+ status = uefi_call_wrapper(file->Read, 3, file, &readsize, &MokNew->Mok);
if (status != EFI_SUCCESS)
goto out;
- mok_enrollment_prompt(mokbuffer,
- (void *)buffer->FileSize + (2 * sizeof(UINT32)));
+ mok_enrollment_prompt(mokbuffer, MokNewSize, FALSE);
out:
if (buffer)
FreePool(buffer);