diff options
Diffstat (limited to 'src/lockdown.c')
| -rw-r--r-- | src/lockdown.c | 95 |
1 files changed, 44 insertions, 51 deletions
diff --git a/src/lockdown.c b/src/lockdown.c index 1a434aa..bfb44d0 100644 --- a/src/lockdown.c +++ b/src/lockdown.c | |||
| @@ -140,7 +140,7 @@ iphone_error_t lockdownd_stop_session(lockdownd_client_t client) | |||
| 140 | plist_add_sub_key_el(dict, "SessionID"); | 140 | plist_add_sub_key_el(dict, "SessionID"); |
| 141 | plist_add_sub_string_el(dict, client->session_id); | 141 | plist_add_sub_string_el(dict, client->session_id); |
| 142 | 142 | ||
| 143 | log_dbg_msg(DBGMASK_LOCKDOWND, "iphone_lckd_stop_session() called\n"); | 143 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: called\n", __func__); |
| 144 | 144 | ||
| 145 | ret = lockdownd_send(client, dict); | 145 | ret = lockdownd_send(client, dict); |
| 146 | 146 | ||
| @@ -150,13 +150,13 @@ iphone_error_t lockdownd_stop_session(lockdownd_client_t client) | |||
| 150 | ret = lockdownd_recv(client, &dict); | 150 | ret = lockdownd_recv(client, &dict); |
| 151 | 151 | ||
| 152 | if (!dict) { | 152 | if (!dict) { |
| 153 | log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_stop_session(): IPHONE_E_PLIST_ERROR\n"); | 153 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: LOCKDOWN_E_PLIST_ERROR\n", __func__); |
| 154 | return IPHONE_E_PLIST_ERROR; | 154 | return IPHONE_E_PLIST_ERROR; |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | ret = IPHONE_E_UNKNOWN_ERROR; | 157 | ret = IPHONE_E_UNKNOWN_ERROR; |
| 158 | if (lockdown_check_result(dict, "StopSession") == RESULT_SUCCESS) { | 158 | if (lockdown_check_result(dict, "StopSession") == RESULT_SUCCESS) { |
| 159 | log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_stop_session(): success\n"); | 159 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: success\n", __func__); |
| 160 | ret = IPHONE_E_SUCCESS; | 160 | ret = IPHONE_E_SUCCESS; |
| 161 | } | 161 | } |
| 162 | plist_free(dict); | 162 | plist_free(dict); |
| @@ -175,15 +175,15 @@ iphone_error_t lockdownd_stop_session(lockdownd_client_t client) | |||
| 175 | static iphone_error_t lockdownd_stop_ssl_session(lockdownd_client_t client) | 175 | static iphone_error_t lockdownd_stop_ssl_session(lockdownd_client_t client) |
| 176 | { | 176 | { |
| 177 | if (!client) { | 177 | if (!client) { |
| 178 | log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_stop_ssl_session(): invalid argument!\n"); | 178 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: invalid argument!\n", __func__); |
| 179 | return IPHONE_E_INVALID_ARG; | 179 | return IPHONE_E_INVALID_ARG; |
| 180 | } | 180 | } |
| 181 | iphone_error_t ret = IPHONE_E_SUCCESS; | 181 | iphone_error_t ret = IPHONE_E_SUCCESS; |
| 182 | 182 | ||
| 183 | if (client->in_SSL) { | 183 | if (client->in_SSL) { |
| 184 | log_dbg_msg(DBGMASK_LOCKDOWND, "Stopping SSL Session\n"); | 184 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: stopping SSL session\n", __func__); |
| 185 | ret = lockdownd_stop_session(client); | 185 | ret = lockdownd_stop_session(client); |
| 186 | log_dbg_msg(DBGMASK_LOCKDOWND, "Sending SSL close notify\n"); | 186 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: sending SSL close notify\n", __func__); |
| 187 | gnutls_bye(*client->ssl_session, GNUTLS_SHUT_RDWR); | 187 | gnutls_bye(*client->ssl_session, GNUTLS_SHUT_RDWR); |
| 188 | } | 188 | } |
| 189 | if (client->ssl_session) { | 189 | if (client->ssl_session) { |
| @@ -281,7 +281,7 @@ iphone_error_t lockdownd_recv(lockdownd_client_t client, plist_t *plist) | |||
| 281 | return IPHONE_E_NOT_ENOUGH_DATA; | 281 | return IPHONE_E_NOT_ENOUGH_DATA; |
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | log_dbg_msg(DBGMASK_LOCKDOWND, "Recv msg :\nsize : %i\nbuffer :\n%s\n", received_bytes, receive); | 284 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: received msg size: %i, buffer follows:\n%s", __func__, received_bytes, receive); |
| 285 | plist_from_xml(receive, received_bytes, plist); | 285 | plist_from_xml(receive, received_bytes, plist); |
| 286 | free(receive); | 286 | free(receive); |
| 287 | 287 | ||
| @@ -312,14 +312,14 @@ iphone_error_t lockdownd_send(lockdownd_client_t client, plist_t plist) | |||
| 312 | iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; | 312 | iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; |
| 313 | 313 | ||
| 314 | plist_to_xml(plist, &XMLContent, &length); | 314 | plist_to_xml(plist, &XMLContent, &length); |
| 315 | log_dbg_msg(DBGMASK_LOCKDOWND, "Send msg :\nsize : %i\nbuffer :\n%s\n", length, XMLContent); | 315 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: sending msg size %i, buffer follows:\n%s", __func__, length, XMLContent); |
| 316 | 316 | ||
| 317 | real_query = (char *) malloc(sizeof(char) * (length + 4)); | 317 | real_query = (char *) malloc(sizeof(char) * (length + 4)); |
| 318 | length = htonl(length); | 318 | length = htonl(length); |
| 319 | memcpy(real_query, &length, sizeof(length)); | 319 | memcpy(real_query, &length, sizeof(length)); |
| 320 | memcpy(real_query + 4, XMLContent, ntohl(length)); | 320 | memcpy(real_query + 4, XMLContent, ntohl(length)); |
| 321 | free(XMLContent); | 321 | free(XMLContent); |
| 322 | log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_send(): made the query, sending it along\n"); | 322 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: made the query, sending it along\n", __func__); |
| 323 | 323 | ||
| 324 | if (!client->in_SSL) | 324 | if (!client->in_SSL) |
| 325 | ret = usbmuxd_send(client->sfd, real_query, ntohl(length) + sizeof(length), (uint32_t*)&bytes); | 325 | ret = usbmuxd_send(client->sfd, real_query, ntohl(length) + sizeof(length), (uint32_t*)&bytes); |
| @@ -334,9 +334,9 @@ iphone_error_t lockdownd_send(lockdownd_client_t client, plist_t plist) | |||
| 334 | } | 334 | } |
| 335 | } | 335 | } |
| 336 | if (ret == IPHONE_E_SUCCESS) { | 336 | if (ret == IPHONE_E_SUCCESS) { |
| 337 | log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_send(): sent it!\n"); | 337 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: sent it!\n", __func__); |
| 338 | } else { | 338 | } else { |
| 339 | log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_send(): sending failed!\n"); | 339 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: sending failed!\n", __func__); |
| 340 | } | 340 | } |
| 341 | free(real_query); | 341 | free(real_query); |
| 342 | 342 | ||
| @@ -360,7 +360,7 @@ iphone_error_t lockdownd_query_type(lockdownd_client_t client) | |||
| 360 | plist_add_sub_key_el(dict, "Request"); | 360 | plist_add_sub_key_el(dict, "Request"); |
| 361 | plist_add_sub_string_el(dict, "QueryType"); | 361 | plist_add_sub_string_el(dict, "QueryType"); |
| 362 | 362 | ||
| 363 | log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_query_type() called\n"); | 363 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: called\n", __func__); |
| 364 | ret = lockdownd_send(client, dict); | 364 | ret = lockdownd_send(client, dict); |
| 365 | 365 | ||
| 366 | plist_free(dict); | 366 | plist_free(dict); |
| @@ -373,7 +373,7 @@ iphone_error_t lockdownd_query_type(lockdownd_client_t client) | |||
| 373 | 373 | ||
| 374 | ret = IPHONE_E_UNKNOWN_ERROR; | 374 | ret = IPHONE_E_UNKNOWN_ERROR; |
| 375 | if (lockdown_check_result(dict, "QueryType") == RESULT_SUCCESS) { | 375 | if (lockdown_check_result(dict, "QueryType") == RESULT_SUCCESS) { |
| 376 | log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_query_type(): success\n"); | 376 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: success\n", __func__); |
| 377 | ret = IPHONE_E_SUCCESS; | 377 | ret = IPHONE_E_SUCCESS; |
| 378 | } | 378 | } |
| 379 | plist_free(dict); | 379 | plist_free(dict); |
| @@ -445,7 +445,7 @@ iphone_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain | |||
| 445 | plist_get_key_val(value_key_node, &result_key); | 445 | plist_get_key_val(value_key_node, &result_key); |
| 446 | 446 | ||
| 447 | if (!strcmp(result_key, "Value")) { | 447 | if (!strcmp(result_key, "Value")) { |
| 448 | log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_get_value(): has a value\n"); | 448 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: has a value\n", __func__); |
| 449 | *value = plist_copy(value_value_node); | 449 | *value = plist_copy(value_value_node); |
| 450 | } | 450 | } |
| 451 | free(result_key); | 451 | free(result_key); |
| @@ -669,17 +669,16 @@ iphone_error_t lockdownd_new_client(iphone_device_t device, lockdownd_client_t * | |||
| 669 | client_loc->ssl_session = (gnutls_session_t *) malloc(sizeof(gnutls_session_t)); | 669 | client_loc->ssl_session = (gnutls_session_t *) malloc(sizeof(gnutls_session_t)); |
| 670 | client_loc->in_SSL = 0; | 670 | client_loc->in_SSL = 0; |
| 671 | 671 | ||
| 672 | if (IPHONE_E_SUCCESS != lockdownd_query_type(client_loc)) { | 672 | log_debug_msg("%s: QueryType failed in the lockdownd client.\n", __func__); |
| 673 | log_debug_msg("QueryType failed in the lockdownd client.\n"); | ||
| 674 | ret = IPHONE_E_NOT_ENOUGH_DATA; | 673 | ret = IPHONE_E_NOT_ENOUGH_DATA; |
| 675 | } | 674 | } |
| 676 | 675 | ||
| 677 | char *uid = NULL; | 676 | char *uid = NULL; |
| 678 | ret = lockdownd_get_device_uid(client_loc, &uid); | 677 | ret = lockdownd_get_device_uid(client_loc, &uid); |
| 679 | if (IPHONE_E_SUCCESS != ret) { | 678 | if (IPHONE_E_SUCCESS != ret) { |
| 680 | log_debug_msg("Device refused to send uid.\n"); | 679 | log_debug_msg("%s: failed to get device uuid.\n", __func__); |
| 681 | } | 680 | } |
| 682 | log_debug_msg("Device uid: %s\n", uid); | 681 | log_debug_msg("%s: device uuid: %s\n", __func__, uid); |
| 683 | 682 | ||
| 684 | host_id = get_host_id(); | 683 | host_id = get_host_id(); |
| 685 | if (IPHONE_E_SUCCESS == ret && !host_id) { | 684 | if (IPHONE_E_SUCCESS == ret && !host_id) { |
| @@ -698,7 +697,7 @@ iphone_error_t lockdownd_new_client(iphone_device_t device, lockdownd_client_t * | |||
| 698 | ret = lockdownd_start_ssl_session(client_loc, host_id); | 697 | ret = lockdownd_start_ssl_session(client_loc, host_id); |
| 699 | if (IPHONE_E_SUCCESS != ret) { | 698 | if (IPHONE_E_SUCCESS != ret) { |
| 700 | ret = IPHONE_E_SSL_ERROR; | 699 | ret = IPHONE_E_SSL_ERROR; |
| 701 | log_debug_msg("SSL Session opening failed.\n"); | 700 | log_debug_msg("%s: SSL Session opening failed.\n", __func__); |
| 702 | } | 701 | } |
| 703 | 702 | ||
| 704 | if (host_id) { | 703 | if (host_id) { |
| @@ -731,10 +730,10 @@ iphone_error_t lockdownd_pair(lockdownd_client_t client, char *uid, char *host_i | |||
| 731 | 730 | ||
| 732 | ret = lockdownd_get_device_public_key(client, &public_key); | 731 | ret = lockdownd_get_device_public_key(client, &public_key); |
| 733 | if (ret != IPHONE_E_SUCCESS) { | 732 | if (ret != IPHONE_E_SUCCESS) { |
| 734 | log_debug_msg("Device refused to send public key.\n"); | 733 | log_debug_msg("%s: device refused to send public key.\n", __func__); |
| 735 | return ret; | 734 | return ret; |
| 736 | } | 735 | } |
| 737 | log_debug_msg("device public key :\n %s.\n", public_key.data); | 736 | log_debug_msg("%s: device public key follows:\n%s\n", __func__, public_key.data); |
| 738 | 737 | ||
| 739 | ret = lockdownd_gen_pair_cert(public_key, &device_cert, &host_cert, &root_cert); | 738 | ret = lockdownd_gen_pair_cert(public_key, &device_cert, &host_cert, &root_cert); |
| 740 | if (ret != IPHONE_E_SUCCESS) { | 739 | if (ret != IPHONE_E_SUCCESS) { |
| @@ -780,11 +779,11 @@ iphone_error_t lockdownd_pair(lockdownd_client_t client, char *uid, char *host_i | |||
| 780 | 779 | ||
| 781 | /* store public key in config if pairing succeeded */ | 780 | /* store public key in config if pairing succeeded */ |
| 782 | if (ret == IPHONE_E_SUCCESS) { | 781 | if (ret == IPHONE_E_SUCCESS) { |
| 783 | log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_pair: pair success\n"); | 782 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: pair success\n", __func__); |
| 784 | store_device_public_key(uid, public_key); | 783 | store_device_public_key(uid, public_key); |
| 785 | ret = IPHONE_E_SUCCESS; | 784 | ret = IPHONE_E_SUCCESS; |
| 786 | } else { | 785 | } else { |
| 787 | log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_pair: pair failure\n"); | 786 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: pair failure\n", __func__); |
| 788 | ret = IPHONE_E_PAIRING_FAILED; | 787 | ret = IPHONE_E_PAIRING_FAILED; |
| 789 | } | 788 | } |
| 790 | free(public_key.data); | 789 | free(public_key.data); |
| @@ -809,7 +808,7 @@ iphone_error_t lockdownd_enter_recovery(lockdownd_client_t client) | |||
| 809 | plist_add_sub_key_el(dict, "Request"); | 808 | plist_add_sub_key_el(dict, "Request"); |
| 810 | plist_add_sub_string_el(dict, "EnterRecovery"); | 809 | plist_add_sub_string_el(dict, "EnterRecovery"); |
| 811 | 810 | ||
| 812 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: Telling device to enter recovery mode\n", __func__); | 811 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: telling device to enter recovery mode\n", __func__); |
| 813 | 812 | ||
| 814 | ret = lockdownd_send(client, dict); | 813 | ret = lockdownd_send(client, dict); |
| 815 | plist_free(dict); | 814 | plist_free(dict); |
| @@ -845,21 +844,20 @@ iphone_error_t lockdownd_goodbye(lockdownd_client_t client) | |||
| 845 | plist_add_sub_key_el(dict, "Request"); | 844 | plist_add_sub_key_el(dict, "Request"); |
| 846 | plist_add_sub_string_el(dict, "Goodbye"); | 845 | plist_add_sub_string_el(dict, "Goodbye"); |
| 847 | 846 | ||
| 848 | log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_goodbye() called\n"); | 847 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: called\n", __func__); |
| 849 | 848 | ||
| 850 | ret = lockdownd_send(client, dict); | 849 | ret = lockdownd_send(client, dict); |
| 851 | plist_free(dict); | 850 | plist_free(dict); |
| 852 | dict = NULL; | 851 | dict = NULL; |
| 853 | 852 | ||
| 854 | ret = lockdownd_recv(client, &dict); | 853 | ret = lockdownd_recv(client, &dict); |
| 855 | |||
| 856 | if (!dict) { | 854 | if (!dict) { |
| 857 | log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_goodbye(): IPHONE_E_PLIST_ERROR\n"); | 855 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: did not get goodbye response back\n", __func__); |
| 858 | return IPHONE_E_PLIST_ERROR; | 856 | return IPHONE_E_PLIST_ERROR; |
| 859 | } | 857 | } |
| 860 | 858 | ||
| 861 | if (lockdown_check_result(dict, "Goodbye") == RESULT_SUCCESS) { | 859 | if (lockdown_check_result(dict, "Goodbye") == RESULT_SUCCESS) { |
| 862 | log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_goodbye(): success\n"); | 860 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: success\n", __func__); |
| 863 | ret = IPHONE_E_SUCCESS; | 861 | ret = IPHONE_E_SUCCESS; |
| 864 | } | 862 | } |
| 865 | plist_free(dict); | 863 | plist_free(dict); |
| @@ -1062,7 +1060,7 @@ iphone_error_t lockdownd_start_ssl_session(lockdownd_client_t client, const char | |||
| 1062 | //gnutls_anon_client_credentials_t anoncred; | 1060 | //gnutls_anon_client_credentials_t anoncred; |
| 1063 | gnutls_certificate_credentials_t xcred; | 1061 | gnutls_certificate_credentials_t xcred; |
| 1064 | 1062 | ||
| 1065 | log_dbg_msg(DBGMASK_LOCKDOWND, "We started the session OK, now trying GnuTLS\n"); | 1063 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: started the session OK, now trying GnuTLS\n", __func__); |
| 1066 | errno = 0; | 1064 | errno = 0; |
| 1067 | gnutls_global_init(); | 1065 | gnutls_global_init(); |
| 1068 | //gnutls_anon_allocate_client_credentials(&anoncred); | 1066 | //gnutls_anon_allocate_client_credentials(&anoncred); |
| @@ -1084,23 +1082,22 @@ iphone_error_t lockdownd_start_ssl_session(lockdownd_client_t client, const char | |||
| 1084 | } | 1082 | } |
| 1085 | gnutls_credentials_set(*client->ssl_session, GNUTLS_CRD_CERTIFICATE, xcred); // this part is killing me. | 1083 | gnutls_credentials_set(*client->ssl_session, GNUTLS_CRD_CERTIFICATE, xcred); // this part is killing me. |
| 1086 | 1084 | ||
| 1087 | log_dbg_msg(DBGMASK_LOCKDOWND, "GnuTLS step 1...\n"); | 1085 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS step 1...\n", __func__); |
| 1088 | gnutls_transport_set_ptr(*client->ssl_session, (gnutls_transport_ptr_t) client); | 1086 | gnutls_transport_set_ptr(*client->ssl_session, (gnutls_transport_ptr_t) client); |
| 1089 | log_dbg_msg(DBGMASK_LOCKDOWND, "GnuTLS step 2...\n"); | 1087 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS step 2...\n", __func__); |
| 1090 | gnutls_transport_set_push_function(*client->ssl_session, (gnutls_push_func) & lockdownd_secuwrite); | 1088 | gnutls_transport_set_push_function(*client->ssl_session, (gnutls_push_func) & lockdownd_secuwrite); |
| 1091 | log_dbg_msg(DBGMASK_LOCKDOWND, "GnuTLS step 3...\n"); | 1089 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS step 3...\n", __func__); |
| 1092 | gnutls_transport_set_pull_function(*client->ssl_session, (gnutls_pull_func) & lockdownd_securead); | 1090 | gnutls_transport_set_pull_function(*client->ssl_session, (gnutls_pull_func) & lockdownd_securead); |
| 1093 | log_dbg_msg(DBGMASK_LOCKDOWND, "GnuTLS step 4 -- now handshaking...\n"); | 1091 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS step 4 -- now handshaking...\n", __func__); |
| 1094 | |||
| 1095 | if (errno) | 1092 | if (errno) |
| 1096 | log_dbg_msg(DBGMASK_LOCKDOWND, "WARN: errno says %s before handshake!\n", strerror(errno)); | 1093 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: WARN: errno says %s before handshake!\n", __func__, strerror(errno)); |
| 1097 | return_me = gnutls_handshake(*client->ssl_session); | 1094 | return_me = gnutls_handshake(*client->ssl_session); |
| 1098 | log_dbg_msg(DBGMASK_LOCKDOWND, "GnuTLS handshake done...\n"); | 1095 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS handshake done...\n", __func__); |
| 1099 | 1096 | ||
| 1100 | if (return_me != GNUTLS_E_SUCCESS) { | 1097 | if (return_me != GNUTLS_E_SUCCESS) { |
| 1101 | log_dbg_msg(DBGMASK_LOCKDOWND, "GnuTLS reported something wrong.\n"); | 1098 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS reported something wrong.\n", __func__); |
| 1102 | gnutls_perror(return_me); | 1099 | gnutls_perror(return_me); |
| 1103 | log_dbg_msg(DBGMASK_LOCKDOWND, "oh.. errno says %s\n", strerror(errno)); | 1100 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: oh.. errno says %s\n", __func__, strerror(errno)); |
| 1104 | return IPHONE_E_SSL_ERROR; | 1101 | return IPHONE_E_SSL_ERROR; |
| 1105 | } else { | 1102 | } else { |
| 1106 | client->in_SSL = 1; | 1103 | client->in_SSL = 1; |
| @@ -1122,20 +1119,20 @@ iphone_error_t lockdownd_start_ssl_session(lockdownd_client_t client, const char | |||
| 1122 | if (session_node_val_type == PLIST_STRING && session_id) { | 1119 | if (session_node_val_type == PLIST_STRING && session_id) { |
| 1123 | // we need to store the session ID for StopSession | 1120 | // we need to store the session ID for StopSession |
| 1124 | strcpy(client->session_id, session_id); | 1121 | strcpy(client->session_id, session_id); |
| 1125 | log_dbg_msg(DBGMASK_LOCKDOWND, "SessionID: %s\n", client->session_id); | 1122 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: SessionID: %s\n", __func__, client->session_id); |
| 1126 | } | 1123 | } |
| 1127 | if (session_id) | 1124 | if (session_id) |
| 1128 | free(session_id); | 1125 | free(session_id); |
| 1129 | } | 1126 | } |
| 1130 | } else | 1127 | } else |
| 1131 | log_dbg_msg(DBGMASK_LOCKDOWND, "Failed to get SessionID!\n"); | 1128 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: Failed to get SessionID!\n", __func__); |
| 1132 | plist_free(dict); | 1129 | plist_free(dict); |
| 1133 | dict = NULL; | 1130 | dict = NULL; |
| 1134 | 1131 | ||
| 1135 | if (ret == IPHONE_E_SUCCESS) | 1132 | if (ret == IPHONE_E_SUCCESS) |
| 1136 | return ret; | 1133 | return ret; |
| 1137 | 1134 | ||
| 1138 | log_dbg_msg(DBGMASK_LOCKDOWND, "Apparently failed negotiating with lockdownd.\n"); | 1135 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: Apparently failed negotiating with lockdownd.\n", __func__); |
| 1139 | return IPHONE_E_SSL_ERROR; | 1136 | return IPHONE_E_SSL_ERROR; |
| 1140 | } | 1137 | } |
| 1141 | 1138 | ||
| @@ -1152,12 +1149,10 @@ ssize_t lockdownd_secuwrite(gnutls_transport_ptr_t transport, char *buffer, size | |||
| 1152 | uint32_t bytes = 0; | 1149 | uint32_t bytes = 0; |
| 1153 | lockdownd_client_t client; | 1150 | lockdownd_client_t client; |
| 1154 | client = (lockdownd_client_t) transport; | 1151 | client = (lockdownd_client_t) transport; |
| 1155 | log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_secuwrite() called\n"); | 1152 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: called\n", __func__); |
| 1156 | log_dbg_msg(DBGMASK_LOCKDOWND, "pre-send\nlength = %zi\n", length); | 1153 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: pre-send length = %zi\n", __func__, length); |
| 1157 | usbmuxd_send(client->sfd, buffer, length, &bytes); | 1154 | usbmuxd_send(client->sfd, buffer, length, &bytes); |
| 1158 | log_dbg_msg(DBGMASK_LOCKDOWND, "post-send\nsent %i bytes\n", bytes); | 1155 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: post-send sent %i bytes\n", __func__, bytes); |
| 1159 | |||
| 1160 | dump_debug_buffer("sslpacketwrite.out", buffer, length); | ||
| 1161 | return bytes; | 1156 | return bytes; |
| 1162 | } | 1157 | } |
| 1163 | 1158 | ||
| @@ -1179,9 +1174,7 @@ ssize_t lockdownd_securead(gnutls_transport_ptr_t transport, char *buffer, size_ | |||
| 1179 | client = (lockdownd_client_t) transport; | 1174 | client = (lockdownd_client_t) transport; |
| 1180 | char *recv_buffer; | 1175 | char *recv_buffer; |
| 1181 | 1176 | ||
| 1182 | log_debug_msg("lockdownd_securead() called\nlength = %zi\n", length); | 1177 | log_debug_msg("%s: pre-read client wants %zi bytes\n", __func__, length); |
| 1183 | |||
| 1184 | log_debug_msg("pre-read\nclient wants %zi bytes\n", length); | ||
| 1185 | 1178 | ||
| 1186 | recv_buffer = (char *) malloc(sizeof(char) * this_len); | 1179 | recv_buffer = (char *) malloc(sizeof(char) * this_len); |
| 1187 | 1180 | ||
| @@ -1191,7 +1184,7 @@ ssize_t lockdownd_securead(gnutls_transport_ptr_t transport, char *buffer, size_ | |||
| 1191 | log_debug_msg("%s: ERROR: usbmux_recv returned %d\n", __func__, res); | 1184 | log_debug_msg("%s: ERROR: usbmux_recv returned %d\n", __func__, res); |
| 1192 | return res; | 1185 | return res; |
| 1193 | } | 1186 | } |
| 1194 | log_debug_msg("post-read\nwe got %i bytes\n", bytes); | 1187 | log_debug_msg("%s: post-read we got %i bytes\n", __func__, bytes); |
| 1195 | 1188 | ||
| 1196 | // increase read count | 1189 | // increase read count |
| 1197 | tbytes += bytes; | 1190 | tbytes += bytes; |
| @@ -1205,7 +1198,7 @@ ssize_t lockdownd_securead(gnutls_transport_ptr_t transport, char *buffer, size_ | |||
| 1205 | } | 1198 | } |
| 1206 | 1199 | ||
| 1207 | this_len = length - tbytes; | 1200 | this_len = length - tbytes; |
| 1208 | log_debug_msg("re-read\ntrying to read missing %i bytes\n", this_len); | 1201 | log_debug_msg("%s: re-read trying to read missing %i bytes\n", __func__, this_len); |
| 1209 | } while (tbytes < length); | 1202 | } while (tbytes < length); |
| 1210 | 1203 | ||
| 1211 | if (recv_buffer) { | 1204 | if (recv_buffer) { |
