diff options
Diffstat (limited to 'src/lockdown.c')
| -rw-r--r-- | src/lockdown.c | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/src/lockdown.c b/src/lockdown.c index 64c325e..c017cdf 100644 --- a/src/lockdown.c +++ b/src/lockdown.c | |||
| @@ -506,7 +506,6 @@ iphone_error_t iphone_lckd_new_client(iphone_device_t device, iphone_lckd_client | |||
| 506 | 506 | ||
| 507 | host_id = get_host_id(); | 507 | host_id = get_host_id(); |
| 508 | if (IPHONE_E_SUCCESS == ret && !host_id) { | 508 | if (IPHONE_E_SUCCESS == ret && !host_id) { |
| 509 | log_debug_msg("No HostID found, run libiphone-initconf.\n"); | ||
| 510 | ret = IPHONE_E_INVALID_CONF; | 509 | ret = IPHONE_E_INVALID_CONF; |
| 511 | } | 510 | } |
| 512 | 511 | ||
| @@ -847,6 +846,60 @@ iphone_error_t lockdownd_start_SSL_session(iphone_lckd_client_t control, const c | |||
| 847 | if (!dict) | 846 | if (!dict) |
| 848 | return IPHONE_E_PLIST_ERROR; | 847 | return IPHONE_E_PLIST_ERROR; |
| 849 | 848 | ||
| 849 | plist_t request_node = plist_get_dict_el_from_key(dict, "Request"); | ||
| 850 | plist_t result_node = plist_get_dict_el_from_key(dict, "Result"); | ||
| 851 | |||
| 852 | if (request_node && PLIST_STRING == plist_get_node_type(request_node) && | ||
| 853 | result_node && PLIST_STRING == plist_get_node_type(result_node)){ | ||
| 854 | |||
| 855 | char *request = NULL; | ||
| 856 | char *result = NULL; | ||
| 857 | |||
| 858 | plist_get_string_val(request_node, &request); | ||
| 859 | plist_get_string_val(result_node, &result); | ||
| 860 | |||
| 861 | if (!strcmp(request, "StartSession")) { | ||
| 862 | if (!strcmp(result, "Failure")) { | ||
| 863 | |||
| 864 | plist_t error_node = plist_get_dict_el_from_key(dict, "Error"); | ||
| 865 | if (error_node && PLIST_STRING == plist_get_node_type(error_node)) { | ||
| 866 | |||
| 867 | char *error = NULL; | ||
| 868 | plist_get_string_val(error_node, &error); | ||
| 869 | |||
| 870 | if (!strcmp(error, "InvalidHostID")) { | ||
| 871 | //hostid is not know. Pair and try again | ||
| 872 | char *uid = NULL; | ||
| 873 | char* host_id = get_host_id(); | ||
| 874 | if (IPHONE_E_SUCCESS == lockdownd_get_device_uid(control, &uid) ) { | ||
| 875 | if (IPHONE_E_SUCCESS == lockdownd_pair_device(control, uid, host_id) ) { | ||
| 876 | |||
| 877 | //start session again | ||
| 878 | plist_free(dict); | ||
| 879 | dict = plist_new_dict(); | ||
| 880 | plist_add_sub_key_el(dict, "HostID"); | ||
| 881 | plist_add_sub_string_el(dict, HostID); | ||
| 882 | plist_add_sub_key_el(dict, "Request"); | ||
| 883 | plist_add_sub_string_el(dict, "StartSession"); | ||
| 884 | |||
| 885 | ret = iphone_lckd_send(control, dict); | ||
| 886 | plist_free(dict); | ||
| 887 | dict = NULL; | ||
| 888 | |||
| 889 | ret = iphone_lckd_recv(control, &dict); | ||
| 890 | } | ||
| 891 | } | ||
| 892 | free(uid); | ||
| 893 | free(host_id); | ||
| 894 | } | ||
| 895 | free(error); | ||
| 896 | } | ||
| 897 | } | ||
| 898 | } | ||
| 899 | free(request); | ||
| 900 | free(result); | ||
| 901 | } | ||
| 902 | |||
| 850 | plist_t query_node = plist_find_node_by_string(dict, "StartSession"); | 903 | plist_t query_node = plist_find_node_by_string(dict, "StartSession"); |
| 851 | plist_t result_key_node = plist_get_next_sibling(query_node); | 904 | plist_t result_key_node = plist_get_next_sibling(query_node); |
| 852 | plist_t result_value_node = plist_get_next_sibling(result_key_node); | 905 | plist_t result_value_node = plist_get_next_sibling(result_key_node); |
