summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2010-01-10 23:38:27 +0100
committerGravatar Martin Szulecki2010-01-10 23:38:27 +0100
commitf60d22f4ae41521d33ed85189733c7538ab65794 (patch)
tree19e822a91402fdd60008626b3d7aa5b177c8bb28
parentb85fe20245809fb5a62a95c1b1efcd6ca4df9282 (diff)
downloadlibimobiledevice-f60d22f4ae41521d33ed85189733c7538ab65794.tar.gz
libimobiledevice-f60d22f4ae41521d33ed85189733c7538ab65794.tar.bz2
Extend lockdown_query_type to actually return the type of the service daemon
-rw-r--r--include/libiphone/lockdown.h2
-rw-r--r--src/lockdown.c22
2 files changed, 19 insertions, 5 deletions
diff --git a/include/libiphone/lockdown.h b/include/libiphone/lockdown.h
index 459fbbd..4a82258 100644
--- a/include/libiphone/lockdown.h
+++ b/include/libiphone/lockdown.h
@@ -58,7 +58,7 @@ typedef struct lockdownd_client_int *lockdownd_client_t;
58lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_t *client, const char *label); 58lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_t *client, const char *label);
59lockdownd_error_t lockdownd_client_free(lockdownd_client_t client); 59lockdownd_error_t lockdownd_client_free(lockdownd_client_t client);
60void lockdownd_client_set_label(lockdownd_client_t client, const char *label); 60void lockdownd_client_set_label(lockdownd_client_t client, const char *label);
61lockdownd_error_t lockdownd_query_type(lockdownd_client_t client); 61lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type);
62lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain, const char *key, plist_t *value); 62lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain, const char *key, plist_t *value);
63lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *domain, const char *key, plist_t value); 63lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *domain, const char *key, plist_t value);
64lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *domain, const char *key); 64lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *domain, const char *key);
diff --git a/src/lockdown.c b/src/lockdown.c
index 24dd4a1..1b33250 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -324,13 +324,15 @@ lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist)
324 return ret; 324 return ret;
325} 325}
326 326
327/** Initiates the handshake for the lockdown session. Part of the lockdownd handshake. 327/** Query the type of the service daemon. Depending on whether the device is
328 * queried in normal mode or restore mode, different types will be returned.
328 * 329 *
329 * @param client The lockdownd client 330 * @param client The lockdownd client
331 * @param type The type returned by the service daemon. Can be NULL to ignore.
330 * 332 *
331 * @return an error code (LOCKDOWN_E_SUCCESS on success) 333 * @return an error code (LOCKDOWN_E_SUCCESS on success)
332 */ 334 */
333lockdownd_error_t lockdownd_query_type(lockdownd_client_t client) 335lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type)
334{ 336{
335 if (!client) 337 if (!client)
336 return LOCKDOWN_E_INVALID_ARG; 338 return LOCKDOWN_E_INVALID_ARG;
@@ -354,7 +356,12 @@ lockdownd_error_t lockdownd_query_type(lockdownd_client_t client)
354 356
355 ret = LOCKDOWN_E_UNKNOWN_ERROR; 357 ret = LOCKDOWN_E_UNKNOWN_ERROR;
356 if (lockdown_check_result(dict, "QueryType") == RESULT_SUCCESS) { 358 if (lockdown_check_result(dict, "QueryType") == RESULT_SUCCESS) {
357 log_dbg_msg(DBGMASK_LOCKDOWND, "%s: success\n", __func__); 359 /* return the type if requested */
360 if (type != NULL) {
361 plist_t type_node = plist_dict_get_item(dict, "Type");
362 plist_get_string_val(type_node, type);
363 }
364 log_dbg_msg(DBGMASK_LOCKDOWND, "%s: success with type %s\n", __func__, *type);
358 ret = LOCKDOWN_E_SUCCESS; 365 ret = LOCKDOWN_E_SUCCESS;
359 } 366 }
360 plist_free(dict); 367 plist_free(dict);
@@ -622,6 +629,7 @@ lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_
622 return LOCKDOWN_E_INVALID_ARG; 629 return LOCKDOWN_E_INVALID_ARG;
623 lockdownd_error_t ret = LOCKDOWN_E_SUCCESS; 630 lockdownd_error_t ret = LOCKDOWN_E_SUCCESS;
624 char *host_id = NULL; 631 char *host_id = NULL;
632 char *type = NULL;
625 633
626 iphone_connection_t connection; 634 iphone_connection_t connection;
627 if (iphone_device_connect(device, 0xf27e, &connection) != IPHONE_E_SUCCESS) { 635 if (iphone_device_connect(device, 0xf27e, &connection) != IPHONE_E_SUCCESS) {
@@ -638,9 +646,15 @@ lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_
638 client_loc->uuid = NULL; 646 client_loc->uuid = NULL;
639 client_loc->label = strdup(label); 647 client_loc->label = strdup(label);
640 648
641 if (LOCKDOWN_E_SUCCESS != lockdownd_query_type(client_loc)) { 649 if (LOCKDOWN_E_SUCCESS != lockdownd_query_type(client_loc, &type)) {
642 log_debug_msg("%s: QueryType failed in the lockdownd client.\n", __func__); 650 log_debug_msg("%s: QueryType failed in the lockdownd client.\n", __func__);
643 ret = LOCKDOWN_E_NOT_ENOUGH_DATA; 651 ret = LOCKDOWN_E_NOT_ENOUGH_DATA;
652 } else {
653 if (strcmp("com.apple.mobile.lockdown", type)) {
654 log_debug_msg("%s: Warning QueryType request returned \"%s\".\n", __func__, type);
655 }
656 if (type)
657 free(type);
644 } 658 }
645 659
646 ret = iphone_device_get_uuid(device, &client_loc->uuid); 660 ret = iphone_device_get_uuid(device, &client_loc->uuid);