From ee355b34d0979bee1e23e184669b1361b76e7e5f Mon Sep 17 00:00:00 2001 From: Nick Chan Date: Fri, 27 Jan 2023 21:24:46 +0800 Subject: [PATCH] implement rootful setup and revert --- .github/workflows/build.yml | 4 ++-- src/kerninfo.h | 6 ++++-- src/optparse.c | 22 ++++++++++++++++++---- src/pongo_helper.c | 5 ++++- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 929ac76..66e4680 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,7 +43,7 @@ jobs: - name: Download dependencies (embedded binaries) run: | cd src - curl -LOOO https://github.com/guacaplushy/checkp4le/raw/main/binaries/checkra1n-kpf-pongo \ + curl -LOOO https://cdn.nickchan.lol/palera1n/c-rewrite/deps/checkra1n-kpf-pongo \ https://cdn.nickchan.lol/palera1n/c-rewrite/deps/binpack.dmg \ https://cdn.nickchan.lol/palera1n/c-rewrite/deps/ramdisk.dmg cd .. @@ -381,7 +381,7 @@ jobs: - name: Download dependencies (embedded binaries) run: | cd src - curl -LOOO https://github.com/guacaplushy/checkp4le/raw/main/binaries/checkra1n-kpf-pongo \ + curl -LOOO https://cdn.nickchan.lol/palera1n/c-rewrite/deps/checkra1n-kpf-pongo \ https://cdn.nickchan.lol/palera1n/c-rewrite/deps/binpack.dmg \ https://cdn.nickchan.lol/palera1n/c-rewrite/deps/ramdisk.dmg cd .. diff --git a/src/kerninfo.h b/src/kerninfo.h index 5e78232..eef0225 100644 --- a/src/kerninfo.h +++ b/src/kerninfo.h @@ -54,8 +54,10 @@ #define checkrain_option_force_revert (1 << 7) /* keep this at 7 */ // palera1n option -#define palerain_option_rootful (1 << 0) -#define palerain_option_jbinit_log_to_file (1 << 1) +#define palerain_option_rootful (1 << 0) /* rootful jailbreak */ +#define palerain_option_jbinit_log_to_file (1 << 1) /* log to /cores/jbinit.log */ +#define palerain_option_setup_rootful (1 << 2) /* create fakefs */ +#define palerain_option_setup_rootful_forced (1 << 3) /* create fakefs over an existing one */ #define PALEINFO_MAGIC 'PLSH' #define PALEINFO_CIGAM 'HSLP' diff --git a/src/optparse.c b/src/optparse.c index ccd62c8..913a586 100644 --- a/src/optparse.c +++ b/src/optparse.c @@ -13,6 +13,8 @@ #include "common.h" static struct option longopts[] = { + {"setup-fakefs", no_argument, NULL, 'c'}, + {"setup-fakefs-forced", no_argument, NULL, 'C'}, {"dfuhelper", no_argument, NULL, 'D'}, {"help", no_argument, NULL, 'h'}, {"pongo-shell", no_argument, NULL, 'p'}, @@ -32,16 +34,19 @@ static struct option longopts[] = { {"override-ramdisk", required_argument, NULL, 'r'}, {"override-kpf", required_argument, NULL, 'K'}, {"disable-ohio", no_argument, NULL, 'O'}, - {NULL, 0, NULL, 0}}; + {NULL, 0, NULL, 0} +}; static int usage(int e, char* prog_name) { fprintf(stderr, - "Usage: %s [-DhpPvVldsOL] [-e boot arguments] [-f root device] [-k Pongo image] [-o overlay file] [-r ramdisk file] [-K KPF file]\n" + "Usage: %s [-cCDhpPvVldsOL] [-e boot arguments] [-f root device] [-k Pongo image] [-o overlay file] [-r ramdisk file] [-K KPF file]\n" "Copyright (C) 2023, palera1n team, All Rights Reserved.\n\n" "iOS/iPadOS 15+ arm64 jailbreaking tool\n\n" "\t--version\t\t\t\tPrint version\n" - "\t--force-revert\t\t\t\tRemove jailbreak (on rootless)\n" + "\t--force-revert\t\t\t\tRemove jailbreak\n" + "\t-c, --setup-fakefs\t\t\tSetup fakefs\n" + "\t-C, --setup-fakefs-forced\t\tSetup fakefs and overwrite any existing ones\n" "\t-D, --dfuhelper-only\t\t\tExit after entering DFU\n" "\t-h, --help\t\t\t\tShow this help\n" "\t-p, --pongo-shell\t\t\tBoots to PongoOS shell\n" @@ -67,9 +72,18 @@ static int usage(int e, char* prog_name) int optparse(int argc, char* argv[]) { int opt; int index; - while ((opt = getopt_long(argc, argv, "DhpvVldsOLe:f:o:r:K:k:", longopts, NULL)) != -1) + while ((opt = getopt_long(argc, argv, "cCDhpvVldsOLe:f:o:r:K:k:", longopts, NULL)) != -1) { switch (opt) { + case 'c': + palerain_flags |= palerain_option_setup_rootful; + kpf_flags |= checkrain_option_verbose_boot; + break; + case 'C': + palerain_flags |= palerain_option_setup_rootful; + palerain_flags |= palerain_option_setup_rootful_forced; + kpf_flags |= checkrain_option_verbose_boot; + break; case 'p': pongo_exit = true; break; diff --git a/src/pongo_helper.c b/src/pongo_helper.c index da3e959..de70711 100644 --- a/src/pongo_helper.c +++ b/src/pongo_helper.c @@ -29,6 +29,10 @@ void *pongo_usb_callback(void *arg) { if (found_pongo) return NULL; found_pongo = 1; + strncat(xargs_cmd, " rootdev=md0", 0x270); + if (checkrain_option_enabled(palerain_flags, palerain_option_setup_rootful)) { + strncat(xargs_cmd, " wdt=-1", 0x270); + } LOG(LOG_INFO, "Found PongoOS USB Device"); usb_device_handle_t handle = *(usb_device_handle_t *)arg; issue_pongo_command(handle, NULL); @@ -44,7 +48,6 @@ void *pongo_usb_callback(void *arg) { issue_pongo_command(handle, rootfs_cmd); issue_pongo_command(handle, dtpatch_cmd); } - strncat(xargs_cmd, " rootdev=md0", 0x270); upload_pongo_file(handle, **ramdisk_to_upload, ramdisk_dmg_len); issue_pongo_command(handle, "ramdisk"); upload_pongo_file(handle, **overlay_to_upload, binpack_dmg_len);