diff --git a/include/kerninfo.h b/include/kerninfo.h index 9a7d28d..477cae6 100644 --- a/include/kerninfo.h +++ b/include/kerninfo.h @@ -60,6 +60,7 @@ #define palerain_option_setup_rootful_forced (1 << 3) /* create fakefs over an existing one */ #define palerain_option_setup_partial_root (1 << 4) /* fakefs creating should be partial */ #define palerain_option_checkrain_is_clone (1 << 5) /* supplied checkra1n is checkra1n clone */ +#define palerain_option_rootless_livefs (1 << 6) /* mount root livefs on rootless */ #ifdef DEV_BUILD #define palerain_option_test1 (1 << 29) diff --git a/src/Makefile b/src/Makefile index 4e85c4f..5c3c567 100644 --- a/src/Makefile +++ b/src/Makefile @@ -14,33 +14,39 @@ endif ifeq ($(FORCE_HELPER),1) OBJECTS += xxd-libcheckra1nhelper.dylib.o CFLAGS += -DFORCE_HELPER +BUILD_OPTIONS += FORCE_HELPER endif ifneq ($(NO_RAMDISK),1) OBJECTS += xxd-ramdisk.dmg.o else CFLAGS += -DNO_RAMDISK +BUILD_OPTIONS += NO_RAMDISK endif ifneq ($(NO_KPF),1) OBJECTS += xxd-checkra1n-kpf-pongo.o else CFLAGS += -DNO_KPF +BUILD_OPTIONS += NO_KPF endif ifneq ($(NO_OVERLAY),1) OBJECTS += xxd-binpack.dmg.o else CFLAGS += -DNO_OVERLAY +BUILD_OPTIONS += NO_OVERLAY endif ifneq ($(NO_CHECKRAIN),1) OBJECTS += xxd-checkra1n.o else CFLAGS += -DNO_CHECKRAIN +BUILD_OPTIONS += NO_CHECKRAIN endif ifneq ($(NO_CUSTOM_PONGO),1) OBJECTS += xxd-Pongo.bin.o else CFLAGS += -DNO_CUSTOM_PONGO +BUILD_OPTIONS += NO_CUSTOM_PONGO endif ifeq ($(DEV_BUILD),1) @@ -57,6 +63,7 @@ ifneq ($(USE_LIBUSB),1) OBJECTS += usb_iokit.o else LIBS += -framework SystemConfiguration -framework Security +BUILD_OPTIONS += USE_LIBUSB endif # add lto and debug symbols for lto CFLAGS += -flto=full -g @@ -71,6 +78,17 @@ CFLAGS += -DUSE_LIBUSB=1 LIBS += $(DEP)/lib/libusb-1.0.a endif +ifneq ($(ROOTFUL),0) +CFLAGS += -DROOTFUL=1 +BUILD_OPTIONS += ROOTFUL +endif + +ifeq ($(BUILD_OPTIONS),) +BUILD_OPTIONS = (none) +endif + +CFLAGS += -DBUILD_OPTIONS=\""$(BUILD_OPTIONS)"\" + checkra1n-%: curl -LO https://assets.checkra.in/downloads/preview/$(CHECKRA1N_VERSION)/$@ chmod 755 $@ diff --git a/src/optparse.c b/src/optparse.c index 135cee1..371d431 100644 --- a/src/optparse.c +++ b/src/optparse.c @@ -18,8 +18,10 @@ checkrain_option_t host_flags = 0; checkrain_option_p host_flags_p = &host_flags; static struct option longopts[] = { +#ifdef ROOTFUL {"setup-partial-fakefs", no_argument, NULL, 'B'}, {"setup-fakefs", no_argument, NULL, 'c'}, +#endif {"dfuhelper", no_argument, NULL, 'D'}, {"help", no_argument, NULL, 'h'}, {"pongo-shell", no_argument, NULL, 'p'}, @@ -27,7 +29,9 @@ static struct option longopts[] = { {"debug-logging", no_argument, NULL, 'v'}, {"verbose-boot", no_argument, NULL, 'V'}, {"boot-args", required_argument, NULL, 'e'}, +#ifdef ROOTFUL {"fakefs", no_argument, NULL, 'f'}, +#endif {"rootless", no_argument, NULL, 'l'}, {"jbinit-log-to-file", no_argument, NULL, 'L'}, {"demote", no_argument, NULL, 'd'}, @@ -55,12 +59,15 @@ static struct option longopts[] = { static int usage(int e, char* prog_name) { fprintf(stderr, + "Usage: %s [-" + "DEhpvVldsSLtRnPI" #ifdef DEV_BUILD - "Usage: %s [-12cCdDEfhIlLnOpRsStvV]" -#else - "Usage: %s [-cCdDEfhIlLnOpRsSvV]" + "12" #endif - " [-e boot arguments] [-k Pongo image] [-o overlay file] [-r ramdisk file] [-K KPF file] [-i checkra1n file]\n" +#ifdef ROOTFUL + "cfB" +#endif + "] [-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.0-16.3.1 arm64 jailbreaking tool\n\n" "\t--version\t\t\t\tPrint version\n" @@ -69,13 +76,17 @@ static int usage(int e, char* prog_name) "\t-1, --test1\t\t\t\tSet palerain_option_test1\n" "\t-2, --test2\t\t\t\tSet palerain_option_test2\n" #endif +#ifdef ROOTFUL "\t-B, --setup-partial-fakefs\t\tSetup partial fakefs\n" "\t-c, --setup-fakefs\t\t\tSetup fakefs\n" +#endif "\t-d, --demote\t\t\t\tDemote\n" - "\t-D, --dfuhelper\t\t\tExit after entering DFU\n" + "\t-D, --dfuhelper\t\t\t\tExit after entering DFU\n" "\t-e, --boot-args \tXNU boot arguments\n" "\t-E, --enter-recovery\t\t\tEnter recovery mode\n" +#ifdef ROOTFUL "\t-f, --fakefs \t\t\t\tBoots fakefs\n" +#endif "\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" @@ -90,7 +101,7 @@ static int usage(int e, char* prog_name) "\t-r, --override-ramdisk \t\tOverride ramdisk\n" "\t-R, --reboot-device\t\t\tReboot connected device in normal mode\n" "\t-s, --safe-mode\t\t\t\tEnter safe mode\n" - "\t-S, --no-colors\t\t\tDisable colors on the command line\n" + "\t-S, --no-colors\t\t\t\tDisable colors on the command line\n" "\t-v, --debug-logging\t\t\tEnable debug logging\n" "\t\tThis option can be repeated for extra verbosity.\n" "\t-V, --verbose-boot\t\t\tVerbose boot\n" @@ -108,15 +119,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, + while ((opt = getopt_long(argc, argv, + "DEhpvVldsSLtRnPIe:o:r:K:k:i:" #ifdef DEV_BUILD - "12BcDEhpvVldsSLftRnPIe:o:r:K:k:i:", -#else - "BcDEhpvVldsSLfRnPIe:o:r:K:k:i:", + "12" #endif - longopts, NULL)) != -1) +#ifdef ROOTFUL + "fcB" +#endif + ,longopts, NULL)) != -1) { switch (opt) { +#ifdef ROOTFUL case 'B': palerain_flags |= palerain_option_setup_partial_root; palerain_flags |= palerain_option_setup_rootful; @@ -126,6 +140,7 @@ int optparse(int argc, char* argv[]) { palerain_flags |= palerain_option_setup_rootful; kpf_flags |= checkrain_option_verbose_boot; break; +#endif case 'p': host_flags |= host_option_pongo_exit; break; @@ -154,13 +169,17 @@ int optparse(int argc, char* argv[]) { } snprintf(xargs_cmd, sizeof(xargs_cmd), "xargs %s", optarg); break; +#ifdef ROOTFUL case 'f': snprintf(rootfs_cmd, sizeof(rootfs_cmd), "rootfs %s", optarg); snprintf(dtpatch_cmd, 0x20, "dtpatch %s", optarg); palerain_flags |= palerain_option_rootful; break; +#endif case 'l': +#ifdef ROOTFUL palerain_flags &= ~palerain_option_rootful; +#endif break; case 'L': palerain_flags |= palerain_option_jbinit_log_to_file; @@ -293,6 +312,7 @@ int optparse(int argc, char* argv[]) { #else "USB backend: IOKit\n" #endif + "Build options: " BUILD_OPTIONS "\n" ); return 0; }