diff --git a/resources/sys_patch/sys_patch_auto.py b/resources/sys_patch/sys_patch_auto.py index 11bc8b585..7bea39299 100644 --- a/resources/sys_patch/sys_patch_auto.py +++ b/resources/sys_patch/sys_patch_auto.py @@ -81,32 +81,39 @@ class AutomaticSysPatch: if patches[patch] is True and not patch.startswith("Settings") and not patch.startswith("Validation"): patch_string += f"- {patch}\n" + logging.info("- No new binaries found on Github, proceeding with patching") logging.info("- No new binaries found on Github, proceeding with patching") if self.constants.launcher_script is None: - args = [self.constants.launcher_binary, "--gui_patch"] + args_string = f"'{self.constants.launcher_binary}' --gui_patch" else: - args = [self.constants.launcher_binary, self.constants.launcher_script, "--gui_patch"] + args_string = f"{self.constants.launcher_binary} {self.constants.launcher_script} --gui_patch" warning_str = "" if network_handler.NetworkUtilities("https://api.github.com/repos/dortania/OpenCore-Legacy-Patcher/releases/latest").verify_network_connection() is False: warning_str = f"""\n\nWARNING: We're unable to verify whether there are any new releases of OpenCore Legacy Patcher on Github. Be aware that you may be using an outdated version for this OS. If you're unsure, verify on Github that OpenCore Legacy Patcher {self.constants.patcher_version} is the latest official release""" + args = [ + "osascript", + "-e", + f"""display dialog "OpenCore Legacy Patcher has detected you're running without Root Patches, and would like to install them.\n\nmacOS wipes all root patches during OS installs and updates, so they need to be reinstalled.\n\nFollowing Patches have been detected for your system: \n{patch_string}\nWould you like to apply these patches?{warning_str}" """ + f'with icon POSIX file "{self.constants.app_icon_path}"', + ] output = subprocess.run( - [ - "osascript", - "-e", - f"""display dialog "OpenCore Legacy Patcher has detected you're running without Root Patches, and would like to install them.\n\nmacOS wipes all root patches during OS installs and updates, so they need to be reinstalled.\n\nFollowing Patches have been detected for your system: \n{patch_string}\nWould you like to apply these patches?{warning_str}" """ - f'with icon POSIX file "{self.constants.app_icon_path}"', - ], + args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) if output.returncode == 0: + args = [ + "osascript", + "-e", + f'''do shell script "{args_string}"''' + f' with prompt "OpenCore Legacy Patcher would like to patch your root volume"' + " with administrator privileges" + " without altering line endings" + ] subprocess.run( - [ - self.constants.oclp_helper_path, - *args - ], + args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) diff --git a/resources/wx_gui/gui_support.py b/resources/wx_gui/gui_support.py index 9b6e54929..863ad52a3 100644 --- a/resources/wx_gui/gui_support.py +++ b/resources/wx_gui/gui_support.py @@ -217,22 +217,32 @@ class RelaunchApplicationAsRoot: return timer: int = 5 - program_arguments: list = [] + program_arguments: str = "" if event: if event.GetEventObject() != wx.Menu: try: if event.GetEventObject().GetLabel() in ["Start Root Patching", "Reinstall Root Patches"]: - program_arguments += ["--gui_patch"] + program_arguments = " --gui_patch" elif event.GetEventObject().GetLabel() == "Revert Root Patches": - program_arguments += ["--gui_unpatch"] + program_arguments = " --gui_unpatch" except TypeError: pass if self.constants.launcher_script is None: - program_arguments = [self.constants.launcher_binary] + program_arguments + program_arguments = f"'{self.constants.launcher_binary}'{program_arguments}" else: - program_arguments = [self.constants.launcher_binary, self.constants.launcher_script] + program_arguments + program_arguments = f"{self.constants.launcher_binary} {self.constants.launcher_script}{program_arguments}" + + # Relaunch as root + args = [ + "osascript", + "-e", + f'''do shell script "{program_arguments}"''' + ' with prompt "OpenCore Legacy Patcher needs administrator privileges to relaunch as admin."' + " with administrator privileges" + " without altering line endings", + ] self.frame.DestroyChildren() self.frame.SetSize(400, 300) @@ -253,7 +263,7 @@ class RelaunchApplicationAsRoot: wx.GetApp().Yield() logging.info(f"- Relaunching as root with command: {program_arguments}") - subprocess.Popen([self.constants.oclp_helper_path, *program_arguments], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) while True: wx.GetApp().Yield()