From 8b7b199384fb4bd394bd26574a184f0f241bfaac Mon Sep 17 00:00:00 2001 From: Nick Chan Date: Thu, 9 Feb 2023 09:21:37 +0800 Subject: [PATCH] add test1 and test2 flag support --- docs/palera1n.1 | 6 +++--- include/kerninfo.h | 5 +++++ src/optparse.c | 26 +++++++++++++++++++------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/docs/palera1n.1 b/docs/palera1n.1 index 6f6dabe..cc47d4c 100644 --- a/docs/palera1n.1 +++ b/docs/palera1n.1 @@ -17,7 +17,7 @@ .Op Fl o Ar overlay file .Op Fl r Ar ramdisk file .Op Fl K Ar KPF file -.Op Fl 1 Ar checkra1n file +.Op Fl i Ar checkra1n file .Sh DESCRIPTION .Nm jailbreaks any iOS/iPadOS device with an arm64 (arm64e excluded) on iOS 15+, @@ -99,8 +99,6 @@ files. As a result, using the loader app to install the jailbreak environment is not supported when this option is used together with .Fl f , -fakefs \[char46] -.It Fl 1 , -checkra1n-file Ar checkra1n file -Specify the path to a custom checkra1n file. .It Fl c , -setup-fakefs When used with .Fl f , -fakefs , @@ -128,6 +126,8 @@ argument is used during fakefs setup. Jailbreak in rootful mode. .It Fl h , -help Prints help text. +.It Fl i , -checkra1n-file Ar checkra1n file +Specify the path to a custom checkra1n file. .It Fl k , -override-pongo Ar pongo file Override PongoOS image. The raw image, named .Em Pongo.bin diff --git a/include/kerninfo.h b/include/kerninfo.h index 89c184d..1d1bd1b 100644 --- a/include/kerninfo.h +++ b/include/kerninfo.h @@ -59,6 +59,11 @@ #define palerain_option_setup_rootful (1 << 2) /* create fakefs */ #define palerain_option_setup_rootful_forced (1 << 3) /* create fakefs over an existing one */ +#ifdef DEV_BUILD +#define palerain_option_test1 (1 << 29) +#define palerain_option_test2 (1 << 30) +#endif + #define PALEINFO_MAGIC 'PLSH' #define PALEINFO_CIGAM 'HSLP' diff --git a/src/optparse.c b/src/optparse.c index 986bb58..d3d4562 100644 --- a/src/optparse.c +++ b/src/optparse.c @@ -35,8 +35,10 @@ static struct option longopts[] = { {"override-ramdisk", required_argument, NULL, 'r'}, {"override-kpf", required_argument, NULL, 'K'}, {"disable-ohio", no_argument, NULL, 'O'}, - {"override-checkra1n", required_argument, NULL, '1'}, + {"override-checkra1n", required_argument, NULL, 'i'}, #ifdef DEV_BUILD + {"test1", no_argument, NULL, '1'}, + {"test2", no_argument, NULL, '2'}, {"tui", no_argument, NULL, 't'}, #endif {NULL, 0, NULL, 0} @@ -46,16 +48,19 @@ static int usage(int e, char* prog_name) { fprintf(stderr, #ifdef DEV_BUILD - "Usage: %s [-cCdDfhlLOpstvV]" + "Usage: %s [-12cCdDfhlLOpstvV]" #else "Usage: %s [-cCdDfhlLOpsvV]" #endif - " [-e boot arguments] [-k Pongo image] [-o overlay file] [-r ramdisk file] [-K KPF file] [-1 checkra1n file]\n" + " [-e boot arguments] [-k Pongo image] [-o overlay file] [-r ramdisk file] [-K KPF file] [-i checkra1n 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\n" - "\t-1, --override-checkra1n \t\tOverride checkra1n\n" +#ifdef DEV_BUILD + "\t-1, --test1\t\t\t\tSet palerain_option_test1\n" + "\t-2, --test2\t\t\t\tSet palerain_option_test2\n" +#endif "\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, --demote\t\t\t\tDemote\n" @@ -63,6 +68,7 @@ static int usage(int e, char* prog_name) "\t-e, --boot-args \tXNU boot arguments\n" "\t-f, --fakefs \t\t\t\tBoots fakefs\n" "\t-h, --help\t\t\t\tShow this help\n" + "\t-i, --override-checkra1n \t\tOverride checkra1n\n" "\t-k, --override-pongo \t\tOverride Pongo image\n" "\t-K, --override-kpf \t\tOverride kernel patchfinder\n" "\t-l, --rootless\t\t\t\tBoots rootless. This is the default\n" @@ -92,9 +98,9 @@ int optparse(int argc, char* argv[]) { int index; while ((opt = getopt_long(argc, argv, #ifdef DEV_BUILD - "cCDhpvVldsOLtfPe:o:r:K:k:1:", + "12cCDhpvVldsOLtfPe:o:r:K:k:i:", #else - "cCDhpvVldsOLfPe:o:r:K:k:1:", + "cCDhpvVldsOLfPe:o:r:K:k:i:", #endif longopts, NULL)) != -1) { @@ -184,7 +190,7 @@ int optparse(int argc, char* argv[]) { return -1; } break; - case '1': {}; + case 'i': {}; struct stat st; if (stat(optarg, &st) != 0) { LOG(LOG_FATAL, "cannot stat external checkra1n file: %d (%s)", errno, strerror(errno)); @@ -203,6 +209,12 @@ int optparse(int argc, char* argv[]) { case 't': use_tui = true; break; + case '1': + palerain_flags |= palerain_option_test1; + break; + case '2': + palerain_flags |= palerain_option_test2; + break; #endif case checkrain_option_force_revert: checkrain_flags |= checkrain_option_force_revert;