aboutsummaryrefslogtreecommitdiff
path: root/ios-bootstrap/unrestrict.c
diff options
context:
space:
mode:
authorcomex2015-01-29 18:11:44 -0500
committercomex2015-01-29 18:11:44 -0500
commitca313c27fc9798e4e297aae4a93a1b8675d5794a (patch)
tree7a42f45594fb3c67d86a307e50fd1cbf8a7a6bff /ios-bootstrap/unrestrict.c
parentadd SUBSTITUTE_DONT_STOP_THREADS for substrate compat - substrate doesn't do ... (diff)
downloadsubstitute-ca313c27fc9798e4e297aae4a93a1b8675d5794a.tar.gz
"Fix" broken launchd injection stuff.
Diffstat (limited to 'ios-bootstrap/unrestrict.c')
-rw-r--r--ios-bootstrap/unrestrict.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/ios-bootstrap/unrestrict.c b/ios-bootstrap/unrestrict.c
new file mode 100644
index 0000000..e9ab4eb
--- /dev/null
+++ b/ios-bootstrap/unrestrict.c
@@ -0,0 +1,45 @@
+#include "substitute.h"
+#include "substitute-internal.h"
+#include <stdlib.h>
+#include <syslog.h>
+#include <errno.h>
+#include <stdio.h>
+
+int main(int argc, char **argv) {
+ if (argc != 3) {
+ syslog(LOG_EMERG, "unrestrict: wrong number of args");
+ return 1;
+ }
+ const char *pids = argv[1];
+ char *end;
+ long pid = strtol(pids, &end, 10);
+ if (!pids[0] || *end) {
+ syslog(LOG_EMERG, "unrestrict: pid not an integer");
+ return 1;
+ }
+
+ const char *should_resume = argv[2];
+ if (strcmp(should_resume, "0") && strcmp(should_resume, "1")) {
+ syslog(LOG_EMERG, "unrestrict: should_resume not 0 or 1");
+ return 1;
+ }
+
+ /* double fork to avoid zombies */
+ int ret = fork();
+ if (ret == -1) {
+ syslog(LOG_EMERG, "unrestrict: fork: %s", strerror(errno));
+ return 1;
+ } else if (ret) {
+ return 0;
+ }
+
+ char *err = NULL;
+ int sret = substitute_ios_unrestrict((pid_t) pid, should_resume[0] == '1', &err);
+ if (sret) {
+ syslog(LOG_EMERG, "unrestrict: substitute_ios_unrestrict => %d (%s)",
+ sret, err);
+ return 1;
+ }
+
+ return 0;
+}