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
256 dev->udid = strdup(muxdev.udid); 256 dev->udid = strdup(muxdev.udid);
257 dev->conn_type = CONNECTION_USBMUXD; 257 dev->conn_type = CONNECTION_USBMUXD;
258 dev->conn_data = (void*)(long)muxdev.handle; 258 dev->conn_data = (void*)(long)muxdev.handle;
259 dev->version = 0;
259 *device = dev; 260 *device = dev;
260 return IDEVICE_E_SUCCESS; 261 return IDEVICE_E_SUCCESS;
261 } 262 }
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 {
76 char *udid; 76 char *udid;
77 enum connection_type conn_type; 77 enum connection_type conn_type;
78 void *conn_data; 78 void *conn_data;
79 int version;
79}; 80};
80 81
81#endif 82#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
707 } 707 }
708 free(type); 708 free(type);
709 709
710 if (device->version == 0) {
711 plist_t p_version = NULL;
712 if (lockdownd_get_value(client_loc, NULL, "ProductVersion", &p_version) == LOCKDOWN_E_SUCCESS) {
713 int vers[3] = {0, 0, 0};
714 char *s_version = NULL;
715 plist_get_string_val(p_version, &s_version);
716 if (s_version && sscanf(s_version, "%d.%d.%d", &vers[0], &vers[1], &vers[2]) >= 2) {
717 device->version = ((vers[0] & 0xFF) << 16) | ((vers[1] & 0xFF) << 8) | (vers[2] & 0xFF);
718 }
719 free(s_version);
720 }
721 }
722
710 userpref_read_pair_record(client_loc->udid, &pair_record); 723 userpref_read_pair_record(client_loc->udid, &pair_record);
711 if (pair_record) { 724 if (pair_record) {
712 pair_record_get_host_id(pair_record, &host_id); 725 pair_record_get_host_id(pair_record, &host_id);
@@ -723,18 +736,18 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new_with_handshake(idevi
723 plist_free(pair_record); 736 plist_free(pair_record);
724 pair_record = NULL; 737 pair_record = NULL;
725 738
726 /* in any case, we need to validate pairing to receive trusted host status */ 739 if (device->version < 0x070000) {
727 ret = lockdownd_validate_pair(client_loc, NULL); 740 /* for older devices, we need to validate pairing to receive trusted host status */
728 741 ret = lockdownd_validate_pair(client_loc, NULL);
729 /* if not paired yet, let's do it now */ 742
730 if (LOCKDOWN_E_INVALID_HOST_ID == ret) { 743 /* if not paired yet, let's do it now */
731 free(host_id); 744 if (LOCKDOWN_E_INVALID_HOST_ID == ret) {
732 host_id = NULL; 745 free(host_id);
733 ret = lockdownd_pair(client_loc, NULL); 746 host_id = NULL;
734 if (LOCKDOWN_E_SUCCESS == ret) { 747 ret = lockdownd_pair(client_loc, NULL);
735 ret = lockdownd_validate_pair(client_loc, NULL); 748 if (LOCKDOWN_E_SUCCESS == ret) {
736 } else if (LOCKDOWN_E_PAIRING_DIALOG_RESPONSE_PENDING == ret) { 749 ret = lockdownd_validate_pair(client_loc, NULL);
737 debug_info("Device shows the pairing dialog."); 750 }
738 } 751 }
739 } 752 }
740 753