summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Hector Martin2021-11-17 15:00:15 +0900
committerGravatar Hector Martin2021-11-17 15:11:53 +0900
commitef2db7acb3b177aab665267934e3d64c95cfe758 (patch)
treedc262ddfd2befb5195668d6938d5082763019b7e
parent17c80a650f963be7842ef15d83e93286a0129f7a (diff)
downloadidevicerestore-ef2db7acb3b177aab665267934e3d64c95cfe758.tar.gz
idevicerestore-ef2db7acb3b177aab665267934e3d64c95cfe758.tar.bz2
idevicerestore: Identify build identity by Variant (Monterey)
Monterey got rid of VariantSupportsGlobalSigning. Identify builds based on the Variant field (which seems to always have consistent values) instead of using RestoreBehavior and VariantSupportsGlobalSigning. Signed-off-by: Hector Martin <marcan@marcan.st>
-rw-r--r--src/idevicerestore.c91
-rw-r--r--src/idevicerestore.h7
-rw-r--r--src/restore.c13
3 files changed, 20 insertions, 91 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index 3892c73..192faef 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -824,14 +824,14 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
plist_dict_set_item(build_identity, "Manifest", manifest);
}
} else if (client->flags & FLAG_ERASE) {
- build_identity = build_manifest_get_build_identity_for_model_with_restore_behavior(buildmanifest, client->device->hardware_model, "Erase");
+ build_identity = build_manifest_get_build_identity_for_model_with_variant(buildmanifest, client->device->hardware_model, "Customer Erase Install (IPSW)");
if (build_identity == NULL) {
error("ERROR: Unable to find any build identities\n");
plist_free(buildmanifest);
return -1;
}
} else {
- build_identity = build_manifest_get_build_identity_for_model_with_restore_behavior(buildmanifest, client->device->hardware_model, "Update");
+ build_identity = build_manifest_get_build_identity_for_model_with_variant(buildmanifest, client->device->hardware_model, "Customer Upgrade Install (IPSW)");
if (!build_identity) {
build_identity = build_manifest_get_build_identity_for_model(buildmanifest, client->device->hardware_model);
}
@@ -1962,7 +1962,7 @@ int get_sep_nonce(struct idevicerestore_client_t* client, unsigned char** nonce,
return 0;
}
-plist_t build_manifest_get_build_identity_for_model_with_restore_behavior(plist_t build_manifest, const char *hardware_model, const char *behavior)
+plist_t build_manifest_get_build_identity_for_model_with_variant(plist_t build_manifest, const char *hardware_model, const char *variant)
{
plist_t build_identities_array = plist_dict_get_item(build_manifest, "BuildIdentities");
if (!build_identities_array || plist_get_node_type(build_identities_array) != PLIST_ARRAY) {
@@ -1992,86 +1992,13 @@ plist_t build_manifest_get_build_identity_for_model_with_restore_behavior(plist_
}
free(str);
str = NULL;
- if (behavior) {
- plist_t rbehavior = plist_dict_get_item(info_dict, "RestoreBehavior");
- if (!rbehavior || plist_get_node_type(rbehavior) != PLIST_STRING) {
+ if (variant) {
+ plist_t rvariant = plist_dict_get_item(info_dict, "Variant");
+ if (!rvariant || plist_get_node_type(rvariant) != PLIST_STRING) {
continue;
}
- plist_get_string_val(rbehavior, &str);
- if (strcasecmp(str, behavior) != 0) {
- free(str);
- continue;
- } else {
- free(str);
- return plist_copy(ident);
- }
- free(str);
- } else {
- return plist_copy(ident);
- }
- }
-
- return NULL;
-}
-
-plist_t build_manifest_get_build_identity_for_model_with_restore_behavior_and_global_signing(
- plist_t build_manifest,
- const char *hardware_model,
- const char *behavior,
- uint8_t global_signing)
-{
- plist_t build_identities_array = plist_dict_get_item(build_manifest, "BuildIdentities");
- if (!build_identities_array || plist_get_node_type(build_identities_array) != PLIST_ARRAY) {
- error("ERROR: Unable to find build identities node\n");
- return NULL;
- }
-
- uint32_t i;
- for (i = 0; i < plist_array_get_size(build_identities_array); i++) {
- plist_t ident = plist_array_get_item(build_identities_array, i);
- if (!ident || plist_get_node_type(ident) != PLIST_DICT) {
- continue;
- }
- plist_t info_dict = plist_dict_get_item(ident, "Info");
- if (!info_dict || plist_get_node_type(ident) != PLIST_DICT) {
- continue;
- }
- plist_t devclass = plist_dict_get_item(info_dict, "DeviceClass");
- if (!devclass || plist_get_node_type(devclass) != PLIST_STRING) {
- continue;
- }
- char *str = NULL;
- plist_get_string_val(devclass, &str);
- if (strcasecmp(str, hardware_model) != 0) {
- free(str);
- continue;
- }
- free(str);
- str = NULL;
-
- plist_t global_signing_node = plist_dict_get_item(info_dict, "VariantSupportsGlobalSigning");
- if (!global_signing_node) {
- if (global_signing) {
- continue;
- }
- } else {
- uint8_t is_global_signing;
- plist_get_bool_val(global_signing_node, &is_global_signing);
-
- if (global_signing && !is_global_signing) {
- continue;
- } else if (!global_signing && is_global_signing) {
- continue;
- }
- }
-
- if (behavior) {
- plist_t rbehavior = plist_dict_get_item(info_dict, "RestoreBehavior");
- if (!rbehavior || plist_get_node_type(rbehavior) != PLIST_STRING) {
- continue;
- }
- plist_get_string_val(rbehavior, &str);
- if (strcasecmp(str, behavior) != 0) {
+ plist_get_string_val(rvariant, &str);
+ if (strcasecmp(str, variant) != 0) {
free(str);
continue;
} else {
@@ -2089,7 +2016,7 @@ plist_t build_manifest_get_build_identity_for_model_with_restore_behavior_and_gl
plist_t build_manifest_get_build_identity_for_model(plist_t build_manifest, const char *hardware_model)
{
- return build_manifest_get_build_identity_for_model_with_restore_behavior(build_manifest, hardware_model, NULL);
+ return build_manifest_get_build_identity_for_model_with_variant(build_manifest, hardware_model, NULL);
}
int get_preboard_manifest(struct idevicerestore_client_t* client, plist_t build_identity, plist_t* manifest)
diff --git a/src/idevicerestore.h b/src/idevicerestore.h
index 0d90108..880f9ee 100644
--- a/src/idevicerestore.h
+++ b/src/idevicerestore.h
@@ -101,12 +101,7 @@ int build_manifest_get_identity_count(plist_t build_manifest);
int build_manifest_check_compatibility(plist_t build_manifest, const char* product);
void build_manifest_get_version_information(plist_t build_manifest, struct idevicerestore_client_t* client);
plist_t build_manifest_get_build_identity_for_model(plist_t build_manifest, const char *hardware_model);
-plist_t build_manifest_get_build_identity_for_model_with_restore_behavior(plist_t build_manifest, const char *hardware_model, const char *behavior);
-plist_t build_manifest_get_build_identity_for_model_with_restore_behavior_and_global_signing(
- plist_t build_manifest,
- const char *hardware_model,
- const char *behavior,
- uint8_t global_signing);
+plist_t build_manifest_get_build_identity_for_model_with_variant(plist_t build_manifest, const char *hardware_model, const char *variant);
int build_manifest_get_build_count(plist_t build_manifest);
void build_identity_print_information(plist_t build_identity);
int build_identity_check_components_in_ipsw(plist_t build_identity, const char* ipsw);
diff --git a/src/restore.c b/src/restore.c
index d26f398..97ee18e 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -2802,16 +2802,23 @@ plist_t restore_get_build_identity(struct idevicerestore_client_t* client, uint8
{
unsigned int size = 0;
unsigned char* data = NULL;
+ const char *variant;
plist_t buildmanifest = NULL;
ipsw_extract_to_memory(client->ipsw, "BuildManifest.plist", &data, &size);
plist_from_xml((char*)data, size, &buildmanifest);
free(data);
- plist_t build_identity = build_manifest_get_build_identity_for_model_with_restore_behavior_and_global_signing(
+ if (is_recover_os)
+ variant = "macOS Customer";
+ else if (client->flags & FLAG_ERASE)
+ variant = "Customer Erase Install (IPSW)";
+ else
+ variant = "Customer Upgrade Install (IPSW)";
+
+ plist_t build_identity = build_manifest_get_build_identity_for_model_with_variant(
buildmanifest,
client->device->hardware_model,
- client->flags & FLAG_ERASE ? "Erase": "Update",
- is_recover_os);
+ variant);
plist_t unique_id_node = plist_dict_get_item(buildmanifest, "UniqueBuildID");
debug_plist(unique_id_node);