diff options
| author | 2025-06-07 11:27:55 +0200 | |
|---|---|---|
| committer | 2025-06-07 11:27:55 +0200 | |
| commit | 2e1ee28bf1d744edcf3513859a38ac5f6615b096 (patch) | |
| tree | 2bd6958e15ac1e32f36d6db0ab345f3b72f8bca1 | |
| parent | 72456f241ef49932a1c1e673059564d6f7ec3aad (diff) | |
| download | libimobiledevice-2e1ee28bf1d744edcf3513859a38ac5f6615b096.tar.gz libimobiledevice-2e1ee28bf1d744edcf3513859a38ac5f6615b096.tar.bz2 | |
lockdown: Move ProductVersion and DeviceClass query into lockdownd_client_new
This way we make sure to also retrieve the device version and class if the
device is not paired yet.
| -rw-r--r-- | src/lockdown.c | 49 | 
1 files changed, 24 insertions, 25 deletions
| diff --git a/src/lockdown.c b/src/lockdown.c index 3679fee..411136c 100644 --- a/src/lockdown.c +++ b/src/lockdown.c | |||
| @@ -621,6 +621,7 @@ lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *cli | |||
| 621 | .port = 0xf27e, | 621 | .port = 0xf27e, | 
| 622 | .ssl_enabled = 0 | 622 | .ssl_enabled = 0 | 
| 623 | }; | 623 | }; | 
| 624 | char *type = NULL; | ||
| 624 | 625 | ||
| 625 | property_list_service_client_t plistclient = NULL; | 626 | property_list_service_client_t plistclient = NULL; | 
| 626 | if (property_list_service_client_new(device, (lockdownd_service_descriptor_t)&service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) { | 627 | if (property_list_service_client_new(device, (lockdownd_service_descriptor_t)&service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) { | 
| @@ -642,37 +643,15 @@ lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *cli | |||
| 642 | 643 | ||
| 643 | client_loc->label = label ? strdup(label) : NULL; | 644 | client_loc->label = label ? strdup(label) : NULL; | 
| 644 | 645 | ||
| 645 | *client = client_loc; | 646 | if (lockdownd_query_type(client_loc, &type) != LOCKDOWN_E_SUCCESS) { | 
| 646 | |||
| 647 | return LOCKDOWN_E_SUCCESS; | ||
| 648 | } | ||
| 649 | |||
| 650 | lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdownd_client_t *client, const char *label) | ||
| 651 | { | ||
| 652 | if (!client) | ||
| 653 | return LOCKDOWN_E_INVALID_ARG; | ||
| 654 | |||
| 655 | lockdownd_error_t ret = LOCKDOWN_E_SUCCESS; | ||
| 656 | lockdownd_client_t client_loc = NULL; | ||
| 657 | plist_t pair_record = NULL; | ||
| 658 | char *host_id = NULL; | ||
| 659 | char *type = NULL; | ||
| 660 | |||
| 661 | ret = lockdownd_client_new(device, &client_loc, label); | ||
| 662 | if (LOCKDOWN_E_SUCCESS != ret) { | ||
| 663 | debug_info("failed to create lockdownd client."); | ||
| 664 | return ret; | ||
| 665 | } | ||
| 666 | |||
| 667 | /* perform handshake */ | ||
| 668 | ret = lockdownd_query_type(client_loc, &type); | ||
| 669 | if (LOCKDOWN_E_SUCCESS != ret) { | ||
| 670 | debug_info("QueryType failed in the lockdownd client."); | 647 | debug_info("QueryType failed in the lockdownd client."); | 
| 671 | } else if (strcmp("com.apple.mobile.lockdown", type) != 0) { | 648 | } else if (strcmp("com.apple.mobile.lockdown", type) != 0) { | 
| 672 | debug_info("Warning QueryType request returned \"%s\".", type); | 649 | debug_info("Warning QueryType request returned \"%s\".", type); | 
| 673 | } | 650 | } | 
| 674 | free(type); | 651 | free(type); | 
| 675 | 652 | ||
| 653 | *client = client_loc; | ||
| 654 | |||
| 676 | if (device->version == 0) { | 655 | if (device->version == 0) { | 
| 677 | plist_t p_version = NULL; | 656 | plist_t p_version = NULL; | 
| 678 | if (lockdownd_get_value(client_loc, NULL, "ProductVersion", &p_version) == LOCKDOWN_E_SUCCESS) { | 657 | if (lockdownd_get_value(client_loc, NULL, "ProductVersion", &p_version) == LOCKDOWN_E_SUCCESS) { | 
| @@ -711,6 +690,26 @@ lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdown | |||
| 711 | plist_free(p_device_class); | 690 | plist_free(p_device_class); | 
| 712 | } | 691 | } | 
| 713 | 692 | ||
| 693 | return LOCKDOWN_E_SUCCESS; | ||
| 694 | } | ||
| 695 | |||
| 696 | lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdownd_client_t *client, const char *label) | ||
| 697 | { | ||
| 698 | if (!client) | ||
| 699 | return LOCKDOWN_E_INVALID_ARG; | ||
| 700 | |||
| 701 | lockdownd_error_t ret = LOCKDOWN_E_SUCCESS; | ||
| 702 | lockdownd_client_t client_loc = NULL; | ||
| 703 | plist_t pair_record = NULL; | ||
| 704 | char *host_id = NULL; | ||
| 705 | |||
| 706 | ret = lockdownd_client_new(device, &client_loc, label); | ||
| 707 | if (LOCKDOWN_E_SUCCESS != ret) { | ||
| 708 | debug_info("failed to create lockdownd client."); | ||
| 709 | return ret; | ||
| 710 | } | ||
| 711 | |||
| 712 | /* perform handshake */ | ||
| 714 | userpref_error_t uerr = userpref_read_pair_record(client_loc->device->udid, &pair_record); | 713 | userpref_error_t uerr = userpref_read_pair_record(client_loc->device->udid, &pair_record); | 
| 715 | if (uerr == USERPREF_E_READ_ERROR) { | 714 | if (uerr == USERPREF_E_READ_ERROR) { | 
| 716 | debug_info("ERROR: Failed to retrieve pair record for %s", client_loc->device->udid); | 715 | debug_info("ERROR: Failed to retrieve pair record for %s", client_loc->device->udid); | 
