summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2009-12-07 19:16:48 +0100
committerGravatar Matt Colyer2009-12-07 19:46:43 -0800
commit6ae6880ce5cf00977dfdb204855a7308d7bf42c9 (patch)
tree4b4c48765178817111d060034955a693c85c2907
parentb9ecd70c30ac1fd7024cadfcda9c7be1d1f7f44f (diff)
downloadlibimobiledevice-6ae6880ce5cf00977dfdb204855a7308d7bf42c9.tar.gz
libimobiledevice-6ae6880ce5cf00977dfdb204855a7308d7bf42c9.tar.bz2
Allow passing NULL as HostID to lockdownd_pair()
When NULL is given as HostID, lockdownd_pair() will use the HostID available from userprefs.
-rw-r--r--src/lockdown.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/lockdown.c b/src/lockdown.c
index b6289ed..d717c01 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -719,6 +719,8 @@ lockdownd_error_t lockdownd_pair(lockdownd_client_t client, char *host_id)
gnutls_datum_t root_cert = { NULL, 0 };
gnutls_datum_t public_key = { NULL, 0 };
+ char *host_id_loc = host_id;
+
ret = lockdownd_get_device_public_key(client, &public_key);
if (ret != LOCKDOWN_E_SUCCESS) {
log_debug_msg("%s: device refused to send public key.\n", __func__);
@@ -732,6 +734,10 @@ lockdownd_error_t lockdownd_pair(lockdownd_client_t client, char *host_id)
return ret;
}
+ if (!host_id) {
+ userpref_get_host_id(&host_id_loc);
+ }
+
/* Setup Pair request plist */
dict = plist_new_dict();
dict_record = plist_new_dict();
@@ -739,7 +745,7 @@ lockdownd_error_t lockdownd_pair(lockdownd_client_t client, char *host_id)
plist_dict_insert_item(dict_record, "DeviceCertificate", plist_new_data((const char*)device_cert.data, device_cert.size));
plist_dict_insert_item(dict_record, "HostCertificate", plist_new_data((const char*)host_cert.data, host_cert.size));
- plist_dict_insert_item(dict_record, "HostID", plist_new_string(host_id));
+ plist_dict_insert_item(dict_record, "HostID", plist_new_string(host_id_loc));
plist_dict_insert_item(dict_record, "RootCertificate", plist_new_data((const char*)root_cert.data, root_cert.size));
plist_dict_insert_item(dict, "Request", plist_new_string("Pair"));
@@ -749,6 +755,10 @@ lockdownd_error_t lockdownd_pair(lockdownd_client_t client, char *host_id)
plist_free(dict);
dict = NULL;
+ if (!host_id) {
+ free(host_id_loc);
+ }
+
if (ret != LOCKDOWN_E_SUCCESS)
return ret;