Skip to content

Commit

Permalink
Merge branch 'roothide:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Pottle authored Jan 11, 2024
2 parents 434ea8b + 7e66445 commit 3573683
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Bootstrap.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 0.4.2;
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = com.roothide.Bootstrap;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -470,7 +470,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 0.4.2;
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = com.roothide.Bootstrap;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Binary file not shown.
4 changes: 4 additions & 0 deletions Bootstrap/AppViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ - (void)updateData:(BOOL)sort {

if([app.bundleURL.path.lastPathComponent isEqualToString:@"Bootstrap.app"])
continue;

if([app.bundleIdentifier isEqualToString:NSBundle.mainBundle.bundleIdentifier]
|| [app.bundleIdentifier isEqualToString:@"com.roothide.Bootstrap"])
continue;

[applications addObject:app];
}
Expand Down
2 changes: 1 addition & 1 deletion Bootstrap/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="248" fixedFrame="YES" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="Bootstrap(beta 4.1)" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="mHC-UO-Fsn">
<textField opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="248" fixedFrame="YES" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="Bootstrap(beta 4.2)" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="mHC-UO-Fsn">
<rect key="frame" x="14" y="34" width="300" height="51"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="42"/>
Expand Down
53 changes: 45 additions & 8 deletions Bootstrap/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,13 @@ - (void)viewDidLoad {

if(isSystemBootstrapped())
{
self.bootstraBtn.enabled = NO;
[self.bootstraBtn setTitle:Localized(@"Bootstrapped") forState:UIControlStateDisabled];
if(checkBootstrapVersion()) {
self.bootstraBtn.enabled = NO;
[self.bootstraBtn setTitle:Localized(@"Bootstrapped") forState:UIControlStateDisabled];
} else {
self.bootstraBtn.enabled = YES;
[self.bootstraBtn setTitle:Localized(@"Update") forState:UIControlStateNormal];
}

self.respringBtn.enabled = YES;
self.appEnablerBtn.enabled = YES;
Expand Down Expand Up @@ -134,7 +139,7 @@ - (void)viewDidLoad {
uname(&systemInfo);
[AppDelegate addLogText:[NSString stringWithFormat:@"device-model: %s",systemInfo.machine]];

[AppDelegate addLogText:[NSString stringWithFormat:@"app-version: %@/%@",NSBundle.mainBundle.infoDictionary[@"CFBundleVersion"],NSBundle.mainBundle.infoDictionary[@"CFBundleShortVersionString"]]];
[AppDelegate addLogText:[NSString stringWithFormat:@"app-version: %@",NSBundle.mainBundle.infoDictionary[@"CFBundleShortVersionString"]]];

[AppDelegate addLogText:[NSString stringWithFormat:@"boot-session: %@",getBootSession()]];

Expand Down Expand Up @@ -162,20 +167,33 @@ - (void)viewDidLoad {

if(isSystemBootstrapped())
{
[self checkServer];
if([self checkServer]) {
[AppDelegate addLogText:Localized(@"bootstrap server check successful")];
}

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkServer)
name:UIApplicationWillEnterForegroundNotification object:nil];
}

if(isBootstrapInstalled() || isSystemBootstrapped()) {
if([UIApplication.sharedApplication canOpenURL:[NSURL URLWithString:@"filza://"]]
|| [LSPlugInKitProxy pluginKitProxyForIdentifier:@"com.tigisoftware.Filza.Sharing"])
{
[AppDelegate showMesage:Localized(@"It seems that you have the Filza app installed, which may be detected as jailbroken. You can enable Tweak for it to hide it.") title:Localized(@"Warnning")];
}
}
}

-(void)checkServer
-(BOOL)checkServer
{
static bool alerted = false;
if(alerted) return;
if(alerted) return NO;

BOOL ret=NO;

if(spawnRoot(jbroot(@"/basebin/bootstrapd"), @[@"check"], nil, nil) != 0)
{
ret = NO;
alerted = true;

UIAlertController *alert = [UIAlertController alertControllerWithTitle:Localized(@"Server Not Running") message:Localized(@"for unknown reasons the bootstrap server is not running, the only thing we can do is to restart it now.") preferredStyle:UIAlertControllerStyleAlert];
Expand All @@ -196,9 +214,11 @@ -(void)checkServer

[AppDelegate showAlert:alert];
} else {
[AppDelegate addLogText:Localized(@"bootstrap server check successful")];
[self updateOpensshStatus];
ret = YES;
}

return ret;
}

-(void)updateOpensshStatus {
Expand Down Expand Up @@ -373,6 +393,22 @@ - (IBAction)openssh:(id)sender {
}

- (IBAction)bootstrap:(id)sender {

if(isSystemBootstrapped())
{
ASSERT(checkBootstrapVersion()==false);

UIAlertController *alert = [UIAlertController alertControllerWithTitle:Localized(@"Update") message:Localized(@"The current bootstrapped version is inconsistent with the Bootstrap app version, and you need to reboot the device to update it.") preferredStyle:UIAlertControllerStyleAlert];

[alert addAction:[UIAlertAction actionWithTitle:Localized(@"Cancel") style:UIAlertActionStyleDefault handler:nil]];
[alert addAction:[UIAlertAction actionWithTitle:Localized(@"Reboot Device") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
ASSERT(spawnRoot(NSBundle.mainBundle.executablePath, @[@"reboot"], nil, nil)==0);
}]];

[AppDelegate showAlert:alert];
return;
}

if(![self checkTSVersion]) {
[AppDelegate showMesage:Localized(@"Your trollstore version is too old, Bootstrap only supports trollstore>=2.0") title:Localized(@"Error")];
return;
Expand All @@ -384,7 +420,7 @@ - (IBAction)bootstrap:(id)sender {
}

UIImpactFeedbackGenerator* generator = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleSoft];
generator.impactOccurred;
[generator impactOccurred];

if(find_jbroot()) //make sure jbroot() function available
{
Expand Down Expand Up @@ -437,6 +473,7 @@ - (IBAction)bootstrap:(id)sender {
[AppDelegate addLogText:[NSString stringWithFormat:@"openssh launch faild(%d):\n%@\n%@", status, log, err]];
}

[generator impactOccurred];
[AppDelegate addLogText:@"respring now..."]; sleep(1);

status = spawnBootstrap((char*[]){"/usr/bin/sbreload", NULL}, &log, &err);
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.
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.
1 change: 1 addition & 0 deletions Bootstrap/bootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ bool isBootstrapInstalled();

bool isSystemBootstrapped();

bool checkBootstrapVersion();

#endif /* bootstrap_h */
31 changes: 25 additions & 6 deletions Bootstrap/bootstrap.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ int rebuildBasebin()
return 0;
}

int startBootstrapd()
int startBootstrapServer()
{
NSString* log=nil;
NSString* err=nil;
Expand Down Expand Up @@ -209,7 +209,7 @@ int InstallBootstrap(NSString* jbroot_path)
ASSERT(rebuildBasebin() == 0);

STRAPLOG("Status: Starting Bootstrapd");
ASSERT(startBootstrapd() == 0);
ASSERT(startBootstrapServer() == 0);

STRAPLOG("Status: Finalizing Bootstrap");
NSString* log=nil;
Expand Down Expand Up @@ -252,7 +252,7 @@ int InstallBootstrap(NSString* jbroot_path)

int ReRandomizeBootstrap()
{
//jbroot() disabled
//jbroot() unavailable

NSFileManager* fm = NSFileManager.defaultManager;

Expand Down Expand Up @@ -292,13 +292,13 @@ int ReRandomizeBootstrap()
ASSERT([fm createSymbolicLinkAtPath:[jbroot_secondary stringByAppendingPathComponent:@".jbroot"]
withDestinationPath:jbroot_path error:nil]);

//jbroot() enabled
//jbroot() available now

STRAPLOG("Status: Building Base Binaries");
ASSERT(rebuildBasebin() == 0);

STRAPLOG("Status: Starting Bootstrapd");
ASSERT(startBootstrapd() == 0);
ASSERT(startBootstrapServer() == 0);

STRAPLOG("Status: Updating Symlinks");
ASSERT(spawnBootstrap((char*[]){"/bin/sh", "/usr/libexec/updatelinks.sh", NULL}, nil, nil) == 0);
Expand All @@ -314,6 +314,12 @@ int bootstrap()

NSFileManager* fm = NSFileManager.defaultManager;

struct stat st;
if(lstat("/var/jb", &st)==0) {
//remove /var/jb to avoid incorrect library loading via @rpath
ASSERT([fm removeItemAtPath:@"/var/jb" error:nil]);
}

NSString* jbroot_path = find_jbroot();

if(!jbroot_path) {
Expand Down Expand Up @@ -355,7 +361,7 @@ int bootstrap()
STRAPLOG("Status: Rebuilding Apps");
ASSERT(spawnBootstrap((char*[]){"/bin/sh", "/basebin/rebuildapps.sh", NULL}, nil, nil) == 0);

NSDictionary* bootinfo = @{@"bootsession":getBootSession()};
NSDictionary* bootinfo = @{@"bootsession":getBootSession(), @"bootversion":NSBundle.mainBundle.infoDictionary[@"CFBundleShortVersionString"]};
ASSERT([bootinfo writeToFile:jbroot(@"/basebin/.bootinfo.plist") atomically:YES]);

STRAPLOG("Status: Bootstrap Successful");
Expand Down Expand Up @@ -445,3 +451,16 @@ bool isSystemBootstrapped()

return [bootsession isEqualToString:getBootSession()];
}

bool checkBootstrapVersion()
{
if(!isBootstrapInstalled()) return false;

NSDictionary* bootinfo = [NSDictionary dictionaryWithContentsOfFile:jbroot(@"/basebin/.bootinfo.plist")];
if(!bootinfo) return false;

NSString* bootversion = bootinfo[@"bootversion"];
if(!bootversion) return false;

return [bootversion isEqualToString:NSBundle.mainBundle.infoDictionary[@"CFBundleShortVersionString"]];
}
5 changes: 4 additions & 1 deletion Bootstrap/credits.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
#define credits_h
// dictionary will be sorted alphabetically
NSDictionary* CREDITS = @{
@"Nick Chan" : @"https://github.com/asdfugil",
@"opa334" : @"http://github.com/opa334",
@"hayden" : @"https://procursus.social/@hayden",
@"CKatri" : @"https://procursus.social/@cameron",
@"Alfie" : @"https://alfiecg.uk",
@"Mineek" : @"https://github.com/mineek",
@"hrtowii" : @"https://github.com/hrtowii",
@"BomberFish" : @"https://twitter.com/bomberfish77",
@"Évelyne" : @"http://github.com/evelyneee",
@"sourcelocation" : @"http://github.com/sourcelocation",
Expand All @@ -28,7 +31,6 @@ NSDictionary* CREDITS = @{
@"Nebula" : @"https://itsnebula.net",
@"DuyKhanhTran" : @"https://twitter.com/TranKha50277352",
@"Nathan" : @"https://github.com/verygenericname",
@"Nick Chan" : @"https://nickchan.lol",
@"Muirey03" : @"https://twitter.com/Muirey03",
@"absidue" : @"https://github.com/absidue",
@"MasterMike" : @"https://ios.cfw.guide",
Expand All @@ -55,6 +57,7 @@ NSDictionary* CREDITS = @{
@"akusio" : @"https://twitter.com/akusio_rr",
@"xsf1re" : @"https://twitter.com/xsf1re",
@"PoomSmart" : @"https://twitter.com/poomsmart",
@"katana" : @"https://twitter.com/nsbedtime",
@"Elias Sfeir" : @"https://twitter.com/eliassfeir1",
@"SquidGesture" : @"https://twitter.com/lclrc",
@"yandevelop" : @"https://twitter.com/yandevelop",
Expand Down
6 changes: 6 additions & 0 deletions Bootstrap/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ int main(int argc, char * argv[]) {
} else if(strcmp(argv[1], "rebuildiconcache")==0) {
int rebuildIconCache();
exit(rebuildIconCache());
} else if(strcmp(argv[1], "reboot")==0) {
sync();
sleep(1);
reboot(0);
sleep(5);
exit(-1);
} else if(strcmp(argv[1], "testprefs")==0) {
SYSLOG("locale=%@", [NSUserDefaults.appDefaults valueForKey:@"locale"]);
[NSUserDefaults.appDefaults setValue:@"CA" forKey:@"locale"];
Expand Down
6 changes: 6 additions & 0 deletions Bootstrap/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,10 @@ void killAllForApp(const char* bundlePath);
user:(BOOL)arg3;
@end

@interface LSPlugInKitProxy : NSObject
+(id)pluginKitProxyForIdentifier:(id)arg1 ;
- (NSString *)bundleIdentifier;
@property (nonatomic,readonly) NSURL *dataContainerURL;
@end

#endif /* utils_h */
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ XCODE_SCHEME = Bootstrap

XCODEPROJ_NAME = Bootstrap

Bootstrap_XCODEFLAGS = MARKETING_VERSION=$(THEOS_PACKAGE_BASE_VERSION) \
Bootstrap_XCODEFLAGS = \
IPHONEOS_DEPLOYMENT_TARGET="$(IPHONEOS_DEPLOYMENT_TARGET)" \
CODE_SIGN_IDENTITY="" \
AD_HOC_CODE_SIGNING_ALLOWED=YES
Expand Down

0 comments on commit 3573683

Please sign in to comment.