diff options
author | Nikias Bassen | 2019-01-27 04:42:17 +0100 |
---|---|---|
committer | Nikias Bassen | 2019-01-27 04:42:17 +0100 |
commit | 3100d735cf8887df1c1dc1946bc9d7ea20b27d34 (patch) | |
tree | ea7d92245cab709a9e0e38a14d9fa84e7c8f0a86 | |
parent | 7a66710a5c9396e25f6906c09aa11bd1a7bc233e (diff) | |
download | libideviceactivation-3100d735cf8887df1c1dc1946bc9d7ea20b27d34.tar.gz libideviceactivation-3100d735cf8887df1c1dc1946bc9d7ea20b27d34.tar.bz2 |
activation: Make sure to get IMSI and ICCID from lockdownd
For some reason, asking lockdownd for 'InternationalMobileSubscriberIdentity'
sometimes returns "MissingValue", even though ideviceinfo (without passing a
key) shows it.
This commit changes the code to get the whole lockdownd 'NULL domain' info
(equivalent to ideviceinfo without specifying any key) and parse the required
info from there.
-rw-r--r-- | src/activation.c | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/src/activation.c b/src/activation.c index 198289f..c4586eb 100644 --- a/src/activation.c +++ b/src/activation.c @@ -743,83 +743,92 @@ IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_request_new uint8_t has_telephony_capability = 0; uint8_t has_mobile_equipment_id = 0; lockdownd_error_t err; + plist_t info = NULL; plist_t node = NULL; plist_t fields = plist_new_dict(); // add InStoreActivation plist_dict_set_item(fields, "InStoreActivation", plist_new_string("false")); + // get a bunch of information at once + err = lockdownd_get_value(lockdown, NULL, NULL, &info); + if (err != LOCKDOWN_E_SUCCESS) { + if (debug_level > 0) + fprintf(stderr, "%s: Unable to get basic information from lockdownd\n", __func__); + plist_free(fields); + return IDEVICE_ACTIVATION_E_INCOMPLETE_INFO; + } + // add AppleSerialNumber - err = lockdownd_get_value(lockdown, NULL, "SerialNumber", &node); - if (err != LOCKDOWN_E_SUCCESS || !node || plist_get_node_type(node) != PLIST_STRING) { + node = plist_dict_get_item(info, "SerialNumber"); + if (!node || plist_get_node_type(node) != PLIST_STRING) { if (debug_level > 0) fprintf(stderr, "%s: Unable to get SerialNumber from lockdownd\n", __func__); plist_free(fields); + plist_free(info); return IDEVICE_ACTIVATION_E_INCOMPLETE_INFO; } plist_dict_set_item(fields, "AppleSerialNumber", plist_copy(node)); - plist_free(node); node = NULL; + // check if device has telephone capability - err = lockdownd_get_value(lockdown, NULL, "TelephonyCapability", &node); - if (err != LOCKDOWN_E_SUCCESS || !node || plist_get_node_type(node) != PLIST_BOOLEAN) { + node = plist_dict_get_item(info, "TelephonyCapability"); + if (!node || plist_get_node_type(node) != PLIST_BOOLEAN) { has_telephony_capability = 0; } else { plist_get_bool_val(node, &has_telephony_capability); } - plist_free(node); node = NULL; if (has_telephony_capability) { // add IMEI - err = lockdownd_get_value(lockdown, NULL, "InternationalMobileEquipmentIdentity", &node); - if (err != LOCKDOWN_E_SUCCESS || !node || plist_get_node_type(node) != PLIST_STRING) { + node = plist_dict_get_item(info, "InternationalMobileEquipmentIdentity"); + if (!node || plist_get_node_type(node) != PLIST_STRING) { has_mobile_equipment_id = 0; } else { plist_dict_set_item(fields, "IMEI", plist_copy(node)); has_mobile_equipment_id = 1; } - plist_free(node); node = NULL; // add MEID - err = lockdownd_get_value(lockdown, NULL, "MobileEquipmentIdentifier", &node); - if (err != LOCKDOWN_E_SUCCESS || !node || plist_get_node_type(node) != PLIST_STRING) { + node = plist_dict_get_item(info, "MobileEquipmentIdentifier"); + if (!node || plist_get_node_type(node) != PLIST_STRING) { if (debug_level > 0) fprintf(stderr, "%s: Unable to get MEID from lockdownd\n", __func__); if (!has_mobile_equipment_id) { plist_free(fields); + plist_free(info); return IDEVICE_ACTIVATION_E_INCOMPLETE_INFO; } } else { plist_dict_set_item(fields, "MEID", plist_copy(node)); } - plist_free(node); node = NULL; // add IMSI - err = lockdownd_get_value(lockdown, NULL, "InternationalMobileSubscriberIdentity", &node); - if (err != LOCKDOWN_E_SUCCESS || !node || plist_get_node_type(node) != PLIST_STRING) { + node = plist_dict_get_item(info, "InternationalMobileSubscriberIdentity"); + if (!node || plist_get_node_type(node) != PLIST_STRING) { if (debug_level > 0) fprintf(stderr, "%s: Unable to get IMSI from lockdownd\n", __func__); } else { plist_dict_set_item(fields, "IMSI", plist_copy(node)); } - plist_free(node); node = NULL; // add ICCID - err = lockdownd_get_value(lockdown, NULL, "IntegratedCircuitCardIdentity", &node); - if (err != LOCKDOWN_E_SUCCESS || !node || plist_get_node_type(node) != PLIST_STRING) { + node = plist_dict_get_item(info, "IntegratedCircuitCardIdentity"); + if (!node || plist_get_node_type(node) != PLIST_STRING) { if (debug_level > 0) fprintf(stderr, "%s: Unable to get ICCID from lockdownd\n", __func__); } else { plist_dict_set_item(fields, "ICCID", plist_copy(node)); } - plist_free(node); node = NULL; } + plist_free(info); + info = NULL; // add activation-info err = lockdownd_get_value(lockdown, NULL, "ActivationInfo", &node); |