diff options
-rw-r--r-- | src/dfu.c | 48 |
1 files changed, 30 insertions, 18 deletions
@@ -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)); |