diff --git a/.gitignore b/.gitignore index 67d83a5b..5dc5aef1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ packages/ *.xcuserstate /Bootstrap.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate *.xcuserstate +.vscode/ + diff --git a/Bootstrap.xcodeproj/project.pbxproj b/Bootstrap.xcodeproj/project.pbxproj index 619cebe6..0fd9e1d5 100644 --- a/Bootstrap.xcodeproj/project.pbxproj +++ b/Bootstrap.xcodeproj/project.pbxproj @@ -571,7 +571,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.3; + MARKETING_VERSION = 1.3.1; OTHER_LDFLAGS = ""; PRODUCT_BUNDLE_IDENTIFIER = com.roothide.Bootstrap; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -609,7 +609,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.3; + MARKETING_VERSION = 1.3.1; OTHER_LDFLAGS = ""; PRODUCT_BUNDLE_IDENTIFIER = com.roothide.Bootstrap; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Bootstrap.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate b/Bootstrap.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate index 4ee26582..316eca24 100644 Binary files a/Bootstrap.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate and b/Bootstrap.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Bootstrap/AppDelegate.m b/Bootstrap/AppDelegate.m index f300a59b..ddd73948 100644 --- a/Bootstrap/AppDelegate.m +++ b/Bootstrap/AppDelegate.m @@ -51,25 +51,22 @@ + (void)showAlert:(UIAlertController*)alert { }); dispatch_async(alertQueue, ^{ - - __block UIViewController* availableVC=nil; - while(!availableVC) { - dispatch_async(dispatch_get_main_queue(), ^{ + __block BOOL presenting = NO; + __block BOOL presented = NO; + while(!presenting) { + dispatch_sync(dispatch_get_main_queue(), ^{ UIViewController* vc = UIApplication.sharedApplication.keyWindow.rootViewController; while(vc.presentedViewController){ vc = vc.presentedViewController; - if(vc.isBeingDismissed) return; + if(vc.isBeingDismissed) { + return; + } } - availableVC = vc; + presenting = YES; + [vc presentViewController:alert animated:YES completion:^{ presented=YES; }]; }); - if(!availableVC) usleep(1000*100); + if(!presenting) usleep(1000*100); } - - __block BOOL presented = NO; - dispatch_async(dispatch_get_main_queue(), ^{ - [availableVC presentViewController:alert animated:YES completion:^{ presented=YES; }]; - }); - while(!presented) usleep(100*1000); }); } diff --git a/Bootstrap/AppEnabler.m b/Bootstrap/AppEnabler.m index c1e1c19a..719be258 100644 --- a/Bootstrap/AppEnabler.m +++ b/Bootstrap/AppEnabler.m @@ -210,7 +210,8 @@ int enableForApp(NSString* bundlePath) } } else if([appInfo[@"CFBundleIdentifier"] hasPrefix:@"com.apple."] - || [NSFileManager.defaultManager fileExistsAtPath:[bundlePath stringByAppendingString:@"/../_TrollStore"]]) + || [NSFileManager.defaultManager fileExistsAtPath:[bundlePath stringByAppendingString:@"/../_TrollStore"]] + || [NSFileManager.defaultManager fileExistsAtPath:[bundlePath stringByAppendingString:@"/../_TrollStoreLite"]]) { ASSERT(backupApp(bundlePath) == 0); @@ -257,7 +258,8 @@ int disableForApp(NSString* bundlePath) ASSERT(spawnBootstrap((char*[]){"/usr/bin/uicache","-p", rootfsPrefix(sysPath).UTF8String, NULL}, nil, nil) == 0); } else if([appInfo[@"CFBundleIdentifier"] hasPrefix:@"com.apple."] - || [NSFileManager.defaultManager fileExistsAtPath:[bundlePath stringByAppendingString:@"/../_TrollStore"]]) + || [NSFileManager.defaultManager fileExistsAtPath:[bundlePath stringByAppendingString:@"/../_TrollStore"]] + || [NSFileManager.defaultManager fileExistsAtPath:[bundlePath stringByAppendingString:@"/../_TrollStoreLite"]]) { struct stat st; diff --git a/Bootstrap/AppViewController.m b/Bootstrap/AppViewController.m index 25cde6c5..48a13198 100644 --- a/Bootstrap/AppViewController.m +++ b/Bootstrap/AppViewController.m @@ -90,35 +90,33 @@ - (void)viewDidLoad { UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; refreshControl.tintColor = [UIColor grayColor]; - [refreshControl addTarget:self action:@selector(startRefresh) forControlEvents:UIControlEventValueChanged]; + [refreshControl addTarget:self action:@selector(manualRefresh) forControlEvents:UIControlEventValueChanged]; self.tableView.refreshControl = refreshControl; [self updateData:YES]; [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(startRefresh2) + selector:@selector(autoRefresh) name:UIApplicationWillEnterForegroundNotification object:nil]; } -- (void)startRefresh { +- (void)startRefresh:(BOOL)resort { [self.tableView.refreshControl beginRefreshing]; dispatch_async(dispatch_get_global_queue(0, 0), ^{ - [self updateData:YES]; + [self updateData:resort]; dispatch_async(dispatch_get_main_queue(), ^{ [self.tableView.refreshControl endRefreshing]; }); }); } -- (void)startRefresh2 { - [self.tableView.refreshControl beginRefreshing]; - dispatch_async(dispatch_get_global_queue(0, 0), ^{ - [self updateData:NO]; - dispatch_async(dispatch_get_main_queue(), ^{ - [self.tableView.refreshControl endRefreshing]; - }); - }); +- (void)manualRefresh { + [self startRefresh:YES]; +} + +- (void)autoRefresh { + [self startRefresh:NO]; } - (void)viewWillAppear:(BOOL)animated { diff --git a/Bootstrap/ViewController.m b/Bootstrap/ViewController.m index aef6def3..02d2f2bc 100644 --- a/Bootstrap/ViewController.m +++ b/Bootstrap/ViewController.m @@ -438,25 +438,34 @@ void bootstrapAction() UIImpactFeedbackGenerator* generator = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleSoft]; [generator impactOccurred]; - int count=0; - NSArray *subItems = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@"/var/containers/Bundle/Application/" error:nil]; - for (NSString *subItem in subItems) { - if (is_jbroot_name(subItem.UTF8String)) - count++; + int installedCount=0; + NSString* dirpath = @"/var/containers/Bundle/Application/"; + NSArray *subItems = [NSFileManager.defaultManager contentsOfDirectoryAtPath:dirpath error:nil]; + for (NSString *subItem in subItems) + { + if (!is_jbroot_name(subItem.UTF8String)) continue; + + NSString* jbroot_path = [dirpath stringByAppendingPathComponent:subItem]; + + if([NSFileManager.defaultManager fileExistsAtPath:[jbroot_path stringByAppendingPathComponent:@"/.installed_dopamine"]]) { + [AppDelegate showMesage:Localized(@"roothide dopamine has been installed on this device, now install this bootstrap may break it!") title:Localized(@"Error")]; + return; + } + + if([NSFileManager.defaultManager fileExistsAtPath:[jbroot_path stringByAppendingPathComponent:@"/.bootstrapped"]] + || [NSFileManager.defaultManager fileExistsAtPath:[jbroot_path stringByAppendingPathComponent:@"/.thebootstrapped"]]) { + installedCount++; + continue; + } } - if(count > 1) { + if(installedCount > 1) { [AppDelegate showMesage:Localized(@"There are multi jbroot in /var/containers/Bundle/Applicaton/") title:Localized(@"Error")]; return; } if(find_jbroot(YES)) //make sure jbroot() function available { - if([NSFileManager.defaultManager fileExistsAtPath:jbroot(@"/.installed_dopamine")]) { - [AppDelegate showMesage:Localized(@"roothide dopamine has been installed on this device, now install this bootstrap may break it!") title:Localized(@"Error")]; - return; - } - //check beta version if([NSFileManager.defaultManager fileExistsAtPath:jbroot(@"/.bootstrapped")]) { NSString* strappedVersion = [NSString stringWithContentsOfFile:jbroot(@"/.bootstrapped") encoding:NSUTF8StringEncoding error:nil]; diff --git a/Bootstrap/basebin/bootstrap.dylib b/Bootstrap/basebin/bootstrap.dylib index cec064cb..b60bdb9e 100755 Binary files a/Bootstrap/basebin/bootstrap.dylib and b/Bootstrap/basebin/bootstrap.dylib differ diff --git a/Bootstrap/basebin/bootstrapd b/Bootstrap/basebin/bootstrapd index acda7312..8af59a3e 100755 Binary files a/Bootstrap/basebin/bootstrapd and b/Bootstrap/basebin/bootstrapd differ diff --git a/Bootstrap/basebin/devtest b/Bootstrap/basebin/devtest index f298eefe..e02f44be 100755 Binary files a/Bootstrap/basebin/devtest and b/Bootstrap/basebin/devtest differ diff --git a/Bootstrap/basebin/entitlements/com.apple.mobilemail.extra b/Bootstrap/basebin/entitlements/com.apple.mobilemail.extra index 9ec7336a..531a5fff 100644 --- a/Bootstrap/basebin/entitlements/com.apple.mobilemail.extra +++ b/Bootstrap/basebin/entitlements/com.apple.mobilemail.extra @@ -7,6 +7,8 @@ get-task-allow + uicache.data-container-required + com.apple.private.security.no-sandbox com.apple.private.security.storage.AppBundles diff --git a/Bootstrap/basebin/entitlements/com.apple.mobilesafari.extra b/Bootstrap/basebin/entitlements/com.apple.mobilesafari.extra index 9ec7336a..531a5fff 100644 --- a/Bootstrap/basebin/entitlements/com.apple.mobilesafari.extra +++ b/Bootstrap/basebin/entitlements/com.apple.mobilesafari.extra @@ -7,6 +7,8 @@ get-task-allow + uicache.data-container-required + com.apple.private.security.no-sandbox com.apple.private.security.storage.AppBundles diff --git a/Bootstrap/basebin/entitlements/com.apple.mobileslideshow.extra b/Bootstrap/basebin/entitlements/com.apple.mobileslideshow.extra index fb4855de..c4b588b5 100644 --- a/Bootstrap/basebin/entitlements/com.apple.mobileslideshow.extra +++ b/Bootstrap/basebin/entitlements/com.apple.mobileslideshow.extra @@ -10,6 +10,8 @@ com.apple.private.security.no-sandbox + uicache.data-container-required + com.apple.security.exception.process-info diff --git a/Bootstrap/basebin/entitlements/com.apple.mobileslideshow.photo-picker.extra b/Bootstrap/basebin/entitlements/com.apple.mobileslideshow.photo-picker.extra index fb4855de..c4b588b5 100644 --- a/Bootstrap/basebin/entitlements/com.apple.mobileslideshow.photo-picker.extra +++ b/Bootstrap/basebin/entitlements/com.apple.mobileslideshow.photo-picker.extra @@ -10,6 +10,8 @@ com.apple.private.security.no-sandbox + uicache.data-container-required + com.apple.security.exception.process-info diff --git a/Bootstrap/basebin/fastPathSign b/Bootstrap/basebin/fastPathSign index abef44c6..4eb0c70d 100755 Binary files a/Bootstrap/basebin/fastPathSign and b/Bootstrap/basebin/fastPathSign differ diff --git a/Bootstrap/basebin/preload b/Bootstrap/basebin/preload index 0704b211..3e7738ad 100755 Binary files a/Bootstrap/basebin/preload and b/Bootstrap/basebin/preload differ diff --git a/Bootstrap/basebin/preload.dylib b/Bootstrap/basebin/preload.dylib index 14a813f0..73d56d08 100755 Binary files a/Bootstrap/basebin/preload.dylib and b/Bootstrap/basebin/preload.dylib differ diff --git a/Bootstrap/basebin/rebuildapp b/Bootstrap/basebin/rebuildapp index 4487f907..95eaec06 100755 Binary files a/Bootstrap/basebin/rebuildapp and b/Bootstrap/basebin/rebuildapp differ diff --git a/Bootstrap/basebin/uicache b/Bootstrap/basebin/uicache index 8217c44d..c3fdd156 100755 Binary files a/Bootstrap/basebin/uicache and b/Bootstrap/basebin/uicache differ diff --git a/Bootstrap/bootstrap.m b/Bootstrap/bootstrap.m index 7086fba6..83c2b7ca 100644 --- a/Bootstrap/bootstrap.m +++ b/Bootstrap/bootstrap.m @@ -196,15 +196,6 @@ int InstallBootstrap(NSString* jbroot_path) ASSERT([fm moveItemAtPath:jbroot(@"/tmp") toPath:[jbroot_secondary stringByAppendingPathComponent:@"/var/tmp"] error:nil]); ASSERT([fm createSymbolicLinkAtPath:jbroot(@"/tmp") withDestinationPath:@"var/tmp" error:nil]); - for(NSString* item in [fm contentsOfDirectoryAtPath:jbroot_path error:nil]) - { - if([item isEqualToString:@"var"]) - continue; - - ASSERT([fm createSymbolicLinkAtPath:[jbroot_secondary stringByAppendingPathComponent:item] withDestinationPath:[jbroot_path stringByAppendingPathComponent:item] error:nil]); - } - - ASSERT([fm removeItemAtPath:[jbroot_secondary stringByAppendingPathComponent:@".jbroot"] error:nil]); ASSERT([fm createSymbolicLinkAtPath:[jbroot_secondary stringByAppendingPathComponent:@".jbroot"] withDestinationPath:jbroot_path error:nil]); @@ -254,6 +245,39 @@ int InstallBootstrap(NSString* jbroot_path) return 0; } +int fixBootstrapSymlink(NSString* path) +{ + const char* jbpath = jbroot(path).fileSystemRepresentation; + + struct stat st={0}; + ASSERT(lstat(jbpath, &st) == 0); + if (!S_ISLNK(st.st_mode)) { + return 0; + } + + char link[PATH_MAX+1] = {0}; + ASSERT(readlink(jbpath, link, sizeof(link)-1) > 0); + if(link[0] != '/') { + return 0; + } + + NSString* _link = @(link).stringByStandardizingPath.stringByResolvingSymlinksInPath; + + NSString *pattern = @"^/var/containers/Bundle/Application/\\.jbroot-[0-9A-Z]{16}(/.+)$"; + NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:nil]; + NSTextCheckingResult *match = [regex firstMatchInString:_link options:0 range:NSMakeRange(0, [_link length])]; + ASSERT(match != nil); + + NSString* target = [_link substringWithRange:[match rangeAtIndex:1]]; + NSString* newlink = [@".jbroot" stringByAppendingPathComponent:target]; + + ASSERT(unlink(jbpath) == 0); + ASSERT(symlink(newlink.fileSystemRepresentation, jbpath) == 0); + ASSERT(access(jbpath, F_OK) == 0); + + return 0; +} + int ReRandomizeBootstrap() { uint64_t prev_jbrand = jbrand(); @@ -272,21 +296,6 @@ int ReRandomizeBootstrap() NSString* jbroot_path = [NSString stringWithFormat:@"/var/containers/Bundle/Application/.jbroot-%016llX", new_jbrand]; NSString* jbroot_secondary = [NSString stringWithFormat:@"/var/mobile/Containers/Shared/AppGroup/.jbroot-%016llX", new_jbrand]; - - for(NSString* item in [fm contentsOfDirectoryAtPath:jbroot_path error:nil]) - { - if([item isEqualToString:@"var"]) - continue; - - NSString* checkpath = [jbroot_secondary stringByAppendingPathComponent:item]; - - struct stat st; - if(lstat(checkpath.fileSystemRepresentation, &st)==0) { - ASSERT([fm removeItemAtPath:checkpath error:nil]); - } - - ASSERT([fm createSymbolicLinkAtPath:checkpath withDestinationPath:[jbroot_path stringByAppendingPathComponent:item] error:nil]); - } ASSERT([fm removeItemAtPath:[jbroot_path stringByAppendingPathComponent:@"/private/var"] error:nil]); ASSERT([fm createSymbolicLinkAtPath:[jbroot_path stringByAppendingPathComponent:@"/private/var"] @@ -307,6 +316,8 @@ int ReRandomizeBootstrap() ASSERT(startBootstrapServer() == 0); STRAPLOG("Status: Updating Symlinks"); + ASSERT(fixBootstrapSymlink(@"/bin/sh") == 0); + ASSERT(fixBootstrapSymlink(@"/usr/bin/sh") == 0); ASSERT(spawnBootstrap((char*[]){"/bin/sh", "/usr/libexec/updatelinks.sh", NULL}, nil, nil) == 0); return 0; @@ -430,30 +441,36 @@ int bootstrap() ASSERT([fm removeItemAtPath:@"/var/jb" error:nil]); } - NSString* jbroot_path = find_jbroot(YES); - - if(!jbroot_path) { - STRAPLOG("device is not strapped..."); - - jbroot_path = [NSString stringWithFormat:@"/var/containers/Bundle/Application/.jbroot-%016llX", jbrand_new()]; - - STRAPLOG("bootstrap @ %@", jbroot_path); - - ASSERT(InstallBootstrap(jbroot_path) == 0); - - } else if(![fm fileExistsAtPath:jbroot(@"/.bootstrapped")] && ![fm fileExistsAtPath:jbroot(@"/.thebootstrapped")]) { - STRAPLOG("remove unfinished bootstrap %@", jbroot_path); + NSString* dirpath = @"/var/containers/Bundle/Application/"; + NSArray *subItems = [fm contentsOfDirectoryAtPath:dirpath error:nil]; + for (NSString *subItem in subItems) + { + if (!is_jbroot_name(subItem.UTF8String)) continue; - uint64_t prev_jbrand = jbrand(); + NSString* jbroot_path = [dirpath stringByAppendingPathComponent:subItem]; - ASSERT([fm removeItemAtPath:jbroot_path error:nil]); + if([fm fileExistsAtPath:[jbroot_path stringByAppendingPathComponent:@"/.bootstrapped"]] + || [fm fileExistsAtPath:[jbroot_path stringByAppendingPathComponent:@"/.thebootstrapped"]]) { + continue; + } - NSString* jbroot_secondary = [NSString stringWithFormat:@"/var/mobile/Containers/Shared/AppGroup/.jbroot-%016llX", prev_jbrand]; + STRAPLOG("remove unknown/unfinished jbroot %@", subItem); + + NSString* jbroot_secondary = [NSString stringWithFormat:@"/var/mobile/Containers/Shared/AppGroup/%@", subItem]; if([fm fileExistsAtPath:jbroot_secondary]) { - STRAPLOG("remove unfinished bootstrap %@", jbroot_secondary); ASSERT([fm removeItemAtPath:jbroot_secondary error:nil]); } + ASSERT([fm removeItemAtPath:jbroot_path error:nil]); + } + + NSString* jbroot_path = find_jbroot(YES); + + if(!jbroot_path) { + STRAPLOG("device is not strapped..."); + + jbroot_path = [NSString stringWithFormat:@"/var/containers/Bundle/Application/.jbroot-%016llX", jbrand_new()]; + STRAPLOG("bootstrap @ %@", jbroot_path); ASSERT(InstallBootstrap(jbroot_path) == 0); @@ -461,6 +478,8 @@ int bootstrap() } else { STRAPLOG("device is strapped: %@", jbroot_path); + ASSERT([fm fileExistsAtPath:jbroot(@"/.bootstrapped")] || [fm fileExistsAtPath:jbroot(@"/.thebootstrapped")]); + if([fm fileExistsAtPath:jbroot(@"/.bootstrapped")]) //beta version to public version ASSERT([fm moveItemAtPath:jbroot(@"/.bootstrapped") toPath:jbroot(@"/.thebootstrapped") error:nil]); diff --git a/basebin b/basebin index e74bc24a..8a1de7d1 160000 --- a/basebin +++ b/basebin @@ -1 +1 @@ -Subproject commit e74bc24aafbb1808b0d283b7134106ddcebddaa5 +Subproject commit 8a1de7d1bd03910416c469cd85b5c5049df20f2a diff --git a/sileo.deb b/sileo.deb index 8e56a86d..7eb7fa52 100644 Binary files a/sileo.deb and b/sileo.deb differ diff --git a/strapfiles/bootstrap-1800.tar.zst b/strapfiles/bootstrap-1800.tar.zst index 7669346a..4a813ff0 100644 Binary files a/strapfiles/bootstrap-1800.tar.zst and b/strapfiles/bootstrap-1800.tar.zst differ diff --git a/strapfiles/bootstrap-1900.tar.zst b/strapfiles/bootstrap-1900.tar.zst index b7b263cf..b3601eec 100644 Binary files a/strapfiles/bootstrap-1900.tar.zst and b/strapfiles/bootstrap-1900.tar.zst differ