Skip to content

Commit

Permalink
1.3.1
Browse files Browse the repository at this point in the history
- Fixed an issue where some packages could not be installed/uninstalled correctly
- Fixed an issue where apps installed via dpkg were not signed correctly
- Fixed an issue where apple terminal/MTerminal might not work correctly
- Fixed an issue that might cause abnormal battery consumption/device overheating
- Fixed an issue where a "multi jbroot" error might occur on reboot
- Fixed an issue where an "updatelinks" error might occur on reboot
- Fixed an issue where fastPathSign might not handle some macho signatures
- Update built-in uicache
- Update built-in sileo package
- Update built-in strapfiles
  • Loading branch information
roothider committed Jan 9, 2025
1 parent 098bf2d commit 9d17f70
Show file tree
Hide file tree
Showing 24 changed files with 117 additions and 82 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ packages/
*.xcuserstate
/Bootstrap.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate
*.xcuserstate
.vscode/

4 changes: 2 additions & 2 deletions Bootstrap.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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)";
Expand Down Expand Up @@ -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)";
Expand Down
Binary file not shown.
23 changes: 10 additions & 13 deletions Bootstrap/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand Down
6 changes: 4 additions & 2 deletions Bootstrap/AppEnabler.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
22 changes: 10 additions & 12 deletions Bootstrap/AppViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
31 changes: 20 additions & 11 deletions Bootstrap/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Binary file modified Bootstrap/basebin/bootstrap.dylib
Binary file not shown.
Binary file modified Bootstrap/basebin/bootstrapd
Binary file not shown.
Binary file modified Bootstrap/basebin/devtest
Binary file not shown.
2 changes: 2 additions & 0 deletions Bootstrap/basebin/entitlements/com.apple.mobilemail.extra
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<key>get-task-allow</key>
<true/>

<key>uicache.data-container-required</key>
<true/>
<key>com.apple.private.security.no-sandbox</key>
<true/>
<key>com.apple.private.security.storage.AppBundles</key>
Expand Down
2 changes: 2 additions & 0 deletions Bootstrap/basebin/entitlements/com.apple.mobilesafari.extra
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<key>get-task-allow</key>
<true/>

<key>uicache.data-container-required</key>
<true/>
<key>com.apple.private.security.no-sandbox</key>
<true/>
<key>com.apple.private.security.storage.AppBundles</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<true/>
<key>com.apple.private.security.no-sandbox</key>
<true/>
<key>uicache.data-container-required</key>
<true/>

<key>com.apple.security.exception.process-info</key>
<true/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<true/>
<key>com.apple.private.security.no-sandbox</key>
<true/>
<key>uicache.data-container-required</key>
<true/>

<key>com.apple.security.exception.process-info</key>
<true/>
Expand Down
Binary file modified Bootstrap/basebin/fastPathSign
Binary file not shown.
Binary file modified Bootstrap/basebin/preload
Binary file not shown.
Binary file modified Bootstrap/basebin/preload.dylib
Binary file not shown.
Binary file modified Bootstrap/basebin/rebuildapp
Binary file not shown.
Binary file modified Bootstrap/basebin/uicache
Binary file not shown.
101 changes: 60 additions & 41 deletions Bootstrap/bootstrap.m
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down Expand Up @@ -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();
Expand All @@ -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"]
Expand All @@ -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;
Expand Down Expand Up @@ -430,37 +441,45 @@ 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);

} 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]);

Expand Down
Binary file modified sileo.deb
Binary file not shown.
Binary file modified strapfiles/bootstrap-1800.tar.zst
Binary file not shown.
Binary file modified strapfiles/bootstrap-1900.tar.zst
Binary file not shown.

0 comments on commit 9d17f70

Please sign in to comment.