Skip to content

Commit d01fc56

Browse files
committed
Bootmgr (macOS): supports secure boot detection
1 parent 9c870a5 commit d01fc56

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/detection/bootmgr/bootmgr_apple.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
#include "bootmgr.h"
22
#include "common/io/io.h"
3+
#include "util/apple/cf_helpers.h"
4+
5+
#include <IOKit/IOKitLib.h>
6+
7+
FF_MAYBE_UNUSED static const char* detectFromIokit(bool* secureBoot)
8+
{
9+
FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryDevice = IORegistryEntryFromPath(kIOMainPortDefault, "IODeviceTree:/chosen");
10+
if (!entryDevice)
11+
return "IORegistryEntryFromPath() failed";
12+
13+
FF_CFTYPE_AUTO_RELEASE CFTypeRef prop = IORegistryEntryCreateCFProperty(entryDevice, CFSTR("secure-boot"), kCFAllocatorDefault, 0);
14+
if (!prop)
15+
return "IORegistryEntryCreateCFProperty() failed";
16+
17+
if (CFGetTypeID(prop) != CFDataGetTypeID() || CFDataGetLength((CFDataRef) prop) == 0)
18+
return "Invalid secure-boot property";
19+
20+
*secureBoot = (bool) *CFDataGetBytePtr((CFDataRef) prop);
21+
return NULL;
22+
}
323

424
const char* ffDetectBootmgr(FFBootmgrResult* result)
525
{
@@ -8,5 +28,7 @@ const char* ffDetectBootmgr(FFBootmgrResult* result)
828

929
ffStrbufSetStatic(&result->name, "iBoot");
1030

31+
detectFromIokit(&result->secureBoot);
32+
1133
return NULL;
1234
}

0 commit comments

Comments
 (0)