diff options
author | Nikias Bassen | 2021-07-29 04:22:11 +0200 |
---|---|---|
committer | Nikias Bassen | 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) free(client->session_id); client->session_id = NULL; } - if (client->udid) { - free(client->udid); - } if (client->label) { free(client->label); } @@ -643,12 +640,9 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new(idevice_t device, lo client_loc->parent = plistclient; client_loc->ssl_enabled = 0; client_loc->session_id = NULL; - client_loc->mux_id = device->mux_id; + client_loc->device = device; - if (idevice_get_udid(device, &client_loc->udid) != IDEVICE_E_SUCCESS) { - debug_info("failed to get device udid."); - } - debug_info("device udid: %s", client_loc->udid); + debug_info("device udid: %s", device->udid); client_loc->label = label ? strdup(label) : NULL; @@ -721,9 +715,9 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new_with_handshake(idevi plist_free(p_device_class); } - userpref_error_t uerr = userpref_read_pair_record(client_loc->udid, &pair_record); + userpref_error_t uerr = userpref_read_pair_record(client_loc->device->udid, &pair_record); if (uerr == USERPREF_E_READ_ERROR) { - debug_info("ERROR: Failed to retrieve pair record for %s", client_loc->udid); + debug_info("ERROR: Failed to retrieve pair record for %s", client_loc->device->udid); lockdownd_client_free(client_loc); return LOCKDOWN_E_RECEIVE_TIMEOUT; } @@ -761,15 +755,15 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new_with_handshake(idevi if (LOCKDOWN_E_SUCCESS == ret) { if (!host_id) { - uerr = userpref_read_pair_record(client_loc->udid, &pair_record); + uerr = userpref_read_pair_record(client_loc->device->udid, &pair_record); if (uerr == USERPREF_E_READ_ERROR) { - debug_info("ERROR: Failed to retrieve pair record for %s", client_loc->udid); + debug_info("ERROR: Failed to retrieve pair record for %s", client_loc->device->udid); return LOCKDOWN_E_RECEIVE_TIMEOUT; } else if (uerr == USERPREF_E_NOENT) { - debug_info("ERROR: No pair record for %s", client_loc->udid); + debug_info("ERROR: No pair record for %s", client_loc->device->udid); return LOCKDOWN_E_INVALID_CONF; } else if (uerr != USERPREF_E_SUCCESS) { - debug_info("ERROR: Failed to retrieve or parse pair record for %s", client_loc->udid); + debug_info("ERROR: Failed to retrieve or parse pair record for %s", client_loc->device->udid); return LOCKDOWN_E_INVALID_CONF; } if (pair_record) { @@ -935,15 +929,15 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, lockdownd_ lockdownd_get_value(client, NULL, "WiFiAddress", &wifi_node); } else { /* use existing pair record */ - userpref_error_t uerr = userpref_read_pair_record(client->udid, &pair_record_plist); + userpref_error_t uerr = userpref_read_pair_record(client->device->udid, &pair_record_plist); if (uerr == USERPREF_E_READ_ERROR) { - debug_info("ERROR: Failed to retrieve pair record for %s", client->udid); + debug_info("ERROR: Failed to retrieve pair record for %s", client->device->udid); return LOCKDOWN_E_RECEIVE_TIMEOUT; } else if (uerr == USERPREF_E_NOENT) { - debug_info("ERROR: No pair record for %s", client->udid); + debug_info("ERROR: No pair record for %s", client->device->udid); return LOCKDOWN_E_INVALID_CONF; } else if (uerr != USERPREF_E_SUCCESS) { - debug_info("ERROR: Failed to retrieve or parse pair record for %s", client->udid); + debug_info("ERROR: Failed to retrieve or parse pair record for %s", client->device->udid); return LOCKDOWN_E_INVALID_CONF; } } @@ -1007,7 +1001,7 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, lockdownd_ debug_info("internal pairing mode"); if (!strcmp("Unpair", verb)) { /* remove public key from config */ - userpref_delete_pair_record(client->udid); + userpref_delete_pair_record(client->device->udid); } else { if (!strcmp("Pair", verb)) { /* add returned escrow bag if available */ @@ -1025,7 +1019,7 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, lockdownd_ wifi_node = NULL; } - userpref_save_pair_record(client->udid, client->mux_id, pair_record_plist); + userpref_save_pair_record(client->device->udid, client->device->mux_id, pair_record_plist); } } } else { @@ -1274,17 +1268,17 @@ static lockdownd_error_t lockdownd_build_start_service_request(lockdownd_client_ if (send_escrow_bag) { /* get the pairing record */ plist_t pair_record = NULL; - userpref_error_t uerr = userpref_read_pair_record(client->udid, &pair_record); + userpref_error_t uerr = userpref_read_pair_record(client->device->udid, &pair_record); if (uerr == USERPREF_E_READ_ERROR) { - debug_info("ERROR: Failed to retrieve pair record for %s", client->udid); + debug_info("ERROR: Failed to retrieve pair record for %s", client->device->udid); plist_free(dict); return LOCKDOWN_E_RECEIVE_TIMEOUT; } else if (uerr == USERPREF_E_NOENT) { - debug_info("ERROR: No pair record for %s", client->udid); + debug_info("ERROR: No pair record for %s", client->device->udid); plist_free(dict); return LOCKDOWN_E_INVALID_CONF; } else if (uerr != USERPREF_E_SUCCESS) { - debug_info("ERROR: Failed to retrieve or parse pair record for %s", client->udid); + debug_info("ERROR: Failed to retrieve or parse pair record for %s", client->device->udid); plist_free(dict); return LOCKDOWN_E_INVALID_CONF; } 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 { property_list_service_client_t parent; int ssl_enabled; char *session_id; - char *udid; char *label; - uint32_t mux_id; + idevice_t device; }; #endif |