From 97a86fcd9243566d8c49f53533283792ea92465d Mon Sep 17 00:00:00 2001 From: Jazzzny Date: Fri, 28 Jul 2023 20:52:18 -0400 Subject: [PATCH 1/6] Add developer patcher --- resources/wx_gui/gui_settings.py | 53 +++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/resources/wx_gui/gui_settings.py b/resources/wx_gui/gui_settings.py index 071275456..3322b0e6b 100644 --- a/resources/wx_gui/gui_settings.py +++ b/resources/wx_gui/gui_settings.py @@ -4,6 +4,7 @@ import pprint import logging import py_sip_xnu import subprocess +import os from pathlib import Path @@ -814,6 +815,9 @@ class SettingsFrame(wx.Frame): }, }, "Developer": { + "Validation": { + "type": "title", + }, "Install latest nightly build ๐Ÿงช": { "type": "button", "function": self.on_nightly, @@ -839,6 +843,28 @@ class SettingsFrame(wx.Frame): "Export constants.py values to a txt file.", ], }, + "Developer Root Volume Patching": { + "type": "title", + }, + "Mount Root Volume": { + "type": "button", + "function": self.on_mount_root_vol, + "description": [ + "Life's too short to type 'sudo mount -o", + "nobrowse -t apfs /dev/diskXsY", + "/System/Volumes/Update/mnt1' every time.", + ], + }, + "wrap_around 2": { + "type": "wrap_around", + }, + "Update Root Volume": { + "type": "button", + "function": self.on_bless_root_vol, + "description": [ + "Rebuild kernel cache and bless snapshot ๐Ÿ™", + ], + }, }, } @@ -1274,4 +1300,29 @@ Hardware Information: def on_test_exception(self, event: wx.Event) -> None: - raise Exception("Test Exception") \ No newline at end of file + raise Exception("Test Exception") + + def on_mount_root_vol(self, event: wx.Event) -> None: + if os.geteuid() != 0: + wx.MessageDialog(self.parent, "Please relaunch as Root to mount the Root Volume", "Error", wx.OK | wx.ICON_ERROR).ShowModal() + else: + from resources.sys_patch.sys_patch import PatchSysVolume + #Don't need to pass model as we're bypassing all logic + if PatchSysVolume("",self.constants)._mount_root_vol() == True: + wx.MessageDialog(self.parent, "Root Volume Mounted, remember to fix permissions before blessing ๐Ÿ™", "Success", wx.OK | wx.ICON_INFORMATION).ShowModal() + else: + wx.MessageDialog(self.parent, "Root Volume Mount Failed, check terminal output", "Error", wx.OK | wx.ICON_ERROR).ShowModal() + + def on_bless_root_vol(self, event: wx.Event) -> None: + if os.geteuid() != 0: + wx.MessageDialog(self.parent, "Please relaunch as Root to save changes", "Error", wx.OK | wx.ICON_ERROR).ShowModal() + else: + from resources.sys_patch.sys_patch import PatchSysVolume + #Don't need to pass model as we're bypassing all logic + if PatchSysVolume("",self.constants)._rebuild_kernel_collection() == True: + if PatchSysVolume("",self.constants)._create_new_apfs_snapshot() == True: + wx.MessageDialog(self.parent, "Root Volume Updated, please reboot to apply changes", "Success", wx.OK | wx.ICON_INFORMATION).ShowModal() + else: + wx.MessageDialog(self.parent, "Root Volume Bless Failed, check terminal output", "Error", wx.OK | wx.ICON_ERROR).ShowModal() + else: + wx.MessageDialog(self.parent, "KC Update Failed, check terminal output", "Error", wx.OK | wx.ICON_ERROR).ShowModal() \ No newline at end of file From 8b0625eb4141bcf0e2abdc4a8b4da23c4995c87d Mon Sep 17 00:00:00 2001 From: Jazzzny Date: Fri, 28 Jul 2023 20:58:35 -0400 Subject: [PATCH 2/6] change wording --- resources/wx_gui/gui_settings.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/wx_gui/gui_settings.py b/resources/wx_gui/gui_settings.py index 3322b0e6b..18479d581 100644 --- a/resources/wx_gui/gui_settings.py +++ b/resources/wx_gui/gui_settings.py @@ -858,7 +858,7 @@ class SettingsFrame(wx.Frame): "wrap_around 2": { "type": "wrap_around", }, - "Update Root Volume": { + "Save Root Volume": { "type": "button", "function": self.on_bless_root_vol, "description": [ @@ -1309,7 +1309,7 @@ Hardware Information: from resources.sys_patch.sys_patch import PatchSysVolume #Don't need to pass model as we're bypassing all logic if PatchSysVolume("",self.constants)._mount_root_vol() == True: - wx.MessageDialog(self.parent, "Root Volume Mounted, remember to fix permissions before blessing ๐Ÿ™", "Success", wx.OK | wx.ICON_INFORMATION).ShowModal() + wx.MessageDialog(self.parent, "Root Volume Mounted, remember to fix permissions before saving the Root Volume", "Success", wx.OK | wx.ICON_INFORMATION).ShowModal() else: wx.MessageDialog(self.parent, "Root Volume Mount Failed, check terminal output", "Error", wx.OK | wx.ICON_ERROR).ShowModal() @@ -1321,7 +1321,7 @@ Hardware Information: #Don't need to pass model as we're bypassing all logic if PatchSysVolume("",self.constants)._rebuild_kernel_collection() == True: if PatchSysVolume("",self.constants)._create_new_apfs_snapshot() == True: - wx.MessageDialog(self.parent, "Root Volume Updated, please reboot to apply changes", "Success", wx.OK | wx.ICON_INFORMATION).ShowModal() + wx.MessageDialog(self.parent, "Root Volume saved, please reboot to apply changes", "Success", wx.OK | wx.ICON_INFORMATION).ShowModal() else: wx.MessageDialog(self.parent, "Root Volume Bless Failed, check terminal output", "Error", wx.OK | wx.ICON_ERROR).ShowModal() else: From 3ff6f6823671c04fff3f3030255d61703d0a8b81 Mon Sep 17 00:00:00 2001 From: Jazzzny Date: Fri, 28 Jul 2023 21:14:25 -0400 Subject: [PATCH 3/6] Update --- resources/wx_gui/gui_settings.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/resources/wx_gui/gui_settings.py b/resources/wx_gui/gui_settings.py index 18479d581..5f51c22ac 100644 --- a/resources/wx_gui/gui_settings.py +++ b/resources/wx_gui/gui_settings.py @@ -1319,10 +1319,7 @@ Hardware Information: else: from resources.sys_patch.sys_patch import PatchSysVolume #Don't need to pass model as we're bypassing all logic - if PatchSysVolume("",self.constants)._rebuild_kernel_collection() == True: - if PatchSysVolume("",self.constants)._create_new_apfs_snapshot() == True: - wx.MessageDialog(self.parent, "Root Volume saved, please reboot to apply changes", "Success", wx.OK | wx.ICON_INFORMATION).ShowModal() - else: - wx.MessageDialog(self.parent, "Root Volume Bless Failed, check terminal output", "Error", wx.OK | wx.ICON_ERROR).ShowModal() + if PatchSysVolume("",self.constants)._rebuild_root_volume() == True: + wx.MessageDialog(self.parent, "Root Volume saved, please reboot to apply changes", "Success", wx.OK | wx.ICON_INFORMATION).ShowModal() else: - wx.MessageDialog(self.parent, "KC Update Failed, check terminal output", "Error", wx.OK | wx.ICON_ERROR).ShowModal() \ No newline at end of file + wx.MessageDialog(self.parent, "Root Volume update Failed, check terminal output", "Error", wx.OK | wx.ICON_ERROR).ShowModal() \ No newline at end of file From d2312e3cce17aa0c41d324b34cee0ad1d3acc5f1 Mon Sep 17 00:00:00 2001 From: Jazzzny Date: Fri, 28 Jul 2023 21:18:12 -0400 Subject: [PATCH 4/6] Add workaround for unmount --- resources/sys_patch/sys_patch.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/resources/sys_patch/sys_patch.py b/resources/sys_patch/sys_patch.py index 5e2bd4238..fd24fecea 100644 --- a/resources/sys_patch/sys_patch.py +++ b/resources/sys_patch/sys_patch.py @@ -417,9 +417,11 @@ class PatchSysVolume: """ Unmount root volume """ - - logging.info("- Unmounting Root Volume (Don't worry if this fails)") - utilities.elevated(["diskutil", "unmount", self.root_mount_path], stdout=subprocess.PIPE).stdout.decode().strip().encode() + if self.root_mount_path: + logging.info("- Unmounting Root Volume (Don't worry if this fails)") + utilities.elevated(["diskutil", "unmount", self.root_mount_path], stdout=subprocess.PIPE).stdout.decode().strip().encode() + else: + logging.info("- Skipping Root Volume unmount") def _rebuild_dyld_shared_cache(self) -> None: From 2455cb1233810db6efadd951247d7abc5d7eae12 Mon Sep 17 00:00:00 2001 From: Jazzzny Date: Fri, 28 Jul 2023 21:23:20 -0400 Subject: [PATCH 5/6] Update imports --- resources/wx_gui/gui_settings.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/wx_gui/gui_settings.py b/resources/wx_gui/gui_settings.py index 5f51c22ac..8bf15fa16 100644 --- a/resources/wx_gui/gui_settings.py +++ b/resources/wx_gui/gui_settings.py @@ -7,6 +7,7 @@ import subprocess import os from pathlib import Path +from resources.sys_patch.sys_patch import PatchSysVolume from resources.wx_gui import ( gui_support, @@ -1306,7 +1307,6 @@ Hardware Information: if os.geteuid() != 0: wx.MessageDialog(self.parent, "Please relaunch as Root to mount the Root Volume", "Error", wx.OK | wx.ICON_ERROR).ShowModal() else: - from resources.sys_patch.sys_patch import PatchSysVolume #Don't need to pass model as we're bypassing all logic if PatchSysVolume("",self.constants)._mount_root_vol() == True: wx.MessageDialog(self.parent, "Root Volume Mounted, remember to fix permissions before saving the Root Volume", "Success", wx.OK | wx.ICON_INFORMATION).ShowModal() @@ -1317,7 +1317,6 @@ Hardware Information: if os.geteuid() != 0: wx.MessageDialog(self.parent, "Please relaunch as Root to save changes", "Error", wx.OK | wx.ICON_ERROR).ShowModal() else: - from resources.sys_patch.sys_patch import PatchSysVolume #Don't need to pass model as we're bypassing all logic if PatchSysVolume("",self.constants)._rebuild_root_volume() == True: wx.MessageDialog(self.parent, "Root Volume saved, please reboot to apply changes", "Success", wx.OK | wx.ICON_INFORMATION).ShowModal() From d6161481efd0dab7d8208e65217d45825bb0e876 Mon Sep 17 00:00:00 2001 From: Jazzzny Date: Fri, 28 Jul 2023 21:26:28 -0400 Subject: [PATCH 6/6] Add returns to comply with comment --- resources/sys_patch/sys_patch.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/sys_patch/sys_patch.py b/resources/sys_patch/sys_patch.py index fd24fecea..4f7741aa0 100644 --- a/resources/sys_patch/sys_patch.py +++ b/resources/sys_patch/sys_patch.py @@ -279,6 +279,8 @@ class PatchSysVolume: if self.needs_kmutil_exemptions is True: logging.info("Note: Apple will require you to open System Preferences -> Security to allow the new kernel extensions to be loaded") self.constants.root_patcher_succeeded = True + return True + return False def _rebuild_kernel_collection(self) -> bool: