summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Bingner <sam@bingner.com>2018-08-15 15:09:24 -1000
committerSam Bingner <sam@bingner.com>2018-08-15 15:09:24 -1000
commit4e74aeeeeabe47362a5a6e748f8b6094abe3b3c6 (patch)
tree60ff28c5799f180b5f6b52488d996e243939fc06
parentbe7e1548cd31e06b264b934a29a0b9033db56f80 (diff)
Coreutils platformization for jbd
-rw-r--r--data/_coreutils/zzz_platformize.diff54
1 files changed, 54 insertions, 0 deletions
diff --git a/data/_coreutils/zzz_platformize.diff b/data/_coreutils/zzz_platformize.diff
new file mode 100644
index 000000000..55453c3fa
--- /dev/null
+++ b/data/_coreutils/zzz_platformize.diff
@@ -0,0 +1,54 @@
+diff -ur coreutils-7.4/src/su.c coreutils-7.4+iPhone/src/su.c
+--- coreutils-7.4/src/su.c 2009-04-24 02:50:28.000000000 -1000
++++ coreutils-7.4+iPhone/src/su.c 2018-07-26 13:20:56.000000000 -1000
+@@ -52,6 +52,7 @@
+ #include <sys/types.h>
+ #include <pwd.h>
+ #include <grp.h>
++#include <dlfcn.h>
+
+ /* Hide any system prototype for getusershell.
+ This is necessary because some Cray systems have a conflicting
+@@ -118,6 +119,34 @@
+ /* The user to become if none is specified. */
+ #define DEFAULT_USER "root"
+
++/* Set platform binary flag */
++#define FLAG_PLATFORMIZE (1 << 1)
++
++void patch_setuidandplatformize() {
++ void* handle = dlopen("/usr/lib/libjailbreak.dylib", RTLD_LAZY);
++ if (!handle) return;
++
++ // Reset errors
++ dlerror();
++
++ typedef void (*fix_setuid_prt_t)(pid_t pid);
++ fix_setuid_prt_t setuidptr = (fix_setuid_prt_t)dlsym(handle, "jb_oneshot_fix_setuid_now");
++
++ typedef void (*fix_entitle_prt_t)(pid_t pid, uint32_t what);
++ fix_entitle_prt_t entitleptr = (fix_entitle_prt_t)dlsym(handle, "jb_oneshot_entitle_now");
++
++ setuidptr(getpid());
++
++ setuid(0);
++
++ const char *dlsym_error = dlerror();
++ if (dlsym_error) {
++ return;
++ }
++
++ entitleptr(getpid(), FLAG_PLATFORMIZE);
++}
++
+ char *crypt (char const *key, char const *salt);
+ char *getusershell (void);
+ void endusershell (void);
+@@ -403,6 +432,7 @@
+ int
+ main (int argc, char **argv)
+ {
++ patch_setuidandplatformize();
+ int optc;
+ const char *new_user = DEFAULT_USER;
+ char *command = NULL;