Skip to content

Commit

Permalink
Remove some unneeded fakefs setup boot commands
Browse files Browse the repository at this point in the history
  • Loading branch information
asdfugil committed Jan 1, 2024
1 parent ea869ac commit 4ba3785
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
11 changes: 0 additions & 11 deletions src/payload/loader/setup_fakefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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 });
Expand Down
23 changes: 12 additions & 11 deletions src/payload_dylib/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit 4ba3785

Please sign in to comment.