mac admin auth check

This commit is contained in:
21pages
2023-02-25 04:55:37 -08:00
parent 17f1c18c92
commit b9b4913ca0
3 changed files with 41 additions and 3 deletions

View File

@@ -34,6 +34,7 @@ extern "C" {
static kAXTrustedCheckOptionPrompt: CFStringRef;
fn AXIsProcessTrustedWithOptions(options: CFDictionaryRef) -> BOOL;
fn InputMonitoringAuthStatus(_: BOOL) -> BOOL;
fn MacCheckAdminAuthorization() -> BOOL;
fn MacGetModeNum(display: u32, numModes: *mut u32) -> BOOL;
fn MacGetModes(
display: u32,
@@ -665,3 +666,10 @@ pub fn change_resolution(name: &str, width: usize, height: usize) -> ResultType<
}
Ok(())
}
pub fn check_super_user_permission() -> ResultType<bool> {
unsafe {
Ok(MacCheckAdminAuthorization() == YES)
}
}