aboutsummaryrefslogtreecommitdiff
path: root/darwin-bootstrap
diff options
context:
space:
mode:
authorcomex2015-07-12 14:26:39 -0400
committercomex2015-07-12 14:26:39 -0400
commit935c1cecba0fc2c9bc09e9740a50d774e520bfa4 (patch)
tree5fa45cbc4ef1c742d38b3c288cefb73327328c30 /darwin-bootstrap
parentImportant: Fix fd leak that I think was the culprit for substitute'd devices ... (diff)
downloadsubstitute-935c1cecba0fc2c9bc09e9740a50d774e520bfa4.tar.gz
safetydance work, but it's broken
Diffstat (limited to 'darwin-bootstrap')
-rw-r--r--darwin-bootstrap/safemode-ui-hook.m32
-rw-r--r--darwin-bootstrap/substituted.m10
2 files changed, 35 insertions, 7 deletions
diff --git a/darwin-bootstrap/safemode-ui-hook.m b/darwin-bootstrap/safemode-ui-hook.m
index f762c6d..8fe228f 100644
--- a/darwin-bootstrap/safemode-ui-hook.m
+++ b/darwin-bootstrap/safemode-ui-hook.m
@@ -12,6 +12,7 @@ static bool g_did_exit_safety_dance;
@interface _SBApplicationController
- (id)applicationWithBundleIdentifier:(NSString *)identifier;
++ (instancetype)sharedInstanceIfExists;
@end
@interface _SBSetupManager
@@ -26,21 +27,40 @@ static bool g_did_exit_safety_dance;
static id (*old_setupApplication)(id, SEL);
static id my_setupApplication(id self, SEL sel) {
- if (g_did_say_in_setup_mode)
- return [self applicationWithBundleIdentifier:@"com.ex.SafetyDance"];
+ if (g_did_say_in_setup_mode) {
+ id app = [self applicationWithBundleIdentifier:@"com.ex.SafetyDance"];
+ if (app) {
+ /* definitely shouldn't be nil, given below check, but... */
+ return app;
+ }
+ }
return old_setupApplication(self, sel);
}
static bool (*old_updateInSetupMode)(id, SEL);
static bool my_updateInSetupMode(id self, SEL sel) {
- if (g_did_exit_safety_dance) {
- g_did_say_in_setup_mode = false;
- return old_updateInSetupMode(self, sel);
- } else {
+ bool should_say = !g_did_exit_safety_dance;
+ if (should_say) {
+ _SBApplicationController *controller =
+ [objc_getClass("SBApplicationController") sharedInstanceIfExists];
+ if (!controller) {
+ NSLog(@"substitute safe mode: SBApplicationController missing...");
+ should_say = false;
+ } else if (![controller
+ applicationWithBundleIdentifier:@"com.ex.SafetyDance"]) {
+ NSLog(@"substitute safe mode: SafetyDance app missing or unregistered");
+ should_say = false;
+ }
+ }
+
+ if (should_say) {
/* take priority over real setup */
g_did_say_in_setup_mode = true;
[self _setInSetupMode:true];
return true;
+ } else {
+ g_did_say_in_setup_mode = false;
+ return old_updateInSetupMode(self, sel);
}
}
diff --git a/darwin-bootstrap/substituted.m b/darwin-bootstrap/substituted.m
index 43654c2..2c3217b 100644
--- a/darwin-bootstrap/substituted.m
+++ b/darwin-bootstrap/substituted.m
@@ -77,6 +77,12 @@ enum convert_filters_ret {
- (enum convert_filters_ret)
convertFiltersForBundleInfo:(NSDictionary *)plist_dict
toXPCReply:(xxpc_object_t)out_info {
+
+ for (NSString *key in [plist_dict allKeys]) {
+ if (!([key isEqualToString:@"Filter"]))
+ return INVALID;
+ }
+
NSDictionary *filter = [plist_dict objectForKey:@"Filter"];
if (!filter)
return PROVISIONAL_PASS;
@@ -201,7 +207,9 @@ enum convert_filters_ret {
_argv0 = [NSString stringWithCString:argv0
encoding:NSUTF8StringEncoding];
- _is_springboard = [_argv0 isEqualToString:@"SpringBoard"];
+ NSString *sb_exe =
+ @"/System/Library/CoreServices/SpringBoard.app/SpringBoard";
+ _is_springboard = [_argv0 isEqualToString:sb_exe];
xxpc_object_t bundles = xxpc_array_create(NULL, 0);