ifdef ROOTFUL

This commit is contained in:
Nick Chan committed 2023-03-29 12:22:58 +08:00
1 parent 2a9f65c870
commit f37643b93e
3 files changed
+49 -10

No files matched your search

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