Skip to content

Commit

Permalink
Fail with an error if creating /var/jb fails
Browse files Browse the repository at this point in the history
  • Loading branch information
opa334 committed Feb 20, 2024
1 parent cc081ee commit b6ed9ed
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Application/Dopamine/Jailbreak/DOBootstrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,17 @@ - (BOOL)fileOrSymlinkExistsAtPath:(NSString *)path
return NO;
}

- (BOOL)createSymlinkAtPath:(NSString *)path toPath:(NSString *)destinationPath createIntermediateDirectories:(BOOL)createIntermediate
- (NSError *)createSymlinkAtPath:(NSString *)path toPath:(NSString *)destinationPath createIntermediateDirectories:(BOOL)createIntermediate
{
NSError *error;
NSString *parentPath = [path stringByDeletingLastPathComponent];
if (![[NSFileManager defaultManager] fileExistsAtPath:parentPath]) {
if (!createIntermediate) return NO;
if (![[NSFileManager defaultManager] createDirectoryAtPath:parentPath withIntermediateDirectories:YES attributes:nil error:nil]) return NO;
if (!createIntermediate) return [NSError errorWithDomain:bootstrapErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : [NSString stringWithFormat:@"Failed create %@->%@ symlink: Parent dir does not exists", path, destinationPath]}];
if (![[NSFileManager defaultManager] createDirectoryAtPath:parentPath withIntermediateDirectories:YES attributes:nil error:&error]) return error;
}

return [[NSFileManager defaultManager] createSymbolicLinkAtPath:path withDestinationPath:destinationPath error:nil];
[[NSFileManager defaultManager] createSymbolicLinkAtPath:path withDestinationPath:destinationPath error:&error];
return error;
}

- (BOOL)isPrivatePrebootMountedWritable
Expand Down Expand Up @@ -444,7 +446,11 @@ - (void)prepareBootstrapWithCompletion:(void (^)(NSError *))completion

NSString *basebinPath = NSJBRootPath(@"/basebin");
NSString *installedPath = NSJBRootPath(@"/.installed_dopamine");
[self createSymlinkAtPath:@"/var/jb" toPath:NSJBRootPath(@"/") createIntermediateDirectories:YES];
error = [self createSymlinkAtPath:@"/var/jb" toPath:NSJBRootPath(@"/") createIntermediateDirectories:YES];
if (error) {
completion(error);
return;
}

if ([[NSFileManager defaultManager] fileExistsAtPath:basebinPath]) {
if (![[NSFileManager defaultManager] removeItemAtPath:basebinPath error:&error]) {
Expand Down

0 comments on commit b6ed9ed

Please sign in to comment.