summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lockdown.c46
-rw-r--r--src/lockdown.h3
2 files changed, 26 insertions, 23 deletions
diff --git a/src/lockdown.c b/src/lockdown.c
index c78d691..5cf90a5 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -28,6 +28,7 @@
28#include <gnutls/x509.h> 28#include <gnutls/x509.h>
29#include <plist/plist.h> 29#include <plist/plist.h>
30 30
31#include "property_list_service.h"
31#include "lockdown.h" 32#include "lockdown.h"
32#include "iphone.h" 33#include "iphone.h"
33#include "utils.h" 34#include "utils.h"
@@ -223,13 +224,11 @@ lockdownd_error_t lockdownd_client_free(lockdownd_client_t client)
223 224
224 lockdownd_stop_ssl_session(client); 225 lockdownd_stop_ssl_session(client);
225 226
226 if (client->connection) { 227 if (client->parent) {
227 lockdownd_goodbye(client); 228 lockdownd_goodbye(client);
228 229
229 // IMO, read of final "sessionUpcall connection closed" packet 230 if (property_list_service_client_free(client->parent) == PROPERTY_LIST_SERVICE_E_SUCCESS) {
230 // should come here instead of in iphone_free_device 231 ret = LOCKDOWN_E_SUCCESS;
231 if ((ret = iphone_device_disconnect(client->connection)) != IPHONE_E_SUCCESS) {
232 ret = LOCKDOWN_E_UNKNOWN_ERROR;
233 } 232 }
234 } 233 }
235 234
@@ -276,16 +275,16 @@ lockdownd_error_t lockdownd_recv(lockdownd_client_t client, plist_t *plist)
276 if (!client || !plist || (plist && *plist)) 275 if (!client || !plist || (plist && *plist))
277 return LOCKDOWN_E_INVALID_ARG; 276 return LOCKDOWN_E_INVALID_ARG;
278 lockdownd_error_t ret = LOCKDOWN_E_SUCCESS; 277 lockdownd_error_t ret = LOCKDOWN_E_SUCCESS;
279 iphone_error_t err; 278 property_list_service_error_t err;
280 279
281 if (!client->in_SSL) { 280 if (!client->in_SSL) {
282 err = iphone_device_receive_plist(client->connection, plist); 281 err = property_list_service_receive_plist(client->parent, plist);
283 if (err != IPHONE_E_SUCCESS) { 282 if (err != PROPERTY_LIST_SERVICE_E_SUCCESS) {
284 ret = LOCKDOWN_E_UNKNOWN_ERROR; 283 ret = LOCKDOWN_E_UNKNOWN_ERROR;
285 } 284 }
286 } else { 285 } else {
287 err = iphone_device_receive_encrypted_plist(client->ssl_session, plist); 286 err = property_list_service_receive_encrypted_plist(client->ssl_session, plist);
288 if (err != IPHONE_E_SUCCESS) { 287 if (err != PROPERTY_LIST_SERVICE_E_SUCCESS) {
289 return LOCKDOWN_E_SSL_ERROR; 288 return LOCKDOWN_E_SSL_ERROR;
290 } 289 }
291 } 290 }
@@ -315,13 +314,13 @@ lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist)
315 iphone_error_t err; 314 iphone_error_t err;
316 315
317 if (!client->in_SSL) { 316 if (!client->in_SSL) {
318 err = iphone_device_send_xml_plist(client->connection, plist); 317 err = property_list_service_send_xml_plist(client->parent, plist);
319 if (err != IPHONE_E_SUCCESS) { 318 if (err != PROPERTY_LIST_SERVICE_E_SUCCESS) {
320 ret = LOCKDOWN_E_UNKNOWN_ERROR; 319 ret = LOCKDOWN_E_UNKNOWN_ERROR;
321 } 320 }
322 } else { 321 } else {
323 err = iphone_device_send_encrypted_xml_plist(client->ssl_session, plist); 322 err = property_list_service_send_encrypted_xml_plist(client->ssl_session, plist);
324 if (err != IPHONE_E_SUCCESS) { 323 if (err != PROPERTY_LIST_SERVICE_E_SUCCESS) {
325 ret = LOCKDOWN_E_SSL_ERROR; 324 ret = LOCKDOWN_E_SSL_ERROR;
326 } 325 }
327 } 326 }
@@ -635,14 +634,14 @@ lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_
635 char *host_id = NULL; 634 char *host_id = NULL;
636 char *type = NULL; 635 char *type = NULL;
637 636
638 iphone_connection_t connection; 637 property_list_service_client_t plistclient = NULL;
639 if (iphone_device_connect(device, 0xf27e, &connection) != IPHONE_E_SUCCESS) { 638 if (property_list_service_client_new(device, 0xf27e, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
640 log_debug_msg("%s: could not connect to lockdownd (device %s)\n", __func__, device->uuid); 639 log_debug_msg("%s: could not connect to lockdownd (device %s)\n", __func__, device->uuid);
641 return LOCKDOWN_E_MUX_ERROR; 640 return LOCKDOWN_E_MUX_ERROR;
642 } 641 }
643 642
644 lockdownd_client_t client_loc = (lockdownd_client_t) malloc(sizeof(struct lockdownd_client_int)); 643 lockdownd_client_t client_loc = (lockdownd_client_t) malloc(sizeof(struct lockdownd_client_int));
645 client_loc->connection = connection; 644 client_loc->parent = plistclient;
646 client_loc->ssl_session = NULL; 645 client_loc->ssl_session = NULL;
647 client_loc->ssl_certificate = NULL; 646 client_loc->ssl_certificate = NULL;
648 client_loc->in_SSL = 0; 647 client_loc->in_SSL = 0;
@@ -691,9 +690,12 @@ lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_
691 free(host_id); 690 free(host_id);
692 host_id = NULL; 691 host_id = NULL;
693 } 692 }
694 693 }
695 if (LOCKDOWN_E_SUCCESS == ret) 694
696 *client = client_loc; 695 if (LOCKDOWN_E_SUCCESS == ret) {
696 *client = client_loc;
697 } else {
698 lockdownd_client_free(client_loc);
697 } 699 }
698 700
699 return ret; 701 return ret;
@@ -1233,7 +1235,7 @@ ssize_t lockdownd_secuwrite(gnutls_transport_ptr_t transport, char *buffer, size
1233 client = (lockdownd_client_t) transport; 1235 client = (lockdownd_client_t) transport;
1234 log_dbg_msg(DBGMASK_LOCKDOWND, "%s: called\n", __func__); 1236 log_dbg_msg(DBGMASK_LOCKDOWND, "%s: called\n", __func__);
1235 log_dbg_msg(DBGMASK_LOCKDOWND, "%s: pre-send length = %zi\n", __func__, length); 1237 log_dbg_msg(DBGMASK_LOCKDOWND, "%s: pre-send length = %zi\n", __func__, length);
1236 iphone_device_send(client->connection, buffer, length, &bytes); 1238 iphone_device_send(property_list_service_get_connection(client->parent), buffer, length, &bytes);
1237 log_dbg_msg(DBGMASK_LOCKDOWND, "%s: post-send sent %i bytes\n", __func__, bytes); 1239 log_dbg_msg(DBGMASK_LOCKDOWND, "%s: post-send sent %i bytes\n", __func__, bytes);
1238 return bytes; 1240 return bytes;
1239} 1241}
@@ -1262,7 +1264,7 @@ ssize_t lockdownd_securead(gnutls_transport_ptr_t transport, char *buffer, size_
1262 1264
1263 // repeat until we have the full data or an error occurs. 1265 // repeat until we have the full data or an error occurs.
1264 do { 1266 do {
1265 if ((res = iphone_device_recv(client->connection, recv_buffer, this_len, (uint32_t*)&bytes)) != LOCKDOWN_E_SUCCESS) { 1267 if ((res = iphone_device_recv(property_list_service_get_connection(client->parent), recv_buffer, this_len, (uint32_t*)&bytes)) != LOCKDOWN_E_SUCCESS) {
1266 log_debug_msg("%s: ERROR: usbmux_recv returned %d\n", __func__, res); 1268 log_debug_msg("%s: ERROR: usbmux_recv returned %d\n", __func__, res);
1267 return res; 1269 return res;
1268 } 1270 }
diff --git a/src/lockdown.h b/src/lockdown.h
index 6e1b843..8de74dd 100644
--- a/src/lockdown.h
+++ b/src/lockdown.h
@@ -26,9 +26,10 @@
26#include <string.h> 26#include <string.h>
27 27
28#include "libiphone/lockdown.h" 28#include "libiphone/lockdown.h"
29#include "property_list_service.h"
29 30
30struct lockdownd_client_int { 31struct lockdownd_client_int {
31 iphone_connection_t connection; 32 property_list_service_client_t parent;
32 gnutls_session_t ssl_session; 33 gnutls_session_t ssl_session;
33 gnutls_certificate_credentials_t ssl_certificate; 34 gnutls_certificate_credentials_t ssl_certificate;
34 int in_SSL; 35 int in_SSL;