sys_patch.py: Add handling for System Preferences prompt

This commit is contained in:
Mykola Grymalyuk
2022-05-26 22:31:15 -06:00
parent de21c361db
commit c1ebfd900f
4 changed files with 32 additions and 7 deletions

View File

@@ -1173,7 +1173,27 @@ class wx_python_gui:
sys.stderr = self.stock_stderr
if self.constants.root_patcher_succeded is True:
print("- Root Patcher finished successfully")
self.reboot_system(message="Root Patcher finished successfully\nWould you like to reboot now?")
if self.constants.needs_to_open_preferences is True:
# Create dialog box to open System Preferences -> Security and Privacy
self.popup = wx.MessageDialog(
self.frame_modal,
"We just finished installing the patches to your Root Volume!\n\nHowever, Apple requires users to manually approve the kernel extensions installed before they can be used next reboot.\n\nWould you like to open System Preferences?",
"Open System Preferences?",
wx.YES_NO | wx.ICON_INFORMATION
)
self.popup.SetYesNoLabels("Open System Preferences", "Ignore")
answer = self.popup.ShowModal()
if answer == wx.ID_YES:
subprocess.Popen(
[
"osascript", "-e",
'tell app "System Preferences" to reveal anchor "General" of pane id "com.apple.preference.security"'
]
)
time.sleep(5)
self.OnCloseFrame(None)
else:
self.reboot_system(message="Root Patcher finished successfully\nWould you like to reboot now?")
self.return_to_main_menu.Enable()
wx.GetApp().Yield()

View File

@@ -190,6 +190,7 @@ class Constants:
self.booted_oc_disk = None # Determine current disk OCLP booted from
self.start_build_install = False # Determine if build install should be started
self.host_is_non_metal = False # Determine if host is non-metal (ie. enable UI hacks)
self.needs_to_open_preferences = False # Determine if preferences need to be opened
self.legacy_accel_support = [
os_data.os_data.big_sur,

View File

@@ -41,6 +41,7 @@ class PatchSysVolume:
self.root_mount_path = None
self.root_supports_snapshot = utilities.check_if_root_is_apfs_snapshot()
self.constants.root_patcher_succeded = False # Reset Variable each time we start
self.constants.needs_to_open_preferences = False
self.patch_set_dictionary = {}
self.needs_kmutil_exemptions = False # For '/Library/Extensions' rebuilds
@@ -120,9 +121,10 @@ class PatchSysVolume:
if self.needs_kmutil_exemptions is True:
# When installing to '/Library/Extensions', following args skip kext consent
# prompt in System Preferences when SIP's disabled
print("- Disabling auth checks in kmutil")
print(" (You will get a prompt by System Preferences, ignore for now)")
args.append("--no-authentication")
args.append("--no-authorization")
self.constants.needs_to_open_preferences = True # Notify in GUI to open System Preferences
else:
args = ["kextcache", "-i", f"{self.mount_location}/"]
@@ -163,6 +165,8 @@ class PatchSysVolume:
self.unmount_drive()
print("- Patching complete")
print("\nPlease reboot the machine for patches to take effect")
if self.needs_kmutil_exemptions is True:
print("Note: Apple will require you to open System Preferences -> Security to\nallow the new kernel extensions to be loaded")
self.constants.root_patcher_succeded = True
if self.constants.gui_mode is False:
input("\nPress [ENTER] to continue")

View File

@@ -135,7 +135,7 @@ class detect_root_patch:
# First check boot-args, then dedicated nvram variable
nv_on = utilities.get_nvram("boot-args")
if nv_on:
if "nvda_drv_vrl" in nv_on:
if "nvda_drv_vrl=" in nv_on:
return True
nv_on = utilities.get_nvram("nvda_drv")
if nv_on:
@@ -146,11 +146,11 @@ class detect_root_patch:
# First check boot-args, then whether property exists on GPU
nv_on = utilities.get_nvram("boot-args")
if nv_on:
if "ngfxgl" in nv_on:
if "ngfxgl=" in nv_on:
return True
for gpu in self.constants.computer.gpus:
if isinstance(gpu, device_probe.NVIDIA):
if gpu.disable_metal:
if gpu.disable_metal is True:
return True
return False
@@ -158,11 +158,11 @@ class detect_root_patch:
# Check for 'nv_web' in boot-args, then whether property exists on GPU
nv_on = utilities.get_nvram("boot-args")
if nv_on:
if "ngfxcompat" in nv_on:
if "ngfxcompat=" in nv_on:
return True
for gpu in self.constants.computer.gpus:
if isinstance(gpu, device_probe.NVIDIA):
if gpu.force_compatible:
if gpu.force_compatible is True:
return True
return False