diff options
author | comex | 2015-07-10 22:38:44 -0400 |
---|---|---|
committer | comex | 2015-07-10 22:38:44 -0400 |
commit | d88b91519b96d8accdbfc4216010d0a42343ca33 (patch) | |
tree | ac54e2a5a8d35b981aeda828230b39f0d92c4129 /darwin-bootstrap | |
parent | Avoid issues with the system time changing (diff) | |
download | substitute-d88b91519b96d8accdbfc4216010d0a42343ca33.tar.gz |
stuff!
Diffstat (limited to 'darwin-bootstrap')
-rw-r--r-- | darwin-bootstrap/com.ex.substituted.plist | 5 | ||||
-rw-r--r-- | darwin-bootstrap/substituted.m | 38 |
2 files changed, 37 insertions, 6 deletions
diff --git a/darwin-bootstrap/com.ex.substituted.plist b/darwin-bootstrap/com.ex.substituted.plist index 4f30051..caed4c9 100644 --- a/darwin-bootstrap/com.ex.substituted.plist +++ b/darwin-bootstrap/com.ex.substituted.plist @@ -13,6 +13,11 @@ <string>com.ex.substituted</string> <key>Program</key> <string>/Library/Substitute/Helpers/substituted</string> + <key>EnvironmentVariables</key> + <dict> + <key>_MSSafeMode</key> + <string>1</string> + </dict> </dict> </plist> diff --git a/darwin-bootstrap/substituted.m b/darwin-bootstrap/substituted.m index cfa1541..ec30a49 100644 --- a/darwin-bootstrap/substituted.m +++ b/darwin-bootstrap/substituted.m @@ -1,6 +1,37 @@ #import <Foundation/Foundation.h> #import <CoreFoundation/CoreFoundation.h> #include "xxpc.h" +#include "substitute.h" +# + +/* This is a daemon contacted by all processes which can load extensions. It + * currently does the work of reading the plists in + * /Library/Substitute/DynamicLibraries in order to avoid loading objc/CF + * libraries into the target binary (unless actually required by loaded + * libraries). In the future it will help with hot loading. */ + +extern kern_return_t bootstrap_look_up3(mach_port_t bp, + const char *service_name, mach_port_t *sp, pid_t target_pid, + const uuid_t instance_id, uint64_t flags); + +static kern_return_t my_bootstrap_look_up3(mach_port_t bp, + const char *service_name, mach_port_t *sp, pid_t target_pid, + const uuid_t instance_id, uint64_t flags) { + NSLog(@"Something in substituted tried to look up '%s', which could cause a deadlock. This is a bug.", + service_name); + return KERN_FAILURE; +} +static const struct substitute_function_hook deadlock_warning_hook = { + bootstrap_look_up3, my_bootstrap_look_up3, NULL +}; + +static void install_deadlock_warning() { + int ret = substitute_hook_functions(&deadlock_warning_hook, 1, NULL, 0); + if (ret) { + NSLog(@"substitute_hook_functions(&deadlock_warning_hook, ..) failed: %d", + ret); + } +} enum convert_filters_ret { PROVISIONAL_PASS, @@ -211,13 +242,8 @@ static void init_peer(xxpc_object_t peer) { xxpc_connection_resume(peer); } -/* This is a daemon contacted by all processes which can load extensions. It - * currently does the work of reading the plists in - * /Library/Substitute/DynamicLibraries in order to avoid loading objc/CF - * libraries into the target binary (unless actually required by loaded - * libraries). In the future it will help with hot loading. */ - int main() { + install_deadlock_warning(); xxpc_connection_t listener = xxpc_connection_create_mach_service( "com.ex.substituted", NULL, XXPC_CONNECTION_MACH_SERVICE_LISTENER); if (!listener) { |