Remove legacy _fix_file_permission()

Required for when OCLP would run as root
This commit is contained in:
Mykola Grymalyuk
2024-05-27 17:15:00 -06:00
parent 8fb2ee4b83
commit c645f57572
2 changed files with 1 additions and 38 deletions

View File

@@ -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)
logging.error(e)

View File

@@ -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