fix domain conversion for patched versions

This commit is contained in:
leminlimez
2024-11-11 17:00:57 -05:00
parent bc61a0dffa
commit 90c74c6b5a

View File

@@ -230,7 +230,13 @@ class DeviceManager:
domain="ManagedPreferencesDomain" domain="ManagedPreferencesDomain"
)) ))
def get_domain_for_path(self, path: str) -> str: def get_domain_for_path(self, path: str, fully_patched: bool = False) -> str:
# just make the Sys Containers to use the regular way (won't work for mga)
sysSharedContainer = "SysSharedContainerDomain-"
sysContainer = "SysContainerDomain-"
if not fully_patched:
sysSharedContainer += "."
sysContainer += "."
mappings: dict = { mappings: dict = {
"/var/Managed Preferences/": "ManagedPreferencesDomain", "/var/Managed Preferences/": "ManagedPreferencesDomain",
"/var/root/": "RootDomain", "/var/root/": "RootDomain",
@@ -238,13 +244,19 @@ class DeviceManager:
"/var/MobileDevice/": "MobileDeviceDomain", "/var/MobileDevice/": "MobileDeviceDomain",
"/var/mobile/": "HomeDomain", "/var/mobile/": "HomeDomain",
"/var/db/": "DatabaseDomain", "/var/db/": "DatabaseDomain",
"/var/containers/Shared/SystemGroup/": "SysSharedContainerDomain-.", "/var/containers/Shared/SystemGroup/": sysSharedContainer,
"/var/containers/Data/SystemGroup/": "SysContainerDomain-." "/var/containers/Data/SystemGroup/": sysContainer
} }
for mapping in mappings.keys(): for mapping in mappings.keys():
if path.startswith(mapping): if path.startswith(mapping):
new_path = path.replace(mapping, "") new_path = path.replace(mapping, "")
return mappings[mapping], new_path new_domain = mappings[mapping]
# if patched, include the next part of the path in the domain
if fully_patched and (new_domain == sysSharedContainer or new_domain == sysContainer):
parts = new_path.split("/")
new_domain += parts[0]
new_path = new_path.replace(parts[0] + "/", "")
return new_domain, new_path
return None, path return None, path
def concat_file(self, contents: str, path: str, files_to_restore: list[FileToRestore]): def concat_file(self, contents: str, path: str, files_to_restore: list[FileToRestore]):
@@ -254,7 +266,7 @@ class DeviceManager:
restore_path=path restore_path=path
)) ))
else: else:
domain, file_path = self.get_domain_for_path(path) domain, file_path = self.get_domain_for_path(path, fully_patched=self.get_current_device_patched())
files_to_restore.append(FileToRestore( files_to_restore.append(FileToRestore(
contents=contents, contents=contents,
restore_path=file_path, restore_path=file_path,
@@ -374,7 +386,9 @@ class DeviceManager:
settings.setValue(self.data_singleton.current_device.uuid + "_model", "") settings.setValue(self.data_singleton.current_device.uuid + "_model", "")
settings.setValue(self.data_singleton.current_device.uuid + "_hardware", "") settings.setValue(self.data_singleton.current_device.uuid + "_hardware", "")
settings.setValue(self.data_singleton.current_device.uuid + "_cpu", "") settings.setValue(self.data_singleton.current_device.uuid + "_cpu", "")
domain, file_path = self.get_domain_for_path("/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/com.apple.MobileGestalt.plist") domain, file_path = self.get_domain_for_path(
"/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/com.apple.MobileGestalt.plist",
fully_patched=self.get_current_device_patched())
restore_files(files=[FileToRestore( restore_files(files=[FileToRestore(
contents=b"", contents=b"",
restore_path=file_path, restore_path=file_path,