summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2017-08-13 00:12:16 +0200
committerGravatar Nikias Bassen2017-08-13 00:12:16 +0200
commit5a85432719fb3d18027d528f87d2a44b76fd3e12 (patch)
tree3b4ee4ae280fd0166bd8e5b6d0e03db293ace590
parent0dbe76b4e75eef5d0e033aac99409fb6df36c512 (diff)
downloadlibimobiledevice-5a85432719fb3d18027d528f87d2a44b76fd3e12.tar.gz
libimobiledevice-5a85432719fb3d18027d528f87d2a44b76fd3e12.tar.bz2
lockdown: Don't explicitly validate pairing unless we're dealing with an older device
On newer iOS version, ValidatePair is not mandatory to gain trusted host status. Starting with iOS 11, the ValidatePair request has been removed from lockdownd and will throw an error. This commit adds a version check so that ValidatePair is only called on devices prior iOS 7.
-rw-r--r--src/idevice.c1
-rw-r--r--src/idevice.h1
-rw-r--r--src/lockdown.c37
3 files changed, 27 insertions, 12 deletions
diff --git a/src/idevice.c b/src/idevice.c
index 21b10ba..ead9b86 100644
--- a/src/idevice.c
+++ b/src/idevice.c
@@ -256,6 +256,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_new(idevice_t * device, const char
dev->udid = strdup(muxdev.udid);
dev->conn_type = CONNECTION_USBMUXD;
dev->conn_data = (void*)(long)muxdev.handle;
+ dev->version = 0;
*device = dev;
return IDEVICE_E_SUCCESS;
}
diff --git a/src/idevice.h b/src/idevice.h
index 1354cc0..e46a7e5 100644
--- a/src/idevice.h
+++ b/src/idevice.h
@@ -76,6 +76,7 @@ struct idevice_private {
char *udid;
enum connection_type conn_type;
void *conn_data;
+ int version;
};
#endif
diff --git a/src/lockdown.c b/src/lockdown.c
index 5251737..071697d 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -707,6 +707,19 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new_with_handshake(idevi
}
free(type);
+ if (device->version == 0) {
+ plist_t p_version = NULL;
+ if (lockdownd_get_value(client_loc, NULL, "ProductVersion", &p_version) == LOCKDOWN_E_SUCCESS) {
+ int vers[3] = {0, 0, 0};
+ char *s_version = NULL;
+ plist_get_string_val(p_version, &s_version);
+ if (s_version && sscanf(s_version, "%d.%d.%d", &vers[0], &vers[1], &vers[2]) >= 2) {
+ device->version = ((vers[0] & 0xFF) << 16) | ((vers[1] & 0xFF) << 8) | (vers[2] & 0xFF);
+ }
+ free(s_version);
+ }
+ }
+
userpref_read_pair_record(client_loc->udid, &pair_record);
if (pair_record) {
pair_record_get_host_id(pair_record, &host_id);
@@ -723,18 +736,18 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new_with_handshake(idevi
plist_free(pair_record);
pair_record = NULL;
- /* in any case, we need to validate pairing to receive trusted host status */
- ret = lockdownd_validate_pair(client_loc, NULL);
-
- /* if not paired yet, let's do it now */
- if (LOCKDOWN_E_INVALID_HOST_ID == ret) {
- free(host_id);
- host_id = NULL;
- ret = lockdownd_pair(client_loc, NULL);
- if (LOCKDOWN_E_SUCCESS == ret) {
- ret = lockdownd_validate_pair(client_loc, NULL);
- } else if (LOCKDOWN_E_PAIRING_DIALOG_RESPONSE_PENDING == ret) {
- debug_info("Device shows the pairing dialog.");
+ if (device->version < 0x070000) {
+ /* for older devices, we need to validate pairing to receive trusted host status */
+ ret = lockdownd_validate_pair(client_loc, NULL);
+
+ /* if not paired yet, let's do it now */
+ if (LOCKDOWN_E_INVALID_HOST_ID == ret) {
+ free(host_id);
+ host_id = NULL;
+ ret = lockdownd_pair(client_loc, NULL);
+ if (LOCKDOWN_E_SUCCESS == ret) {
+ ret = lockdownd_validate_pair(client_loc, NULL);
+ }
}
}