diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/idevice.c | 4 | ||||
| -rw-r--r-- | src/lockdown.c | 76 | ||||
| -rw-r--r-- | src/property_list_service.c | 4 |
3 files changed, 45 insertions, 39 deletions
diff --git a/src/idevice.c b/src/idevice.c index b6dfe4e..913038e 100644 --- a/src/idevice.c +++ b/src/idevice.c | |||
| @@ -376,8 +376,8 @@ static idevice_error_t internal_connection_receive_timeout(idevice_connection_t | |||
| 376 | if (connection->type == CONNECTION_USBMUXD) { | 376 | if (connection->type == CONNECTION_USBMUXD) { |
| 377 | int res = usbmuxd_recv_timeout((int)(long)connection->data, data, len, recv_bytes, timeout); | 377 | int res = usbmuxd_recv_timeout((int)(long)connection->data, data, len, recv_bytes, timeout); |
| 378 | if (res < 0) { | 378 | if (res < 0) { |
| 379 | debug_info("ERROR: usbmuxd_recv_timeout returned %d (%s)", res, strerror(-res)); | 379 | debug_info("ERROR: usbmuxd_recv_timeout returned %d (%s)", res, strerror(errno)); |
| 380 | return IDEVICE_E_UNKNOWN_ERROR; | 380 | return (res == -EAGAIN ? IDEVICE_E_NOT_ENOUGH_DATA : IDEVICE_E_UNKNOWN_ERROR); |
| 381 | } | 381 | } |
| 382 | return IDEVICE_E_SUCCESS; | 382 | return IDEVICE_E_SUCCESS; |
| 383 | } else { | 383 | } else { |
diff --git a/src/lockdown.c b/src/lockdown.c index cae950b..5251737 100644 --- a/src/lockdown.c +++ b/src/lockdown.c | |||
| @@ -136,6 +136,36 @@ static lockdownd_error_t lockdownd_strtoerr(const char* name) | |||
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | /** | 138 | /** |
| 139 | * Convert a property_list_service_error_t value to a lockdownd_error_t | ||
| 140 | * value. Used internally to get correct error codes. | ||
| 141 | * | ||
| 142 | * @param err A property_list_service_error_t error code | ||
| 143 | * | ||
| 144 | * @return A matching lockdownd_error_t error code, | ||
| 145 | * LOCKDOWND_E_UNKNOWN_ERROR otherwise. | ||
| 146 | */ | ||
| 147 | static lockdownd_error_t lockdownd_error(property_list_service_error_t err) | ||
| 148 | { | ||
| 149 | switch (err) { | ||
| 150 | case PROPERTY_LIST_SERVICE_E_SUCCESS: | ||
| 151 | return LOCKDOWN_E_SUCCESS; | ||
| 152 | case PROPERTY_LIST_SERVICE_E_INVALID_ARG: | ||
| 153 | return LOCKDOWN_E_INVALID_ARG; | ||
| 154 | case PROPERTY_LIST_SERVICE_E_PLIST_ERROR: | ||
| 155 | return LOCKDOWN_E_PLIST_ERROR; | ||
| 156 | case PROPERTY_LIST_SERVICE_E_MUX_ERROR: | ||
| 157 | return LOCKDOWN_E_MUX_ERROR; | ||
| 158 | case PROPERTY_LIST_SERVICE_E_SSL_ERROR: | ||
| 159 | return LOCKDOWN_E_SSL_ERROR; | ||
| 160 | case PROPERTY_LIST_SERVICE_E_RECEIVE_TIMEOUT: | ||
| 161 | return LOCKDOWN_E_RECEIVE_TIMEOUT; | ||
| 162 | default: | ||
| 163 | break; | ||
| 164 | } | ||
| 165 | return LOCKDOWN_E_UNKNOWN_ERROR; | ||
| 166 | } | ||
| 167 | |||
| 168 | /** | ||
| 139 | * Internally used function for checking the result from lockdown's answer | 169 | * Internally used function for checking the result from lockdown's answer |
| 140 | * plist to a previously sent request. | 170 | * plist to a previously sent request. |
| 141 | * | 171 | * |
| @@ -349,18 +379,8 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_receive(lockdownd_client_t clie | |||
| 349 | { | 379 | { |
| 350 | if (!client || !plist || (plist && *plist)) | 380 | if (!client || !plist || (plist && *plist)) |
| 351 | return LOCKDOWN_E_INVALID_ARG; | 381 | return LOCKDOWN_E_INVALID_ARG; |
| 352 | lockdownd_error_t ret = LOCKDOWN_E_SUCCESS; | ||
| 353 | property_list_service_error_t err; | ||
| 354 | |||
| 355 | err = property_list_service_receive_plist(client->parent, plist); | ||
| 356 | if (err != PROPERTY_LIST_SERVICE_E_SUCCESS) { | ||
| 357 | ret = LOCKDOWN_E_UNKNOWN_ERROR; | ||
| 358 | } | ||
| 359 | 382 | ||
| 360 | if (!*plist) | 383 | return lockdownd_error(property_list_service_receive_plist(client->parent, plist)); |
| 361 | ret = LOCKDOWN_E_PLIST_ERROR; | ||
| 362 | |||
| 363 | return ret; | ||
| 364 | } | 384 | } |
| 365 | 385 | ||
| 366 | LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist) | 386 | LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist) |
| @@ -368,14 +388,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_send(lockdownd_client_t client, | |||
| 368 | if (!client || !plist) | 388 | if (!client || !plist) |
| 369 | return LOCKDOWN_E_INVALID_ARG; | 389 | return LOCKDOWN_E_INVALID_ARG; |
| 370 | 390 | ||
| 371 | lockdownd_error_t ret = LOCKDOWN_E_SUCCESS; | 391 | return lockdownd_error(property_list_service_send_xml_plist(client->parent, plist)); |
| 372 | property_list_service_error_t err; | ||
| 373 | |||
| 374 | err = property_list_service_send_xml_plist(client->parent, plist); | ||
| 375 | if (err != PROPERTY_LIST_SERVICE_E_SUCCESS) { | ||
| 376 | ret = LOCKDOWN_E_UNKNOWN_ERROR; | ||
| 377 | } | ||
| 378 | return ret; | ||
| 379 | } | 392 | } |
| 380 | 393 | ||
| 381 | LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type) | 394 | LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type) |
| @@ -686,13 +699,11 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new_with_handshake(idevi | |||
| 686 | } | 699 | } |
| 687 | 700 | ||
| 688 | /* perform handshake */ | 701 | /* perform handshake */ |
| 689 | if (LOCKDOWN_E_SUCCESS != lockdownd_query_type(client_loc, &type)) { | 702 | ret = lockdownd_query_type(client_loc, &type); |
| 703 | if (LOCKDOWN_E_SUCCESS != ret) { | ||
| 690 | debug_info("QueryType failed in the lockdownd client."); | 704 | debug_info("QueryType failed in the lockdownd client."); |
| 691 | ret = LOCKDOWN_E_NOT_ENOUGH_DATA; | 705 | } else if (strcmp("com.apple.mobile.lockdown", type)) { |
| 692 | } else { | 706 | debug_info("Warning QueryType request returned \"%s\".", type); |
| 693 | if (strcmp("com.apple.mobile.lockdown", type)) { | ||
| 694 | debug_info("Warning QueryType request returned \"%s\".", type); | ||
| 695 | } | ||
| 696 | } | 707 | } |
| 697 | free(type); | 708 | free(type); |
| 698 | 709 | ||
| @@ -1113,7 +1124,6 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_goodbye(lockdownd_client_t clie | |||
| 1113 | LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char *host_id, char **session_id, int *ssl_enabled) | 1124 | LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char *host_id, char **session_id, int *ssl_enabled) |
| 1114 | { | 1125 | { |
| 1115 | lockdownd_error_t ret = LOCKDOWN_E_SUCCESS; | 1126 | lockdownd_error_t ret = LOCKDOWN_E_SUCCESS; |
| 1116 | property_list_service_error_t plret; | ||
| 1117 | plist_t dict = NULL; | 1127 | plist_t dict = NULL; |
| 1118 | 1128 | ||
| 1119 | if (!client || !host_id) | 1129 | if (!client || !host_id) |
| @@ -1184,20 +1194,14 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_start_session(lockdownd_client_ | |||
| 1184 | debug_info("Failed to get SessionID!"); | 1194 | debug_info("Failed to get SessionID!"); |
| 1185 | } | 1195 | } |
| 1186 | 1196 | ||
| 1187 | debug_info("Enable SSL Session: %s", (use_ssl?"true":"false")); | 1197 | debug_info("Enable SSL Session: %s", (use_ssl ? "true" : "false")); |
| 1188 | 1198 | ||
| 1189 | if (use_ssl) { | 1199 | if (use_ssl) { |
| 1190 | plret = property_list_service_enable_ssl(client->parent); | 1200 | ret = lockdownd_error(property_list_service_enable_ssl(client->parent)); |
| 1191 | if (plret == PROPERTY_LIST_SERVICE_E_SUCCESS) { | 1201 | client->ssl_enabled = (ret == LOCKDOWN_E_SUCCESS ? 1 : 0); |
| 1192 | ret = LOCKDOWN_E_SUCCESS; | ||
| 1193 | client->ssl_enabled = 1; | ||
| 1194 | } else { | ||
| 1195 | ret = LOCKDOWN_E_SSL_ERROR; | ||
| 1196 | client->ssl_enabled = 0; | ||
| 1197 | } | ||
| 1198 | } else { | 1202 | } else { |
| 1199 | client->ssl_enabled = 0; | ||
| 1200 | ret = LOCKDOWN_E_SUCCESS; | 1203 | ret = LOCKDOWN_E_SUCCESS; |
| 1204 | client->ssl_enabled = 0; | ||
| 1201 | } | 1205 | } |
| 1202 | } | 1206 | } |
| 1203 | 1207 | ||
diff --git a/src/property_list_service.c b/src/property_list_service.c index a5bdf9b..f411699 100644 --- a/src/property_list_service.c +++ b/src/property_list_service.c | |||
| @@ -98,7 +98,8 @@ LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_client_ | |||
| 98 | * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success, | 98 | * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success, |
| 99 | * PROPERTY_LIST_SERVICE_E_INVALID_ARG when one or more parameters are | 99 | * PROPERTY_LIST_SERVICE_E_INVALID_ARG when one or more parameters are |
| 100 | * invalid, PROPERTY_LIST_SERVICE_E_PLIST_ERROR when dict is not a valid | 100 | * invalid, PROPERTY_LIST_SERVICE_E_PLIST_ERROR when dict is not a valid |
| 101 | * plist, or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when an unspecified | 101 | * plist, PROPERTY_LIST_SERVICE_E_MUX_ERROR when a communication error |
| 102 | * occurs, or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when an unspecified | ||
| 102 | * error occurs. | 103 | * error occurs. |
| 103 | */ | 104 | */ |
| 104 | static property_list_service_error_t internal_plist_send(property_list_service_client_t client, plist_t plist, int binary) | 105 | static property_list_service_error_t internal_plist_send(property_list_service_client_t client, plist_t plist, int binary) |
| @@ -140,6 +141,7 @@ static property_list_service_error_t internal_plist_send(property_list_service_c | |||
| 140 | } | 141 | } |
| 141 | if (bytes <= 0) { | 142 | if (bytes <= 0) { |
| 142 | debug_info("ERROR: sending to device failed."); | 143 | debug_info("ERROR: sending to device failed."); |
| 144 | res = PROPERTY_LIST_SERVICE_E_MUX_ERROR; | ||
| 143 | } | 145 | } |
| 144 | 146 | ||
| 145 | free(content); | 147 | free(content); |
