summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2016-07-22 15:19:04 -0700
committerJay Freeman (saurik) <saurik@saurik.com>2016-07-22 15:19:04 -0700
commit68d2b30b8a240347caa0937c75cfbf0079b7a3a5 (patch)
tree122c5d5d4879af525e713f0af38c607009fcd8c9
parent29800e26a158518a01eda03e9c35f0aba0f764d6 (diff)
Add ldrestart for safe restart from app jailbreak.v1.1.12
-rw-r--r--.gitignore1
-rw-r--r--ldrestart.cpp79
-rw-r--r--makefile7
3 files changed, 86 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index f891275..a768abc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@ debs
extrainst_
gssc
iomfsetgamma
+ldrestart
sbdidlaunch
sbreload
uicache
diff --git a/ldrestart.cpp b/ldrestart.cpp
new file mode 100644
index 0000000..04f7a8b
--- /dev/null
+++ b/ldrestart.cpp
@@ -0,0 +1,79 @@
+/* Cydia - iPhone UIKit Front-End for Debian APT
+ * Copyright (C) 2008-2015 Jay Freeman (saurik)
+*/
+
+/* GNU General Public License, Version 3 {{{ */
+/*
+ * Cydia is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 3 of the License,
+ * or (at your option) any later version.
+ *
+ * Cydia is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Cydia. If not, see <http://www.gnu.org/licenses/>.
+**/
+/* }}} */
+
+#include <cstdio>
+#include <cstdlib>
+
+#include <errno.h>
+#include <signal.h>
+#include <sysexits.h>
+#include <unistd.h>
+
+#include <launch.h>
+
+#include <sys/stat.h>
+
+void process(launch_data_t value, const char *name, void *baton) {
+ if (launch_data_get_type(value) != LAUNCH_DATA_DICTIONARY)
+ return;
+
+ auto integer(launch_data_dict_lookup(value, LAUNCH_JOBKEY_PID));
+ if (integer == NULL || launch_data_get_type(integer) != LAUNCH_DATA_INTEGER)
+ return;
+
+ auto pid(launch_data_get_integer(integer));
+ if (kill(pid, 0) == -1)
+ return;
+
+ auto string(launch_data_dict_lookup(value, LAUNCH_JOBKEY_LABEL));
+ if (string == NULL || launch_data_get_type(string) != LAUNCH_DATA_STRING)
+ return;
+ auto label(launch_data_get_string(string));
+
+ auto stop(launch_data_alloc(LAUNCH_DATA_DICTIONARY));
+ launch_data_dict_insert(stop, string, LAUNCH_KEY_STOPJOB);
+
+ auto result(launch_msg(stop));
+ launch_data_free(stop);
+ if (result == NULL)
+ return;
+
+ if (launch_data_get_type(result) != LAUNCH_DATA_ERRNO)
+ fprintf(stderr, "%s\n", label);
+ else if (auto number = launch_data_get_errno(result))
+ fprintf(stderr, "%s: %s\n", label, strerror(number));
+
+ launch_data_free(result);
+}
+
+int main(int argc, char *argv[]) {
+ auto request(launch_data_new_string(LAUNCH_KEY_GETJOBS));
+ auto response(launch_msg(request));
+ launch_data_free(request);
+
+ if (response == NULL)
+ return EX_UNAVAILABLE;
+ if (launch_data_get_type(response) != LAUNCH_DATA_DICTIONARY)
+ return EX_SOFTWARE;
+
+ launch_data_dict_iterate(response, &process, NULL);
+ return EX_OK;
+}
diff --git a/makefile b/makefile
index 0f16936..bb00062 100644
--- a/makefile
+++ b/makefile
@@ -1,4 +1,4 @@
-uikittools = uiduid uicache uiopen gssc sbdidlaunch sbreload cfversion iomfsetgamma
+uikittools = uiduid uicache uiopen gssc sbdidlaunch sbreload cfversion iomfsetgamma ldrestart
all: $(uikittools)
@@ -15,6 +15,7 @@ flags += -framework Foundation
flags += -miphoneos-version-min=2.0
flags += -arch armv6
+ldrestart := -std=c++11
gssc := -lobjc
iomfsetgamma := -I. $(private) -framework IOKit -framework IOMobileFramebuffer
sbdidlaunch := $(private) -framework SpringBoardServices
@@ -30,6 +31,10 @@ extrainst_: csstore.cpp
cycc -- -o $@ $^ $(flags) $($@)
ldid -S$(wildcard $@.xml) $@
+%: %.cpp
+ cycc -- -o $@ $^ $(flags) $($@)
+ ldid -S$(wildcard $@.xml) $@
+
%: %.c
cycc -- -o $@ -x c $^ $(flags) $($@)
ldid -S$(wildcard $@.xml) $@