Skip to content

Commit

Permalink
Fix preboot path permissions on rootless
Browse files Browse the repository at this point in the history
  • Loading branch information
asdfugil committed Aug 9, 2024
1 parent 1e836ae commit cbe4c4e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/libjailbreak/libjailbreak.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ const char* jailbreak_str_pinfo_flag(uint64_t flag);
xpc_object_t jailbreak_send_jailbreakd_message_with_reply_sync(xpc_object_t xdict);
xpc_object_t jailbreak_send_jailbreakd_command_with_reply_sync(uint64_t cmd);
int jailbreak_send_launchd_message(xpc_object_t xdict, xpc_object_t *xreply);
int jailbreak_get_bmhash_path(char jbPath[150]);

#endif
11 changes: 11 additions & 0 deletions src/libjailbreak/prebootpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,14 @@ int jailbreak_get_prebootPath(char jbPath[150]) {
}
return KERN_SUCCESS;
}

int jailbreak_get_bmhash_path(char jbPath[150]) {
struct utsname name;
int ret = uname(&name);
if (ret) return errno;
if (atoi(name.release) < 20) return ENOTSUP;
char bmhash[97];
jailbreak_get_bmhash(bmhash);
snprintf(jbPath, 150, "/private/preboot/%s", bmhash);
return 0;
}
17 changes: 17 additions & 0 deletions src/payload/loader/sysstatuscheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <sys/kern_memorystatus.h>
#include <sys/snapshot.h>
#include <sys/mount.h>
#include <sys/stat.h>

uint32_t dyld_get_active_platform(void);

Expand Down Expand Up @@ -233,6 +234,22 @@ int sysstatuscheck(uint32_t __unused payload_options, uint64_t pflags) {
} else {
remove_bogus_var_jb();
create_var_jb();
char fixupPath[150];
if (jailbreak_get_prebootPath(fixupPath) == 0) {
chown(fixupPath, 0, 0);
chmod(fixupPath, 0755);
char fixupPath2[160];
snprintf(fixupPath2, 160, "%s/..", fixupPath);
chown(fixupPath2, 0, 0);
chmod(fixupPath2, 0755);
}
if (jailbreak_get_bmhash_path(fixupPath) == 0) {
chown(fixupPath, 0, 0);
chmod(fixupPath, 0755);
}
chown("/private/preboot", 0, 0);
chmod("/private/preboot", 0755);

#ifdef HAVE_SYSTEMWIDE_IOSEXEC
if (access("/var/jb", F_OK) == 0) {
fixup_databases();
Expand Down

0 comments on commit cbe4c4e

Please sign in to comment.