Skip to content

Commit

Permalink
fix some remount issues
Browse files Browse the repository at this point in the history
  • Loading branch information
asdfugil committed Dec 25, 2023
1 parent 339182e commit d4e0d9a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
5 changes: 4 additions & 1 deletion include/payload/payload.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <stdbool.h>
#include <paleinfo.h>
#include <unistd.h>
#include <sys/utsname.h>
#include <xpc/xpc.h>

#define CHECK_ERROR(action, loop, msg, ...) do { \
Expand Down Expand Up @@ -44,7 +45,9 @@ int runCommand(char* argv[]);
int setup_fakefs(uint32_t payload_options, struct paleinfo* pinfo_p);
int load_etc_rc_d(uint64_t pflags);
int create_var_jb();
int remount(int remount_now);
int remount(void);
int remount_rootfs(struct utsname* name_p);
int remount_preboot(struct utsname* name_p);
int get_platform();
void bootstrap(xpc_object_t xrequest, xpc_object_t xreply, struct paleinfo* pinfo);
int remove_jailbreak_files(uint64_t pflags);
Expand Down
19 changes: 18 additions & 1 deletion src/payload/jailbreakd/bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <pthread.h>
#define TARGET_OS_IPHONE 1
#include <spawn_private.h>
#include <sys/utsname.h>
#include <sys/spawn_internal.h>
#include <sys/kern_memorystatus.h>
#include <CoreFoundation/CoreFoundation.h>
Expand Down Expand Up @@ -106,7 +107,23 @@ void bootstrap(xpc_object_t xrequest, xpc_object_t xreply, struct paleinfo* pinf
return;
}

if (remount(1)) {
struct utsname name;
ret = uname(&name);
if (ret) {
xpc_dictionary_set_string(xreply, "errorDescription", "remount failed");
xpc_dictionary_set_int64(xreply, "error", errno);
return;
}

int (*remount_func)(struct utsname* name_p);
if (pinfo->flags & palerain_option_rootful) {
remount_func = &remount_rootfs;
} else {
remount_func = &remount_preboot;
}

ret = remount_func(&name);
if (ret) {
xpc_dictionary_set_string(xreply, "errorDescription", "remount failed");
xpc_dictionary_set_int64(xreply, "error", errno);
return;
Expand Down
5 changes: 2 additions & 3 deletions src/payload/loader/remount.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ int remount_preboot(struct utsname* name_p) {
return mount(fs.f_fstypename, fs.f_mntonname, mntflags, &arg);
}

int remount(int remount_now) {
int remount(void) {
struct utsname name;
uname(&name);
int ret;
if (
access("/.mount_rw", F_OK) == 0 ||
access("/.procursus_strapped", F_OK) == 0 ||
remount_now
access("/.procursus_strapped", F_OK) == 0
)
{
ret = remount_rootfs(&name);
Expand Down
2 changes: 1 addition & 1 deletion src/payload/loader/sysstatuscheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ int remove_jailbreak_files(uint64_t pflags) {
int fixup_databases(void);
int sysstatuscheck(uint32_t payload_options, uint64_t pflags) {
printf("plooshInit sysstatuscheck...\n");
remount(0);
remount();
enable_non_default_system_apps();
if (access("/private/var/dropbear_rsa_host_key", F_OK) != 0) {
printf("generating ssh host key...\n");
Expand Down

0 comments on commit d4e0d9a

Please sign in to comment.