summaryrefslogtreecommitdiffstats
path: root/tools/ideviceimagemounter.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2013-02-26 03:20:56 +0100
committerGravatar Martin Szulecki2013-02-26 03:20:56 +0100
commitfcc1bb855efb6860417ed827d3b50feba24a9a8b (patch)
tree47d3c7d6a985dc647f7962329014c8116d657cc9 /tools/ideviceimagemounter.c
parent3b54aac30447bc02fafd721a63a752968628e7e0 (diff)
downloadlibimobiledevice-fcc1bb855efb6860417ed827d3b50feba24a9a8b.tar.gz
libimobiledevice-fcc1bb855efb6860417ed827d3b50feba24a9a8b.tar.bz2
Refactor port number use into service descriptor to enable SSL for services
This is a major change which breaks API but is required in order to support SSL communication for services as used by network connections.
Diffstat (limited to 'tools/ideviceimagemounter.c')
-rw-r--r--tools/ideviceimagemounter.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/tools/ideviceimagemounter.c b/tools/ideviceimagemounter.c
index 9b65a0e..57a2e27 100644
--- a/tools/ideviceimagemounter.c
+++ b/tools/ideviceimagemounter.c
@@ -267,7 +267,7 @@ int main(int argc, char **argv)
267 lockdownd_client_t lckd = NULL; 267 lockdownd_client_t lckd = NULL;
268 mobile_image_mounter_client_t mim = NULL; 268 mobile_image_mounter_client_t mim = NULL;
269 afc_client_t afc = NULL; 269 afc_client_t afc = NULL;
270 uint16_t port = 0; 270 lockdownd_service_descriptor_t service = NULL;
271 int res = -1; 271 int res = -1;
272 char *image_path = NULL; 272 char *image_path = NULL;
273 char *image_sig_path = NULL; 273 char *image_sig_path = NULL;
@@ -303,30 +303,38 @@ int main(int argc, char **argv)
303 goto leave; 303 goto leave;
304 } 304 }
305 305
306 lockdownd_start_service(lckd, "com.apple.mobile.mobile_image_mounter", &port); 306 lockdownd_start_service(lckd, "com.apple.mobile.mobile_image_mounter", &service);
307 307
308 if (port == 0) { 308 if (service->port == 0) {
309 printf("ERROR: Could not start mobile_image_mounter service!\n"); 309 printf("ERROR: Could not start mobile_image_mounter service!\n");
310 goto leave; 310 goto leave;
311 } 311 }
312 312
313 if (mobile_image_mounter_new(device, port, &mim) != MOBILE_IMAGE_MOUNTER_E_SUCCESS) { 313 if (mobile_image_mounter_new(device, service, &mim) != MOBILE_IMAGE_MOUNTER_E_SUCCESS) {
314 printf("ERROR: Could not connect to mobile_image_mounter!\n"); 314 printf("ERROR: Could not connect to mobile_image_mounter!\n");
315 goto leave; 315 goto leave;
316 } 316 }
317 317
318 if (service) {
319 lockdownd_service_descriptor_free(service);
320 service = NULL;
321 }
322
318 if (!list_mode) { 323 if (!list_mode) {
319 struct stat fst; 324 struct stat fst;
320 port = 0; 325 if ((lockdownd_start_service(lckd, "com.apple.afc", &service) !=
321 if ((lockdownd_start_service(lckd, "com.apple.afc", &port) != 326 LOCKDOWN_E_SUCCESS) || !service->port) {
322 LOCKDOWN_E_SUCCESS) || !port) {
323 fprintf(stderr, "Could not start com.apple.afc!\n"); 327 fprintf(stderr, "Could not start com.apple.afc!\n");
324 goto leave; 328 goto leave;
325 } 329 }
326 if (afc_client_new(device, port, &afc) != AFC_E_SUCCESS) { 330 if (afc_client_new(device, service, &afc) != AFC_E_SUCCESS) {
327 fprintf(stderr, "Could not connect to AFC!\n"); 331 fprintf(stderr, "Could not connect to AFC!\n");
328 goto leave; 332 goto leave;
329 } 333 }
334 if (service) {
335 lockdownd_service_descriptor_free(service);
336 service = NULL;
337 }
330 if (stat(image_path, &fst) != 0) { 338 if (stat(image_path, &fst) != 0) {
331 fprintf(stderr, "ERROR: stat: %s: %s\n", image_path, strerror(errno)); 339 fprintf(stderr, "ERROR: stat: %s: %s\n", image_path, strerror(errno));
332 goto leave; 340 goto leave;