Skip to content

Commit

Permalink
Log improvements, error handling improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
opa334 committed Jun 20, 2024
1 parent cdded6d commit 43c03c1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Application/Dopamine/Jailbreak/DOEnvironmentManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSString *)versionSupportString;
- (NSString *)accessibleKernelPath;
- (void)locateJailbreakRoot;
- (void)ensureJailbreakRootExists;
- (NSError *)ensureJailbreakRootExists;


- (void)runUnsandboxed:(void (^)(void))unsandboxBlock;
Expand Down
14 changes: 10 additions & 4 deletions Application/Dopamine/Jailbreak/DOEnvironmentManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@ - (void)locateJailbreakRoot
}
}

- (void)ensureJailbreakRootExists
- (NSError *)ensureJailbreakRootExists
{
NSError *error = nil;

[self locateJailbreakRoot];

if (!gSystemInfo.jailbreakInfo.rootPath || _bootstrapNeedsMigration) {
Expand All @@ -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
Expand Down
9 changes: 8 additions & 1 deletion Application/Dopamine/Jailbreak/DOJailbreaker.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#import <libjailbreak/jbclient_xpc.h>
#import <libjailbreak/kcall_arm64.h>
#import <CoreServices/LSApplicationProxy.h>
#import <sys/utsname.h>
#import "spawn.h"
int posix_spawnattr_set_registered_ports_np(posix_spawnattr_t * __restrict attr, mach_port_t portarray[], uint32_t count);

Expand Down Expand Up @@ -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];
Expand All @@ -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];
Expand Down

0 comments on commit 43c03c1

Please sign in to comment.