From ca313c27fc9798e4e297aae4a93a1b8675d5794a Mon Sep 17 00:00:00 2001 From: comex Date: Thu, 29 Jan 2015 18:11:44 -0500 Subject: "Fix" broken launchd injection stuff. --- ios-bootstrap/unrestrict.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 ios-bootstrap/unrestrict.c (limited to 'ios-bootstrap/unrestrict.c') 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 +#include +#include +#include + +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; +} -- cgit v1.2.3