depricate old FileToRestore

This commit is contained in:
leminlimez
2024-09-27 23:21:08 -04:00
parent 69169b9512
commit 6c1f9a566d
4 changed files with 13 additions and 31 deletions

View File

@@ -3,19 +3,9 @@ from pymobiledevice3.lockdown import LockdownClient
import os import os
class FileToRestore: class FileToRestore:
# TODO: Depricate this in favor of second init definition
def __init__(self, contents: str, restore_path: str, restore_name: str, owner: int = 501, group: int = 501):
self.contents = contents
self.restore_path = restore_path
self.restore_name = restore_name
self.owner = owner
self.group = group
def __init__(self, contents: str, restore_path: str, owner: int = 501, group: int = 501): def __init__(self, contents: str, restore_path: str, owner: int = 501, group: int = 501):
self.contents = contents self.contents = contents
path, file = os.path.split(restore_path) self.restore_path = restore_path
self.restore_path = path + "/"
self.restore_name = file # TODO: Remove this and handle splitting in the restore_files function
self.owner = owner self.owner = owner
self.group = group self.group = group
@@ -52,7 +42,8 @@ def restore_files(files: list, reboot: bool = False, lockdown_client: LockdownCl
elif file.restore_path.startswith("/private/var/"): elif file.restore_path.startswith("/private/var/"):
base_path = "/private/var/backup" base_path = "/private/var/backup"
# don't append the directory if it has already been added (restore will fail) # don't append the directory if it has already been added (restore will fail)
domain_path = f"SysContainerDomain-../../../../../../../..{base_path}{file.restore_path}" path, name = os.path.split(file.restore_path)
domain_path = f"SysContainerDomain-../../../../../../../..{base_path}{path}"
if last_domain != domain_path: if last_domain != domain_path:
files_list.append(backup.Directory( files_list.append(backup.Directory(
"", "",
@@ -63,7 +54,7 @@ def restore_files(files: list, reboot: bool = False, lockdown_client: LockdownCl
last_domain = domain_path last_domain = domain_path
files_list.append(backup.ConcreteFile( files_list.append(backup.ConcreteFile(
"", "",
f"{domain_path}{file.restore_name}", f"{domain_path}{name}",
owner=file.owner, owner=file.owner,
group=file.group, group=file.group,
contents=b"", contents=b"",

View File

@@ -135,13 +135,11 @@ while running:
files_to_restore = [ files_to_restore = [
FileToRestore( FileToRestore(
contents=plistlib.dumps(gestalt_plist), contents=plistlib.dumps(gestalt_plist),
restore_path="/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/", restore_path="/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/com.apple.MobileGestalt.plist",
restore_name="com.apple.MobileGestalt.plist"
), ),
FileToRestore( FileToRestore(
contents=plistlib.dumps(flag_plist), contents=plistlib.dumps(flag_plist),
restore_path="/var/preferences/FeatureFlags/", restore_path="/var/preferences/FeatureFlags/Global.plist",
restore_name="Global.plist"
) )
] ]
if eligibility_files != None: if eligibility_files != None:
@@ -175,8 +173,7 @@ while running:
try: try:
restore_files(files=[FileToRestore( restore_files(files=[FileToRestore(
contents=b"", contents=b"",
restore_path="/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/", restore_path="/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/com.apple.MobileGestalt.plist",
restore_name="com.apple.MobileGestalt.plist"
)], reboot=True, lockdown_client=device.ld) )], reboot=True, lockdown_client=device.ld)
except Exception as e: except Exception as e:
print(traceback.format_exc()) print(traceback.format_exc())

View File

@@ -143,15 +143,13 @@ class DeviceManager:
files_to_restore = [ files_to_restore = [
FileToRestore( FileToRestore(
contents=plistlib.dumps(flag_plist), contents=plistlib.dumps(flag_plist),
restore_path="/var/preferences/FeatureFlags/", restore_path="/var/preferences/FeatureFlags/Global.plist",
restore_name="Global.plist"
) )
] ]
if gestalt_data != None: if gestalt_data != None:
files_to_restore.append(FileToRestore( files_to_restore.append(FileToRestore(
contents=gestalt_data, contents=gestalt_data,
restore_path="/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/", restore_path="/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/com.apple.MobileGestalt.plist",
restore_name="com.apple.MobileGestalt.plist"
)) ))
if eligibility_files: if eligibility_files:
files_to_restore += eligibility_files files_to_restore += eligibility_files
@@ -197,8 +195,7 @@ class DeviceManager:
try: try:
restore_files(files=[FileToRestore( restore_files(files=[FileToRestore(
contents=b"", contents=b"",
restore_path="/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/", restore_path="/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/com.apple.MobileGestalt.plist",
restore_name="com.apple.MobileGestalt.plist"
)], reboot=True, lockdown_client=self.data_singleton.current_device.ld) )], reboot=True, lockdown_client=self.data_singleton.current_device.ld)
QMessageBox.information(None, "Success!", "All done! Your device will now restart.") QMessageBox.information(None, "Success!", "All done! Your device will now restart.")
update_label("Success!") update_label("Success!")

View File

@@ -62,8 +62,7 @@ class EligibilityTweak(Tweak):
files_to_restore = [ files_to_restore = [
FileToRestore( FileToRestore(
contents=eligibility_data, contents=eligibility_data,
restore_path="/var/db/os_eligibility/", restore_path="/var/db/os_eligibility/eligibility.plist",
restore_name="eligibility.plist"
) )
] ]
@@ -74,16 +73,14 @@ class EligibilityTweak(Tweak):
files_to_restore.append( files_to_restore.append(
FileToRestore( FileToRestore(
contents=config_data, contents=config_data,
restore_path="/var/MobileAsset/AssetsV2/com_apple_MobileAsset_OSEligibility/purpose_auto/c55a421c053e10233e5bfc15c42fa6230e5639a9.asset/AssetData/", restore_path="/var/MobileAsset/AssetsV2/com_apple_MobileAsset_OSEligibility/purpose_auto/c55a421c053e10233e5bfc15c42fa6230e5639a9.asset/AssetData/Config.plist",
restore_name="Config.plist"
) )
) )
elif self.method == 1: elif self.method == 1:
files_to_restore.append( files_to_restore.append(
FileToRestore( FileToRestore(
contents=config_data, contents=config_data,
restore_path="/var/MobileAsset/AssetsV2/com_apple_MobileAsset_OSEligibility/purpose_auto/247556c634fc4cc4fd742f1b33af9abf194a986e.asset/AssetData/", restore_path="/var/MobileAsset/AssetsV2/com_apple_MobileAsset_OSEligibility/purpose_auto/247556c634fc4cc4fd742f1b33af9abf194a986e.asset/AssetData/Config.plist",
restore_name="Config.plist"
) )
) )