galaxy requested changes

This commit is contained in:
Nick Chan committed 2023-02-03 13:22:07 +08:00
1 parent 23b76ec6d7
commit 4692a33dc0
6 files changed
+48 -17

No files matched your search

+2 -1
View File
@@ -126,6 +126,7 @@ extern char palerain_flags_cmd[0x20];
extern char kpf_flags_cmd[0x20];
extern char dtpatch_cmd[0x20];
extern char rootfs_cmd[512];
extern char* ext_checkra1n;
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 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);
void* pongo_helper(void* ptr);
+3 -3
View File
@@ -363,9 +363,9 @@ int recvinfo_cmd(recvinfo_t* info, const uint64_t ecid) {
}
info->mode = mode;
info->cpid = device->chip_id;
strncpy(info->product_type, device->product_type, 0x20);
strncpy(info->display_name, device->display_name, 0x20);
strncpy(info->iboot_ver, (ibootver) ? ibootver : "", 0x20);
snprintf(info->product_type, 0x20, "%s", device->product_type);
snprintf(info->display_name, 0x20, "%s", device->display_name);
snprintf(info->iboot_ver, 0x20, "%s", (ibootver) ? ibootver : "");
free(ibootver);
irecv_close(client);
return 0;
+20 -8
View File
@@ -20,29 +20,40 @@ extern char **environ;
#include <common.h>
#include <xxd-embedded.h>
char* pongo_path = NULL;
char* ext_checkra1n = NULL;
void exec_checkra1n() {
int exec_checkra1n() {
LOG(LOG_INFO, "About to execute checkra1n");
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);
if (fd == -1) {
LOG(LOG_FATAL, "Cannot open temporary file: %d (%s)", errno, strerror(errno));
return;
return -1;
}
ssize_t didWrite = write(fd, checkra1n, 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));
close(fd);
unlink(checkra1n_path);
return;
return -1;
}
close(fd);
ret = chmod(checkra1n_path, 0700);
if (ret) {
LOG(LOG_FATAL, "Cannot chmod %s: %d (%s)", checkra1n_path, errno, strerror(errno));
unlink(checkra1n_path);
return -1;
}
checkra1n_exec: {};
char args[0x10] = "-pE";
if (demote) strncat(args, "d", 0xf);
if (verbose >= 2) strncat(args, "v", 0xf);
@@ -59,12 +70,13 @@ void exec_checkra1n() {
pongo_path = NULL;
if (ret) {
LOG(LOG_FATAL, "Cannot posix spawn %s: %d (%s)", checkra1n_path, errno, strerror(errno));
unlink(checkra1n_path);
return;
if (ext_checkra1n != NULL) unlink(checkra1n_path);
return -1;
}
LOG(LOG_VERBOSE2, "%s spawned successfully", checkra1n_path);
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);
return;
return 0;
}
+1 -1
View File
@@ -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;
*value = (char*)malloc(str_len + 1);
strncpy(*value, str_start, str_len);
snprintf(*value, str_len, "%s", str_start);
(*value)[str_len] = '\0';
free(resp);
+2 -1
View File
@@ -116,7 +116,7 @@ int palera1n(int argc, char *argv[]) {
set_spin(0);
if (dfuhelper_only || device_has_booted)
goto normal_exit;
exec_checkra1n();
if (exec_checkra1n()) goto cleanup;
if (pongo_exit || demote)
goto normal_exit;
set_spin(1);
@@ -162,6 +162,7 @@ cleanup:
munmap(override_overlay.ptr, (size_t)override_overlay.len);
close(override_overlay.fd);
}
if (ext_checkra1n != NULL) free(ext_checkra1n);
pthread_mutex_destroy(&log_mutex);
pthread_mutex_destroy(&spin_mutex);
pthread_mutex_destroy(&found_pongo_mutex);
+20 -3
View File
@@ -35,6 +35,7 @@ static struct option longopts[] = {
{"override-ramdisk", required_argument, NULL, 'r'},
{"override-kpf", required_argument, NULL, 'K'},
{"disable-ohio", no_argument, NULL, 'O'},
{"override-checkra1n", required_argument, NULL, '1'},
#ifdef DEV_BUILD
{"tui", no_argument, NULL, 't'},
#endif
@@ -49,7 +50,7 @@ static int usage(int e, char* prog_name)
#else
"Usage: %s [-cCDhpvVldsOLf]"
#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"
"iOS/iPadOS 15+ arm64 jailbreaking tool\n\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-r, --override-ramdisk <file>\t\tOverride ramdisk\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"
#ifdef DEV_BUILD
"\t-t, --tui\t\t\t\tTerminal user interface\n"
#endif
"\nEnvironmental variables:\n"
"\tTMPDIR\t\ttemporary diretory (path the built-in checkra1n will be extracted to)\n"
,
prog_name);
exit(e);
@@ -87,9 +92,9 @@ int optparse(int argc, char* argv[]) {
int index;
while ((opt = getopt_long(argc, argv,
#ifdef DEV_BUILD
"cCDhpvVldsOLtfPe:o:r:K:k:",
"cCDhpvVldsOLtfPe:o:r:K:k:1:",
#else
"cCDhpvVldsOLfPe:o:r:K:k:",
"cCDhpvVldsOLfPe:o:r:K:k:1:",
#endif
longopts, NULL)) != -1)
{
@@ -179,6 +184,18 @@ int optparse(int argc, char* argv[]) {
return -1;
}
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':
ohio = false;
break;