diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lockdown.c | 22 |
1 files changed, 18 insertions, 4 deletions
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 | */ |
| 333 | lockdownd_error_t lockdownd_query_type(lockdownd_client_t client) | 335 | lockdownd_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); |
