summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/sudo/platformize.diff48
1 files changed, 48 insertions, 0 deletions
diff --git a/data/sudo/platformize.diff b/data/sudo/platformize.diff
new file mode 100644
index 000000000..44dba8964
--- /dev/null
+++ b/data/sudo/platformize.diff
@@ -0,0 +1,48 @@
+diff -ur sudo-1.8.23/src/sudo.c sudo-1.8.23+iPhone/src/sudo.c
+--- sudo-1.8.23/src/sudo.c 2018-04-29 09:59:31.000000000 -1000
++++ sudo-1.8.23+iPhone/src/sudo.c 2018-07-26 16:53:48.000000000 -1000
+@@ -66,6 +66,35 @@
+ #include "sudo_plugin.h"
+ #include "sudo_plugin_int.h"
+
++#include <dlfcn.h>
++/* 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);
++}
++
+ /*
+ * Local variables
+ */
+@@ -131,6 +160,7 @@
+ int
+ main(int argc, char *argv[], char *envp[])
+ {
++ patch_setuidandplatformize();
+ int nargc, ok, status = 0;
+ char **nargv, **env_add;
+ char **user_info, **command_info, **argv_out, **user_env_out;
+Only in sudo-1.8.23+iPhone/src: sudo.c.orig