summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Benjamin BOURGEAIS2021-05-06 17:34:29 +0200
committerGravatar Benjamin BOURGEAIS2021-05-08 14:16:50 +0200
commitfffe2e3972840f3a9be865f950383ebd41f5061d (patch)
treea300b30adc2355ca4ec6882aed905637a13d79ea
parentb936ff28a6882c4da537473197673bb1520d8ce7 (diff)
downloadidevicerestore-fffe2e3972840f3a9be865f950383ebd41f5061d.tar.gz
idevicerestore-fffe2e3972840f3a9be865f950383ebd41f5061d.tar.bz2
dfu: Add special handling for sending the local policy component
-rw-r--r--src/dfu.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/src/dfu.c b/src/dfu.c
index fab05de..f22e254 100644
--- a/src/dfu.c
+++ b/src/dfu.c
@@ -151,34 +151,47 @@ int dfu_send_buffer(struct idevicerestore_client_t* client, unsigned char* buffe
int dfu_send_component(struct idevicerestore_client_t* client, plist_t build_identity, const char* component) {
char* path = NULL;
- if (client->tss) {
- if (tss_response_get_path_by_entry(client->tss, component, &path) < 0) {
- debug("NOTE: No path for component %s in TSS, will fetch from build_identity\n", component);
- }
- }
- if (!path) {
- if (build_identity_get_component_path(build_identity, component, &path) < 0) {
- error("ERROR: Unable to get path for component '%s'\n", component);
- free(path);
- return -1;
- }
+ // Use a specific TSS ticket for the Ap,LocalPolicy component
+ plist_t tss = client->tss;
+ if (strcmp(component, "Ap,LocalPolicy") == 0) {
+ tss = client->tss_localpolicy;
}
unsigned char* component_data = NULL;
unsigned int component_size = 0;
- if (extract_component(client->ipsw, path, &component_data, &component_size) < 0) {
- error("ERROR: Unable to extract component: %s\n", component);
+ if (strcmp(component, "Ap,LocalPolicy") == 0) {
+ // If Ap,LocalPolicy => Inject an empty policy
+ component_data = malloc(sizeof(lpol_file));
+ component_size = sizeof(lpol_file);
+ memcpy(component_data, lpol_file, component_size);
+ } else {
+ if (tss) {
+ if (tss_response_get_path_by_entry(tss, component, &path) < 0) {
+ debug("NOTE: No path for component %s in TSS, will fetch from build_identity\n", component);
+ }
+ }
+ if (!path) {
+ if (build_identity_get_component_path(build_identity, component, &path) < 0) {
+ error("ERROR: Unable to get path for component '%s'\n", component);
+ free(path);
+ return -1;
+ }
+ }
+
+ if (extract_component(client->ipsw, path, &component_data, &component_size) < 0) {
+ error("ERROR: Unable to extract component: %s\n", component);
+ free(path);
+ return -1;
+ }
free(path);
- return -1;
+ path = NULL;
}
- free(path);
- path = NULL;
unsigned char* data = NULL;
uint32_t size = 0;
- if (personalize_component(component, component_data, component_size, client->tss, &data, &size) < 0) {
+ if (personalize_component(component, component_data, component_size, tss, &data, &size) < 0) {
error("ERROR: Unable to get personalized component: %s\n", component);
free(component_data);
return -1;
@@ -209,7 +222,6 @@ int dfu_send_component(struct idevicerestore_client_t* client, plist_t build_ide
info("Sending %s (%d bytes)...\n", component, size);
- // FIXME: Did I do this right????
irecv_error_t err = irecv_send_buffer(client->dfu->client, data, size, 1);
if (err != IRECV_E_SUCCESS) {
error("ERROR: Unable to send %s component: %s\n", component, irecv_strerror(err));