From 4e74aeeeeabe47362a5a6e748f8b6094abe3b3c6 Mon Sep 17 00:00:00 2001 From: Sam Bingner Date: Wed, 15 Aug 2018 15:09:24 -1000 Subject: Coreutils platformization for jbd --- data/_coreutils/zzz_platformize.diff | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 data/_coreutils/zzz_platformize.diff 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 + #include + #include ++#include + + /* 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; -- cgit v1.2.3