From 43c03c167ccaa23ca51f268213e5abc85a9aee55 Mon Sep 17 00:00:00 2001 From: opa334 Date: Thu, 20 Jun 2024 02:10:29 +0200 Subject: [PATCH] Log improvements, error handling improvements --- .../Dopamine/Jailbreak/DOEnvironmentManager.h | 2 +- .../Dopamine/Jailbreak/DOEnvironmentManager.m | 14 ++++++++++---- Application/Dopamine/Jailbreak/DOJailbreaker.m | 9 ++++++++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Application/Dopamine/Jailbreak/DOEnvironmentManager.h b/Application/Dopamine/Jailbreak/DOEnvironmentManager.h index 930ac084f..4ed725b85 100644 --- a/Application/Dopamine/Jailbreak/DOEnvironmentManager.h +++ b/Application/Dopamine/Jailbreak/DOEnvironmentManager.h @@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN - (NSString *)versionSupportString; - (NSString *)accessibleKernelPath; - (void)locateJailbreakRoot; -- (void)ensureJailbreakRootExists; +- (NSError *)ensureJailbreakRootExists; - (void)runUnsandboxed:(void (^)(void))unsandboxBlock; diff --git a/Application/Dopamine/Jailbreak/DOEnvironmentManager.m b/Application/Dopamine/Jailbreak/DOEnvironmentManager.m index 6516d2c93..91df51d03 100644 --- a/Application/Dopamine/Jailbreak/DOEnvironmentManager.m +++ b/Application/Dopamine/Jailbreak/DOEnvironmentManager.m @@ -148,8 +148,10 @@ - (void)locateJailbreakRoot } } -- (void)ensureJailbreakRootExists +- (NSError *)ensureJailbreakRootExists { + NSError *error = nil; + [self locateJailbreakRoot]; if (!gSystemInfo.jailbreakInfo.rootPath || _bootstrapNeedsMigration) { @@ -172,16 +174,20 @@ - (void)ensureJailbreakRootExists if (_bootstrapNeedsMigration) { NSString *oldRandomizedJailbreakPath = [[NSString stringWithUTF8String:gSystemInfo.jailbreakInfo.rootPath] stringByDeletingLastPathComponent]; - [[NSFileManager defaultManager] moveItemAtPath:oldRandomizedJailbreakPath toPath:randomizedJailbreakPath error:nil]; + [[NSFileManager defaultManager] moveItemAtPath:oldRandomizedJailbreakPath toPath:randomizedJailbreakPath error:&error]; } else { if (![[NSFileManager defaultManager] fileExistsAtPath:jailbreakRootPath]) { - [[NSFileManager defaultManager] createDirectoryAtPath:jailbreakRootPath withIntermediateDirectories:YES attributes:nil error:nil]; + [[NSFileManager defaultManager] createDirectoryAtPath:jailbreakRootPath withIntermediateDirectories:YES attributes:nil error:&error]; } } - gSystemInfo.jailbreakInfo.rootPath = strdup(jailbreakRootPath.UTF8String); + if (!error) { + gSystemInfo.jailbreakInfo.rootPath = strdup(jailbreakRootPath.UTF8String); + } } + + return error; } - (BOOL)isArm64e diff --git a/Application/Dopamine/Jailbreak/DOJailbreaker.m b/Application/Dopamine/Jailbreak/DOJailbreaker.m index 5d7c2bd1e..78b0f1104 100644 --- a/Application/Dopamine/Jailbreak/DOJailbreaker.m +++ b/Application/Dopamine/Jailbreak/DOJailbreaker.m @@ -29,6 +29,7 @@ #import #import #import +#import #import "spawn.h" int posix_spawnattr_set_registered_ports_np(posix_spawnattr_t * __restrict attr, mach_port_t portarray[], uint32_t count); @@ -477,6 +478,11 @@ - (void)runWithError:(NSError **)errOut didRemoveJailbreak:(BOOL*)didRemove show BOOL idownloadEnabled = [[DOPreferenceManager sharedManager] boolPreferenceValueForKey:@"idownloadEnabled" fallback:NO]; BOOL appJITEnabled = [[DOPreferenceManager sharedManager] boolPreferenceValueForKey:@"appJITEnabled" fallback:YES]; + struct utsname systemInfo; + uname(&systemInfo); + NSString *startLog = [NSString stringWithFormat:@"Starting Jailbreak (Model: %s, %@, Configuration: {removeJailbreak=%d, tweakInjection=%d, idownload=%d, appJIT=%d})", systemInfo.machine, NSProcessInfo.processInfo.operatingSystemVersionString, removeJailbreakEnabled, tweaksEnabled, idownloadEnabled, appJITEnabled]; + [[DOUIManager sharedInstance] sendLog:startLog debug:YES]; + *errOut = [self gatherSystemInformation]; if (*errOut) return; *errOut = [self doExploitation]; @@ -503,7 +509,8 @@ - (void)runWithError:(NSError **)errOut didRemoveJailbreak:(BOOL*)didRemove show if (*errOut) return; // Now that we are unsandboxed, populate the jailbreak root path - [[DOEnvironmentManager sharedManager] ensureJailbreakRootExists]; + *errOut = [[DOEnvironmentManager sharedManager] ensureJailbreakRootExists]; + if (*errOut) return; if (removeJailbreakEnabled) { [[DOUIManager sharedInstance] sendLog:DOLocalizedString(@"Removing Jailbreak") debug:NO];