From c645f575720bd6d7a04356d754356c20b5b77b41 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Mon, 27 May 2024 17:15:00 -0600 Subject: [PATCH] Remove legacy _fix_file_permission() Required for when OCLP would run as root --- .../support/global_settings.py | 18 +--------------- .../support/logging_handler.py | 21 ------------------- 2 files changed, 1 insertion(+), 38 deletions(-) diff --git a/opencore_legacy_patcher/support/global_settings.py b/opencore_legacy_patcher/support/global_settings.py index f02ff9b6a..a50bfe8dd 100644 --- a/opencore_legacy_patcher/support/global_settings.py +++ b/opencore_legacy_patcher/support/global_settings.py @@ -28,7 +28,6 @@ class GlobalEnviromentSettings: self._generate_settings_file() self._convert_defaults_to_global_settings() - self._fix_file_permission() def read_property(self, property_name: str) -> str: @@ -105,19 +104,4 @@ class GlobalEnviromentSettings: Path(defaults_path).unlink() except Exception as e: logging.error("Error: Unable to delete defaults plist") - logging.error(e) - - - def _fix_file_permission(self) -> None: - """ - Fixes file permission for log file - - If OCLP was invoked as root, file permission will only allow root to write to settings file - This in turn breaks normal OCLP execution to write to settings file - """ - - # Set file permission to allow any user to write to log file - result = subprocess_wrapper.run_as_root(["/bin/chmod", "777", self.global_settings_plist], capture_output=True) - if result.returncode != 0: - logging.warning("Failed to fix settings file permissions:") - subprocess_wrapper.log(result) \ No newline at end of file + logging.error(e) \ No newline at end of file diff --git a/opencore_legacy_patcher/support/logging_handler.py b/opencore_legacy_patcher/support/logging_handler.py index 70202309e..db9d1f6e8 100644 --- a/opencore_legacy_patcher/support/logging_handler.py +++ b/opencore_legacy_patcher/support/logging_handler.py @@ -61,7 +61,6 @@ class InitializeLoggingSupport: self._attempt_initialize_logging_configuration() self._start_logging() self._implement_custom_traceback_handler() - self._fix_file_permission() self._clean_prior_version_logs() @@ -123,26 +122,6 @@ class InitializeLoggingSupport: logging.error(f"Failed to delete log file: {e}") - def _fix_file_permission(self) -> None: - """ - Fixes file permission for log file - - If OCLP was invoked as root, file permission will only allow root to write to log file - This in turn breaks normal OCLP execution to write to log file - """ - - paths = [ - self.log_filepath, # ~/Library/Logs/Dortania/OpenCore-Patcher_{version}_{date}.log - self.log_filepath.parent, # ~/Library/Logs/Dortania - ] - - for path in paths: - result = subprocess_wrapper.run_as_root(["/bin/chmod", "777", path], capture_output=True) - if result.returncode != 0: - logging.error(f"Failed to fix log file permissions") - subprocess_wrapper.log(result) - - def _initialize_logging_configuration(self, log_to_file: bool = True) -> None: """ Initialize logging framework configuration