summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
Diffstat (limited to 'data')
-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;