mirror of
https://github.com/palera1n/palera1n.git
synced 2026-10-23 18:49:48 +02:00
galaxy requested changes
This commit is contained in:
1 parent
23b76ec6d7
commit
4692a33dc0
6 files changed
+48
-17
No files matched your search
+2
-1
@@ -126,6 +126,7 @@ extern char palerain_flags_cmd[0x20];
|
|||||||
extern char kpf_flags_cmd[0x20];
|
extern char kpf_flags_cmd[0x20];
|
||||||
extern char dtpatch_cmd[0x20];
|
extern char dtpatch_cmd[0x20];
|
||||||
extern char rootfs_cmd[512];
|
extern char rootfs_cmd[512];
|
||||||
|
extern char* ext_checkra1n;
|
||||||
|
|
||||||
extern bool palerain_version;
|
extern bool palerain_version;
|
||||||
|
|
||||||
@@ -146,7 +147,7 @@ int recvinfo_cmd(recvinfo_t* info, const uint64_t ecid);
|
|||||||
int autoboot_cmd(const uint64_t ecid);
|
int autoboot_cmd(const uint64_t ecid);
|
||||||
int exitrecv_cmd(const uint64_t ecid);
|
int exitrecv_cmd(const uint64_t ecid);
|
||||||
|
|
||||||
void exec_checkra1n();
|
int exec_checkra1n();
|
||||||
int override_file(override_file_t *finfo, niarelap_file_t** orig, unsigned int *orig_len, char *filename);
|
int override_file(override_file_t *finfo, niarelap_file_t** orig, unsigned int *orig_len, char *filename);
|
||||||
void* pongo_helper(void* ptr);
|
void* pongo_helper(void* ptr);
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -363,9 +363,9 @@ int recvinfo_cmd(recvinfo_t* info, const uint64_t ecid) {
|
|||||||
}
|
}
|
||||||
info->mode = mode;
|
info->mode = mode;
|
||||||
info->cpid = device->chip_id;
|
info->cpid = device->chip_id;
|
||||||
strncpy(info->product_type, device->product_type, 0x20);
|
snprintf(info->product_type, 0x20, "%s", device->product_type);
|
||||||
strncpy(info->display_name, device->display_name, 0x20);
|
snprintf(info->display_name, 0x20, "%s", device->display_name);
|
||||||
strncpy(info->iboot_ver, (ibootver) ? ibootver : "", 0x20);
|
snprintf(info->iboot_ver, 0x20, "%s", (ibootver) ? ibootver : "");
|
||||||
free(ibootver);
|
free(ibootver);
|
||||||
irecv_close(client);
|
irecv_close(client);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
+20
-8
@@ -20,29 +20,40 @@ extern char **environ;
|
|||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <xxd-embedded.h>
|
#include <xxd-embedded.h>
|
||||||
char* pongo_path = NULL;
|
char* pongo_path = NULL;
|
||||||
|
char* ext_checkra1n = NULL;
|
||||||
|
|
||||||
void exec_checkra1n() {
|
int exec_checkra1n() {
|
||||||
LOG(LOG_INFO, "About to execute checkra1n");
|
LOG(LOG_INFO, "About to execute checkra1n");
|
||||||
int fd, ret;
|
int fd, ret;
|
||||||
char checkra1n_path[] = "/tmp/checkra1n.XXXXXX";
|
char* checkra1n_path = NULL;
|
||||||
|
if (ext_checkra1n != NULL) {
|
||||||
|
checkra1n_path = ext_checkra1n;
|
||||||
|
goto checkra1n_exec;
|
||||||
|
}
|
||||||
|
if (getenv("TMPDIR") != NULL) {
|
||||||
|
checkra1n_path = malloc(strlen(getenv("TMPDIR")) + 20);
|
||||||
|
snprintf(checkra1n_path, strlen(getenv("TMPDIR")) + 20, "%s/checkra1n.XXXXXX", getenv("TMPDIR"));
|
||||||
|
} else checkra1n_path = "/tmp/checkra1n.XXXXXX";
|
||||||
fd = mkstemp(checkra1n_path);
|
fd = mkstemp(checkra1n_path);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
LOG(LOG_FATAL, "Cannot open temporary file: %d (%s)", errno, strerror(errno));
|
LOG(LOG_FATAL, "Cannot open temporary file: %d (%s)", errno, strerror(errno));
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
ssize_t didWrite = write(fd, checkra1n, checkra1n_len);
|
ssize_t didWrite = write(fd, checkra1n, checkra1n_len);
|
||||||
if (didWrite != (ssize_t)checkra1n_len) {
|
if (didWrite != (ssize_t)checkra1n_len) {
|
||||||
LOG(LOG_FATAL, "Size written does not match expected: %lld != %d: %d (%s)", didWrite, checkra1n_len, errno, strerror(errno));
|
LOG(LOG_FATAL, "Size written does not match expected: %lld != %d: %d (%s)", didWrite, checkra1n_len, errno, strerror(errno));
|
||||||
close(fd);
|
close(fd);
|
||||||
unlink(checkra1n_path);
|
unlink(checkra1n_path);
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
ret = chmod(checkra1n_path, 0700);
|
ret = chmod(checkra1n_path, 0700);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
LOG(LOG_FATAL, "Cannot chmod %s: %d (%s)", checkra1n_path, errno, strerror(errno));
|
LOG(LOG_FATAL, "Cannot chmod %s: %d (%s)", checkra1n_path, errno, strerror(errno));
|
||||||
unlink(checkra1n_path);
|
unlink(checkra1n_path);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
checkra1n_exec: {};
|
||||||
char args[0x10] = "-pE";
|
char args[0x10] = "-pE";
|
||||||
if (demote) strncat(args, "d", 0xf);
|
if (demote) strncat(args, "d", 0xf);
|
||||||
if (verbose >= 2) strncat(args, "v", 0xf);
|
if (verbose >= 2) strncat(args, "v", 0xf);
|
||||||
@@ -59,12 +70,13 @@ void exec_checkra1n() {
|
|||||||
pongo_path = NULL;
|
pongo_path = NULL;
|
||||||
if (ret) {
|
if (ret) {
|
||||||
LOG(LOG_FATAL, "Cannot posix spawn %s: %d (%s)", checkra1n_path, errno, strerror(errno));
|
LOG(LOG_FATAL, "Cannot posix spawn %s: %d (%s)", checkra1n_path, errno, strerror(errno));
|
||||||
unlink(checkra1n_path);
|
if (ext_checkra1n != NULL) unlink(checkra1n_path);
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
LOG(LOG_VERBOSE2, "%s spawned successfully", checkra1n_path);
|
LOG(LOG_VERBOSE2, "%s spawned successfully", checkra1n_path);
|
||||||
sleep(2);
|
sleep(2);
|
||||||
unlink(checkra1n_path);
|
if (ext_checkra1n != NULL) unlink(checkra1n_path);
|
||||||
|
if (getenv("TMPDIR") && ext_checkra1n == NULL) free(checkra1n_path);
|
||||||
waitpid(pid, NULL, 0);
|
waitpid(pid, NULL, 0);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -205,7 +205,7 @@ int lockdown_get_string_value(int fd, const char* domain, const char* key, char*
|
|||||||
}
|
}
|
||||||
size_t str_len = p - str_start;
|
size_t str_len = p - str_start;
|
||||||
*value = (char*)malloc(str_len + 1);
|
*value = (char*)malloc(str_len + 1);
|
||||||
strncpy(*value, str_start, str_len);
|
snprintf(*value, str_len, "%s", str_start);
|
||||||
(*value)[str_len] = '\0';
|
(*value)[str_len] = '\0';
|
||||||
free(resp);
|
free(resp);
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -116,7 +116,7 @@ int palera1n(int argc, char *argv[]) {
|
|||||||
set_spin(0);
|
set_spin(0);
|
||||||
if (dfuhelper_only || device_has_booted)
|
if (dfuhelper_only || device_has_booted)
|
||||||
goto normal_exit;
|
goto normal_exit;
|
||||||
exec_checkra1n();
|
if (exec_checkra1n()) goto cleanup;
|
||||||
if (pongo_exit || demote)
|
if (pongo_exit || demote)
|
||||||
goto normal_exit;
|
goto normal_exit;
|
||||||
set_spin(1);
|
set_spin(1);
|
||||||
@@ -162,6 +162,7 @@ cleanup:
|
|||||||
munmap(override_overlay.ptr, (size_t)override_overlay.len);
|
munmap(override_overlay.ptr, (size_t)override_overlay.len);
|
||||||
close(override_overlay.fd);
|
close(override_overlay.fd);
|
||||||
}
|
}
|
||||||
|
if (ext_checkra1n != NULL) free(ext_checkra1n);
|
||||||
pthread_mutex_destroy(&log_mutex);
|
pthread_mutex_destroy(&log_mutex);
|
||||||
pthread_mutex_destroy(&spin_mutex);
|
pthread_mutex_destroy(&spin_mutex);
|
||||||
pthread_mutex_destroy(&found_pongo_mutex);
|
pthread_mutex_destroy(&found_pongo_mutex);
|
||||||
|
|||||||
+20
-3
@@ -35,6 +35,7 @@ static struct option longopts[] = {
|
|||||||
{"override-ramdisk", required_argument, NULL, 'r'},
|
{"override-ramdisk", required_argument, NULL, 'r'},
|
||||||
{"override-kpf", required_argument, NULL, 'K'},
|
{"override-kpf", required_argument, NULL, 'K'},
|
||||||
{"disable-ohio", no_argument, NULL, 'O'},
|
{"disable-ohio", no_argument, NULL, 'O'},
|
||||||
|
{"override-checkra1n", required_argument, NULL, '1'},
|
||||||
#ifdef DEV_BUILD
|
#ifdef DEV_BUILD
|
||||||
{"tui", no_argument, NULL, 't'},
|
{"tui", no_argument, NULL, 't'},
|
||||||
#endif
|
#endif
|
||||||
@@ -49,7 +50,7 @@ static int usage(int e, char* prog_name)
|
|||||||
#else
|
#else
|
||||||
"Usage: %s [-cCDhpvVldsOLf]"
|
"Usage: %s [-cCDhpvVldsOLf]"
|
||||||
#endif
|
#endif
|
||||||
" [-e boot arguments] [-k Pongo image] [-o overlay file] [-r ramdisk file] [-K KPF file]\n"
|
" [-e boot arguments] [-k Pongo image] [-o overlay file] [-r ramdisk file] [-K KPF file] [-1 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+ arm64 jailbreaking tool\n\n"
|
"iOS/iPadOS 15+ arm64 jailbreaking tool\n\n"
|
||||||
"\t--version\t\t\t\tPrint version\n"
|
"\t--version\t\t\t\tPrint version\n"
|
||||||
@@ -73,10 +74,14 @@ static int usage(int e, char* prog_name)
|
|||||||
"\t-o, --override-overlay <file>\t\tOverride overlay\n"
|
"\t-o, --override-overlay <file>\t\tOverride overlay\n"
|
||||||
"\t-r, --override-ramdisk <file>\t\tOverride ramdisk\n"
|
"\t-r, --override-ramdisk <file>\t\tOverride ramdisk\n"
|
||||||
"\t-K, --override-kpf <file>\t\tOverride kernel patchfinder\n"
|
"\t-K, --override-kpf <file>\t\tOverride kernel patchfinder\n"
|
||||||
|
"\t-1, --override-checkra1n <file>\t\tOverride checkra1n\n"
|
||||||
"\t-O, --disable-ohio\t\t\tDisable Ohio\n"
|
"\t-O, --disable-ohio\t\t\tDisable Ohio\n"
|
||||||
|
|
||||||
#ifdef DEV_BUILD
|
#ifdef DEV_BUILD
|
||||||
"\t-t, --tui\t\t\t\tTerminal user interface\n"
|
"\t-t, --tui\t\t\t\tTerminal user interface\n"
|
||||||
#endif
|
#endif
|
||||||
|
"\nEnvironmental variables:\n"
|
||||||
|
"\tTMPDIR\t\ttemporary diretory (path the built-in checkra1n will be extracted to)\n"
|
||||||
,
|
,
|
||||||
prog_name);
|
prog_name);
|
||||||
exit(e);
|
exit(e);
|
||||||
@@ -87,9 +92,9 @@ int optparse(int argc, char* argv[]) {
|
|||||||
int index;
|
int index;
|
||||||
while ((opt = getopt_long(argc, argv,
|
while ((opt = getopt_long(argc, argv,
|
||||||
#ifdef DEV_BUILD
|
#ifdef DEV_BUILD
|
||||||
"cCDhpvVldsOLtfPe:o:r:K:k:",
|
"cCDhpvVldsOLtfPe:o:r:K:k:1:",
|
||||||
#else
|
#else
|
||||||
"cCDhpvVldsOLfPe:o:r:K:k:",
|
"cCDhpvVldsOLfPe:o:r:K:k:1:",
|
||||||
#endif
|
#endif
|
||||||
longopts, NULL)) != -1)
|
longopts, NULL)) != -1)
|
||||||
{
|
{
|
||||||
@@ -179,6 +184,18 @@ int optparse(int argc, char* argv[]) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case '1': {};
|
||||||
|
struct stat st;
|
||||||
|
if (stat(optarg, &st) != 0) {
|
||||||
|
LOG(LOG_FATAL, "cannot stat external checkra1n file: %d (%s)", errno, strerror(errno));
|
||||||
|
return -1;
|
||||||
|
} else if (!(st.st_mode & S_IXUSR) && !(st.st_mode & S_IXGRP) && !(st.st_mode & S_IXOTH)) {
|
||||||
|
LOG(LOG_FATAL, "%s is not executable", optarg);
|
||||||
|
return -1;
|
||||||
|
};
|
||||||
|
ext_checkra1n = calloc(1, strlen(optarg) + 1);
|
||||||
|
snprintf(ext_checkra1n, strlen(optarg) + 1, "%s", optarg);
|
||||||
|
break;
|
||||||
case 'O':
|
case 'O':
|
||||||
ohio = false;
|
ohio = false;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in new issue
Block a user