mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 08:13:44 +01:00
Bootmgr (macOS): supports secure boot detection on Intel
This commit is contained in:
@@ -4,8 +4,9 @@
|
||||
|
||||
#include <IOKit/IOKitLib.h>
|
||||
|
||||
FF_MAYBE_UNUSED static const char* detectFromIokit(bool* secureBoot)
|
||||
static const char* detectSecureBoot(bool* result)
|
||||
{
|
||||
#if __aarch64__
|
||||
FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryDevice = IORegistryEntryFromPath(kIOMainPortDefault, "IODeviceTree:/chosen");
|
||||
if (!entryDevice)
|
||||
return "IORegistryEntryFromPath() failed";
|
||||
@@ -17,7 +18,22 @@ FF_MAYBE_UNUSED static const char* detectFromIokit(bool* secureBoot)
|
||||
if (CFGetTypeID(prop) != CFDataGetTypeID() || CFDataGetLength((CFDataRef) prop) == 0)
|
||||
return "Invalid secure-boot property";
|
||||
|
||||
*secureBoot = (bool) *CFDataGetBytePtr((CFDataRef) prop);
|
||||
*result = (bool) *CFDataGetBytePtr((CFDataRef) prop);
|
||||
#else
|
||||
FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryDevice = IORegistryEntryFromPath(kIOMainPortDefault, "IODeviceTree:/options");
|
||||
if (!entryDevice)
|
||||
return "IORegistryEntryFromPath() failed";
|
||||
|
||||
FF_CFTYPE_AUTO_RELEASE CFTypeRef prop = IORegistryEntryCreateCFProperty(entryDevice, CFSTR("94b73556-2197-4702-82a8-3e1337dafbfb:AppleSecureBootPolicy"), kCFAllocatorDefault, 0);
|
||||
if (!prop)
|
||||
return "IORegistryEntryCreateCFProperty() failed";
|
||||
|
||||
if (CFGetTypeID(prop) != CFDataGetTypeID() || CFDataGetLength((CFDataRef) prop) == 0)
|
||||
return "Invalid secure-boot property";
|
||||
|
||||
*result = *CFDataGetBytePtr((CFDataRef) prop) != 0x02 /* Permissive Security */;
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -28,7 +44,7 @@ const char* ffDetectBootmgr(FFBootmgrResult* result)
|
||||
|
||||
ffStrbufSetStatic(&result->name, "iBoot");
|
||||
|
||||
detectFromIokit(&result->secureBoot);
|
||||
detectSecureBoot(&result->secureBoot);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user