Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netboot cleanup for additional files #686

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions shim.c
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@
#include <Library/BaseCryptLib.h>

#include <stdint.h>
#include <stdio.h>

#define OID_EKU_MODSIGN "1.3.6.1.4.1.2312.16.1.2"

@@ -1519,7 +1520,8 @@ load_revocations_file(EFI_HANDLE image_handle, CHAR16 *PathName)
}

EFI_STATUS
load_cert_file(EFI_HANDLE image_handle, CHAR16 *filename, CHAR16 *PathName)
load_cert_file(EFI_HANDLE image_handle, CHAR16 *filename, CHAR16 *PathName,
int flags)
{
EFI_STATUS efi_status;
PE_COFF_LOADER_IMAGE_CONTEXT context;
@@ -1532,8 +1534,7 @@ load_cert_file(EFI_HANDLE image_handle, CHAR16 *filename, CHAR16 *PathName)
int i;

efi_status = read_image(image_handle, filename, &PathName,
&data, &datasize,
SUPPRESS_NETBOOT_OPEN_FAILURE_NOISE);
&data, &datasize, flags);
if (EFI_ERROR(efi_status))
return efi_status;

@@ -1575,13 +1576,15 @@ load_unbundled_trust(EFI_HANDLE image_handle)
EFI_STATUS efi_status;
EFI_LOADED_IMAGE *li = NULL;
CHAR16 *PathName = NULL;
static CHAR16 FileName[] = L"shim_certificate_0.efi";
EFI_FILE *root, *dir;
EFI_FILE_INFO *info;
EFI_HANDLE device;
EFI_FILE_IO_INTERFACE *drive;
UINTN buffersize = 0;
void *buffer = NULL;
BOOLEAN search_revocations = TRUE;
int i = 0;

efi_status = gBS->HandleProtocol(image_handle, &EFI_LOADED_IMAGE_GUID,
(void **)&li);
@@ -1693,13 +1696,18 @@ load_unbundled_trust(EFI_HANDLE image_handle)
if (EFI_ERROR(efi_status)) {
perror(L"Failed to open %s - %r\n",
PathName, efi_status);
while (load_cert_file(image_handle, FileName, PathName,
SUPPRESS_NETBOOT_OPEN_FAILURE_NOISE)
== EFI_SUCCESS && i++ < 10) {
FileName[17]++;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's going to be confusing having to rename shim_certificate_sbat.efi to shim_certificate_0.efi, shim_certificate_ski.efi to shim_certificate_1.efi etc. Can't we just use those names?

}
goto done;
}
}

if (!search_revocations &&
StrnCaseCmp(info->FileName, L"shim_certificate", 16) == 0) {
load_cert_file(image_handle, info->FileName, PathName);
load_cert_file(image_handle, info->FileName, PathName, 0);
}
}
done: