From 4ba3785d215a9807c70d408f1e6b9b7d07fc8c27 Mon Sep 17 00:00:00 2001 From: Nick Chan Date: Tue, 2 Jan 2024 05:25:39 +0800 Subject: [PATCH] Remove some unneeded fakefs setup boot commands --- src/payload/loader/setup_fakefs.c | 11 ----------- src/payload_dylib/main.c | 23 ++++++++++++----------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/payload/loader/setup_fakefs.c b/src/payload/loader/setup_fakefs.c index 9c82065..c6a21b7 100644 --- a/src/payload/loader/setup_fakefs.c +++ b/src/payload/loader/setup_fakefs.c @@ -102,10 +102,6 @@ int copyfile_fakefs_cb(int what, int stage, copyfile_state_t state, const char * int setup_fakefs(uint32_t payload_options, struct paleinfo* pinfo_p) { CHECK_ERROR(runCommand((char*[]){ "/sbin/fsck", "-qL", NULL }), 1, "fsck failed"); - CHECK_ERROR(runCommand((char*[]){ "/sbin/mount", "-P", "1", NULL }), 1, "mount-phase-1 failed"); - CHECK_ERROR(runCommand((char*[]){ "/usr/libexec/init_data_protection", NULL }), 1, "init_data_protection failed"); - CHECK_ERROR(runCommand((char*[]){ "/sbin/mount", "-P", "2", NULL }), 1, "mount-phase-2 failed"); - CHECK_ERROR(runCommand((char*[]){ "/usr/libexec/keybagd", "--init", NULL }), 1, "keybag failed"); struct statfs rootfs_st; CHECK_ERROR(statfs("/", &rootfs_st), 1, "statfs / failed"); @@ -279,16 +275,9 @@ int setup_fakefs(uint32_t payload_options, struct paleinfo* pinfo_p) { "\n" "=========================================================\n" ); - - runCommand((char*[]){ "/usr/libexec/seputil", "--gigalocker-shutdown", NULL }); - - if (access("/sbin/umount", F_OK) == 0) - runCommand((char*[]){ "/sbin/umount", "-a", NULL }); - unmount("/private/var", MNT_FORCE); unmount("/cores/fs/real", MNT_FORCE); unmount("/cores/fs/fake", MNT_FORCE); - unmount("/private/xarts", MNT_FORCE); if (access("/sbin/umount", F_OK) == 0) runCommand((char*[]){ "/sbin/umount", "-a", NULL }); diff --git a/src/payload_dylib/main.c b/src/payload_dylib/main.c index c91b6c3..507cd64 100644 --- a/src/payload_dylib/main.c +++ b/src/payload_dylib/main.c @@ -75,6 +75,17 @@ __attribute__((constructor))void launchd_hook_main(void) { spin(); } + if ((pflags & palerain_option_setup_rootful)) { + int32_t initproc_started = 1; + CHECK_ERROR(sysctlbyname("kern.initproc_spawned", NULL, NULL, &initproc_started, 4), "sysctl kern.initproc_spawned=1"); + CHECK_ERROR(unmount("/cores/binpack/Applications", MNT_FORCE), "unmount(/cores/binpack/Applications)"); + CHECK_ERROR(unmount("/cores/binpack", MNT_FORCE), "unmount(/cores/binpack)"); + printf("Rebooting\n"); + kern_return_t failed = host_reboot(mach_host_self(), 0x1000); + fprintf(stderr, "reboot failed: %d (%s)\n", failed, mach_error_string(failed)); + spin(); + } + if ((pflags & palerain_option_verbose_boot) == 0) bootscreend_main(); void* systemhook_handle = dlopen(HOOK_DYLIB_PATH, RTLD_NOW); if (!systemhook_handle) { @@ -98,20 +109,10 @@ __attribute__((constructor))void launchd_hook_main(void) { fprintf(stderr, "symbol MSHookFunction not found in " ELLEKIT_PATH ": %s\n", dlerror()); spin(); } - + initSpawnHooks(); InitDaemonHooks(); - if ((pflags & palerain_option_setup_rootful)) { - int32_t initproc_started = 1; - CHECK_ERROR(sysctlbyname("kern.initproc_spawned", NULL, NULL, &initproc_started, 4), "sysctl kern.initproc_spawned=1"); - CHECK_ERROR(unmount("/cores/binpack/Applications", MNT_FORCE), "unmount(/cores/binpack/Applications)"); - CHECK_ERROR(unmount("/cores/binpack", MNT_FORCE), "unmount(/cores/binpack)"); - printf("Rebooting\n"); - kern_return_t failed = host_reboot(mach_host_self(), 0x1000); - fprintf(stderr, "reboot failed: %d (%s)\n", failed, mach_error_string(failed)); - spin(); - } printf("=========== bye from payload.dylib ===========\n"); close(fd_console);