diff options
| author | 2021-07-29 04:22:11 +0200 | |
|---|---|---|
| committer | 2021-07-29 04:22:11 +0200 | |
| commit | 58f3516e9ff3f83f9c4b3f9f17181b5ce730f872 (patch) | |
| tree | 47b9b481a296037751883c9fa6a30c7cedb9a769 | |
| parent | 6c7b50355cc5de1da1d7677e012f18efbce34237 (diff) | |
| download | libimobiledevice-58f3516e9ff3f83f9c4b3f9f17181b5ce730f872.tar.gz libimobiledevice-58f3516e9ff3f83f9c4b3f9f17181b5ce730f872.tar.bz2 | |
lockdown: Replace udid and mux_id members from client struct with idevice_t reference
| -rw-r--r-- | src/lockdown.c | 42 | ||||
| -rw-r--r-- | src/lockdown.h | 3 |
2 files changed, 19 insertions, 26 deletions
diff --git a/src/lockdown.c b/src/lockdown.c index 2cacc71..8fc2c49 100644 --- a/src/lockdown.c +++ b/src/lockdown.c | |||
| @@ -311,9 +311,6 @@ static lockdownd_error_t lockdownd_client_free_simple(lockdownd_client_t client) | |||
| 311 | free(client->session_id); | 311 | free(client->session_id); |
| 312 | client->session_id = NULL; | 312 | client->session_id = NULL; |
| 313 | } | 313 | } |
| 314 | if (client->udid) { | ||
| 315 | free(client->udid); | ||
| 316 | } | ||
| 317 | if (client->label) { | 314 | if (client->label) { |
| 318 | free(client->label); | 315 | free(client->label); |
| 319 | } | 316 | } |
| @@ -643,12 +640,9 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new(idevice_t device, lo | |||
| 643 | client_loc->parent = plistclient; | 640 | client_loc->parent = plistclient; |
| 644 | client_loc->ssl_enabled = 0; | 641 | client_loc->ssl_enabled = 0; |
| 645 | client_loc->session_id = NULL; | 642 | client_loc->session_id = NULL; |
| 646 | client_loc->mux_id = device->mux_id; | 643 | client_loc->device = device; |
| 647 | 644 | ||
| 648 | if (idevice_get_udid(device, &client_loc->udid) != IDEVICE_E_SUCCESS) { | 645 | debug_info("device udid: %s", device->udid); |
| 649 | debug_info("failed to get device udid."); | ||
| 650 | } | ||
| 651 | debug_info("device udid: %s", client_loc->udid); | ||
| 652 | 646 | ||
| 653 | client_loc->label = label ? strdup(label) : NULL; | 647 | client_loc->label = label ? strdup(label) : NULL; |
| 654 | 648 | ||
| @@ -721,9 +715,9 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new_with_handshake(idevi | |||
| 721 | plist_free(p_device_class); | 715 | plist_free(p_device_class); |
| 722 | } | 716 | } |
| 723 | 717 | ||
| 724 | userpref_error_t uerr = userpref_read_pair_record(client_loc->udid, &pair_record); | 718 | userpref_error_t uerr = userpref_read_pair_record(client_loc->device->udid, &pair_record); |
| 725 | if (uerr == USERPREF_E_READ_ERROR) { | 719 | if (uerr == USERPREF_E_READ_ERROR) { |
| 726 | debug_info("ERROR: Failed to retrieve pair record for %s", client_loc->udid); | 720 | debug_info("ERROR: Failed to retrieve pair record for %s", client_loc->device->udid); |
| 727 | lockdownd_client_free(client_loc); | 721 | lockdownd_client_free(client_loc); |
| 728 | return LOCKDOWN_E_RECEIVE_TIMEOUT; | 722 | return LOCKDOWN_E_RECEIVE_TIMEOUT; |
| 729 | } | 723 | } |
| @@ -761,15 +755,15 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new_with_handshake(idevi | |||
| 761 | 755 | ||
| 762 | if (LOCKDOWN_E_SUCCESS == ret) { | 756 | if (LOCKDOWN_E_SUCCESS == ret) { |
| 763 | if (!host_id) { | 757 | if (!host_id) { |
| 764 | uerr = userpref_read_pair_record(client_loc->udid, &pair_record); | 758 | uerr = userpref_read_pair_record(client_loc->device->udid, &pair_record); |
| 765 | if (uerr == USERPREF_E_READ_ERROR) { | 759 | if (uerr == USERPREF_E_READ_ERROR) { |
| 766 | debug_info("ERROR: Failed to retrieve pair record for %s", client_loc->udid); | 760 | debug_info("ERROR: Failed to retrieve pair record for %s", client_loc->device->udid); |
| 767 | return LOCKDOWN_E_RECEIVE_TIMEOUT; | 761 | return LOCKDOWN_E_RECEIVE_TIMEOUT; |
| 768 | } else if (uerr == USERPREF_E_NOENT) { | 762 | } else if (uerr == USERPREF_E_NOENT) { |
| 769 | debug_info("ERROR: No pair record for %s", client_loc->udid); | 763 | debug_info("ERROR: No pair record for %s", client_loc->device->udid); |
| 770 | return LOCKDOWN_E_INVALID_CONF; | 764 | return LOCKDOWN_E_INVALID_CONF; |
| 771 | } else if (uerr != USERPREF_E_SUCCESS) { | 765 | } else if (uerr != USERPREF_E_SUCCESS) { |
| 772 | debug_info("ERROR: Failed to retrieve or parse pair record for %s", client_loc->udid); | 766 | debug_info("ERROR: Failed to retrieve or parse pair record for %s", client_loc->device->udid); |
| 773 | return LOCKDOWN_E_INVALID_CONF; | 767 | return LOCKDOWN_E_INVALID_CONF; |
| 774 | } | 768 | } |
| 775 | if (pair_record) { | 769 | if (pair_record) { |
| @@ -935,15 +929,15 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, lockdownd_ | |||
| 935 | lockdownd_get_value(client, NULL, "WiFiAddress", &wifi_node); | 929 | lockdownd_get_value(client, NULL, "WiFiAddress", &wifi_node); |
| 936 | } else { | 930 | } else { |
| 937 | /* use existing pair record */ | 931 | /* use existing pair record */ |
| 938 | userpref_error_t uerr = userpref_read_pair_record(client->udid, &pair_record_plist); | 932 | userpref_error_t uerr = userpref_read_pair_record(client->device->udid, &pair_record_plist); |
| 939 | if (uerr == USERPREF_E_READ_ERROR) { | 933 | if (uerr == USERPREF_E_READ_ERROR) { |
| 940 | debug_info("ERROR: Failed to retrieve pair record for %s", client->udid); | 934 | debug_info("ERROR: Failed to retrieve pair record for %s", client->device->udid); |
| 941 | return LOCKDOWN_E_RECEIVE_TIMEOUT; | 935 | return LOCKDOWN_E_RECEIVE_TIMEOUT; |
| 942 | } else if (uerr == USERPREF_E_NOENT) { | 936 | } else if (uerr == USERPREF_E_NOENT) { |
| 943 | debug_info("ERROR: No pair record for %s", client->udid); | 937 | debug_info("ERROR: No pair record for %s", client->device->udid); |
| 944 | return LOCKDOWN_E_INVALID_CONF; | 938 | return LOCKDOWN_E_INVALID_CONF; |
| 945 | } else if (uerr != USERPREF_E_SUCCESS) { | 939 | } else if (uerr != USERPREF_E_SUCCESS) { |
| 946 | debug_info("ERROR: Failed to retrieve or parse pair record for %s", client->udid); | 940 | debug_info("ERROR: Failed to retrieve or parse pair record for %s", client->device->udid); |
| 947 | return LOCKDOWN_E_INVALID_CONF; | 941 | return LOCKDOWN_E_INVALID_CONF; |
| 948 | } | 942 | } |
| 949 | } | 943 | } |
| @@ -1007,7 +1001,7 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, lockdownd_ | |||
| 1007 | debug_info("internal pairing mode"); | 1001 | debug_info("internal pairing mode"); |
| 1008 | if (!strcmp("Unpair", verb)) { | 1002 | if (!strcmp("Unpair", verb)) { |
| 1009 | /* remove public key from config */ | 1003 | /* remove public key from config */ |
| 1010 | userpref_delete_pair_record(client->udid); | 1004 | userpref_delete_pair_record(client->device->udid); |
| 1011 | } else { | 1005 | } else { |
| 1012 | if (!strcmp("Pair", verb)) { | 1006 | if (!strcmp("Pair", verb)) { |
| 1013 | /* add returned escrow bag if available */ | 1007 | /* add returned escrow bag if available */ |
| @@ -1025,7 +1019,7 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, lockdownd_ | |||
| 1025 | wifi_node = NULL; | 1019 | wifi_node = NULL; |
| 1026 | } | 1020 | } |
| 1027 | 1021 | ||
| 1028 | userpref_save_pair_record(client->udid, client->mux_id, pair_record_plist); | 1022 | userpref_save_pair_record(client->device->udid, client->device->mux_id, pair_record_plist); |
| 1029 | } | 1023 | } |
| 1030 | } | 1024 | } |
| 1031 | } else { | 1025 | } else { |
| @@ -1274,17 +1268,17 @@ static lockdownd_error_t lockdownd_build_start_service_request(lockdownd_client_ | |||
| 1274 | if (send_escrow_bag) { | 1268 | if (send_escrow_bag) { |
| 1275 | /* get the pairing record */ | 1269 | /* get the pairing record */ |
| 1276 | plist_t pair_record = NULL; | 1270 | plist_t pair_record = NULL; |
| 1277 | userpref_error_t uerr = userpref_read_pair_record(client->udid, &pair_record); | 1271 | userpref_error_t uerr = userpref_read_pair_record(client->device->udid, &pair_record); |
| 1278 | if (uerr == USERPREF_E_READ_ERROR) { | 1272 | if (uerr == USERPREF_E_READ_ERROR) { |
| 1279 | debug_info("ERROR: Failed to retrieve pair record for %s", client->udid); | 1273 | debug_info("ERROR: Failed to retrieve pair record for %s", client->device->udid); |
| 1280 | plist_free(dict); | 1274 | plist_free(dict); |
| 1281 | return LOCKDOWN_E_RECEIVE_TIMEOUT; | 1275 | return LOCKDOWN_E_RECEIVE_TIMEOUT; |
| 1282 | } else if (uerr == USERPREF_E_NOENT) { | 1276 | } else if (uerr == USERPREF_E_NOENT) { |
| 1283 | debug_info("ERROR: No pair record for %s", client->udid); | 1277 | debug_info("ERROR: No pair record for %s", client->device->udid); |
| 1284 | plist_free(dict); | 1278 | plist_free(dict); |
| 1285 | return LOCKDOWN_E_INVALID_CONF; | 1279 | return LOCKDOWN_E_INVALID_CONF; |
| 1286 | } else if (uerr != USERPREF_E_SUCCESS) { | 1280 | } else if (uerr != USERPREF_E_SUCCESS) { |
| 1287 | debug_info("ERROR: Failed to retrieve or parse pair record for %s", client->udid); | 1281 | debug_info("ERROR: Failed to retrieve or parse pair record for %s", client->device->udid); |
| 1288 | plist_free(dict); | 1282 | plist_free(dict); |
| 1289 | return LOCKDOWN_E_INVALID_CONF; | 1283 | return LOCKDOWN_E_INVALID_CONF; |
| 1290 | } | 1284 | } |
diff --git a/src/lockdown.h b/src/lockdown.h index bf595df..0091f1d 100644 --- a/src/lockdown.h +++ b/src/lockdown.h | |||
| @@ -32,9 +32,8 @@ struct lockdownd_client_private { | |||
| 32 | property_list_service_client_t parent; | 32 | property_list_service_client_t parent; |
| 33 | int ssl_enabled; | 33 | int ssl_enabled; |
| 34 | char *session_id; | 34 | char *session_id; |
| 35 | char *udid; | ||
| 36 | char *label; | 35 | char *label; |
| 37 | uint32_t mux_id; | 36 | idevice_t device; |
| 38 | }; | 37 | }; |
| 39 | 38 | ||
| 40 | #endif | 39 | #endif |
