summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/idevicebackup.c54
-rw-r--r--tools/idevicebackup2.c54
-rw-r--r--tools/idevicedebugserverproxy.c15
-rw-r--r--tools/idevicediagnostics.c17
-rw-r--r--tools/ideviceimagemounter.c24
-rw-r--r--tools/ideviceprovision.c11
-rw-r--r--tools/idevicescreenshot.c14
-rw-r--r--tools/idevicesyslog.c13
8 files changed, 136 insertions, 66 deletions
diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c
index abd269a..95c5694 100644
--- a/tools/idevicebackup.c
+++ b/tools/idevicebackup.c
@@ -745,7 +745,7 @@ static int mobilebackup_check_file_integrity(const char *backup_directory, const
static void do_post_notification(const char *notification)
{
- uint16_t nport = 0;
+ lockdownd_service_descriptor_t service = NULL;
np_client_t np;
if (!client) {
@@ -754,9 +754,9 @@ static void do_post_notification(const char *notification)
}
}
- lockdownd_start_service(client, NP_SERVICE_NAME, &nport);
- if (nport) {
- np_client_new(device, nport, &np);
+ lockdownd_start_service(client, NP_SERVICE_NAME, &service);
+ if (service->port) {
+ np_client_new(device, service, &np);
if (np) {
np_post_notification(np, notification);
np_client_free(np);
@@ -764,6 +764,11 @@ static void do_post_notification(const char *notification)
} else {
printf("Could not start %s\n", NP_SERVICE_NAME);
}
+
+ if (service) {
+ lockdownd_service_descriptor_free(service);
+ service = NULL;
+ }
}
static void print_progress(double progress)
@@ -819,7 +824,7 @@ int main(int argc, char *argv[])
idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR;
int i;
char* udid = NULL;
- uint16_t port = 0;
+ lockdownd_service_descriptor_t service = NULL;
int cmd = -1;
int is_full_backup = 0;
char *backup_directory = NULL;
@@ -931,9 +936,9 @@ int main(int argc, char *argv[])
/* start notification_proxy */
np_client_t np = NULL;
- ret = lockdownd_start_service(client, NP_SERVICE_NAME, &port);
- if ((ret == LOCKDOWN_E_SUCCESS) && port) {
- np_client_new(device, port, &np);
+ ret = lockdownd_start_service(client, NP_SERVICE_NAME, &service);
+ if ((ret == LOCKDOWN_E_SUCCESS) && service->port) {
+ np_client_new(device, service, &np);
np_set_notify_callback(np, notify_cb, NULL);
const char *noties[5] = {
NP_SYNC_CANCEL_REQUEST,
@@ -947,22 +952,37 @@ int main(int argc, char *argv[])
printf("ERROR: Could not start service %s.\n", NP_SERVICE_NAME);
}
+ if (service) {
+ lockdownd_service_descriptor_free(service);
+ service = NULL;
+ }
+
afc_client_t afc = NULL;
if (cmd == CMD_BACKUP) {
/* start AFC, we need this for the lock file */
- port = 0;
- ret = lockdownd_start_service(client, "com.apple.afc", &port);
- if ((ret == LOCKDOWN_E_SUCCESS) && port) {
- afc_client_new(device, port, &afc);
+ service->port = 0;
+ service->ssl_enabled = 0;
+ ret = lockdownd_start_service(client, "com.apple.afc", &service);
+ if ((ret == LOCKDOWN_E_SUCCESS) && service->port) {
+ afc_client_new(device, service, &afc);
}
}
+ if (service) {
+ lockdownd_service_descriptor_free(service);
+ service = NULL;
+ }
+
/* start mobilebackup service and retrieve port */
- port = 0;
- ret = lockdownd_start_service(client, MOBILEBACKUP_SERVICE_NAME, &port);
- if ((ret == LOCKDOWN_E_SUCCESS) && port) {
- printf("Started \"%s\" service on port %d.\n", MOBILEBACKUP_SERVICE_NAME, port);
- mobilebackup_client_new(device, port, &mobilebackup);
+ ret = lockdownd_start_service(client, MOBILEBACKUP_SERVICE_NAME, &service);
+ if ((ret == LOCKDOWN_E_SUCCESS) && service->port) {
+ printf("Started \"%s\" service on port %d.\n", MOBILEBACKUP_SERVICE_NAME, service->port);
+ mobilebackup_client_new(device, service, &mobilebackup);
+
+ if (service) {
+ lockdownd_service_descriptor_free(service);
+ service = NULL;
+ }
/* check abort conditions */
if (quit_flag > 0) {
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c
index a0e732d..0353c9b 100644
--- a/tools/idevicebackup2.c
+++ b/tools/idevicebackup2.c
@@ -479,7 +479,7 @@ static int mb2_status_check_snapshot_state(const char *path, const char *udid, c
static void do_post_notification(idevice_t device, const char *notification)
{
- uint16_t nport = 0;
+ lockdownd_service_descriptor_t service = NULL;
np_client_t np;
lockdownd_client_t lockdown = NULL;
@@ -488,9 +488,9 @@ static void do_post_notification(idevice_t device, const char *notification)
return;
}
- lockdownd_start_service(lockdown, NP_SERVICE_NAME, &nport);
- if (nport) {
- np_client_new(device, nport, &np);
+ lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service);
+ if (service->port) {
+ np_client_new(device, service, &np);
if (np) {
np_post_notification(np, notification);
np_client_free(np);
@@ -498,6 +498,11 @@ static void do_post_notification(idevice_t device, const char *notification)
} else {
printf("Could not start %s\n", NP_SERVICE_NAME);
}
+
+ if (service) {
+ lockdownd_service_descriptor_free(service);
+ service = NULL;
+ }
}
static void print_progress_real(double progress, int flush)
@@ -1277,7 +1282,7 @@ int main(int argc, char *argv[])
int i;
char* udid = NULL;
char* source_udid = NULL;
- uint16_t port = 0;
+ lockdownd_service_descriptor_t service = NULL;
int cmd = -1;
int cmd_flags = 0;
int is_full_backup = 0;
@@ -1551,9 +1556,9 @@ int main(int argc, char *argv[])
/* start notification_proxy */
np_client_t np = NULL;
- ret = lockdownd_start_service(lockdown, NP_SERVICE_NAME, &port);
- if ((ret == LOCKDOWN_E_SUCCESS) && port) {
- np_client_new(device, port, &np);
+ ret = lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service);
+ if ((ret == LOCKDOWN_E_SUCCESS) && service->port) {
+ np_client_new(device, service, &np);
np_set_notify_callback(np, notify_cb, NULL);
const char *noties[5] = {
NP_SYNC_CANCEL_REQUEST,
@@ -1567,23 +1572,38 @@ int main(int argc, char *argv[])
printf("ERROR: Could not start service %s.\n", NP_SERVICE_NAME);
}
+ if (service) {
+ lockdownd_service_descriptor_free(service);
+ service = NULL;
+ }
+
afc_client_t afc = NULL;
if (cmd == CMD_BACKUP) {
/* start AFC, we need this for the lock file */
- port = 0;
- ret = lockdownd_start_service(lockdown, "com.apple.afc", &port);
- if ((ret == LOCKDOWN_E_SUCCESS) && port) {
- afc_client_new(device, port, &afc);
+ service->port = 0;
+ service->ssl_enabled = 0;
+ ret = lockdownd_start_service(lockdown, "com.apple.afc", &service);
+ if ((ret == LOCKDOWN_E_SUCCESS) && service->port) {
+ afc_client_new(device, service, &afc);
}
}
+ if (service) {
+ lockdownd_service_descriptor_free(service);
+ service = NULL;
+ }
+
/* start mobilebackup service and retrieve port */
mobilebackup2_client_t mobilebackup2 = NULL;
- port = 0;
- ret = lockdownd_start_service(lockdown, MOBILEBACKUP2_SERVICE_NAME, &port);
- if ((ret == LOCKDOWN_E_SUCCESS) && port) {
- PRINT_VERBOSE(1, "Started \"%s\" service on port %d.\n", MOBILEBACKUP2_SERVICE_NAME, port);
- mobilebackup2_client_new(device, port, &mobilebackup2);
+ ret = lockdownd_start_service(lockdown, MOBILEBACKUP2_SERVICE_NAME, &service);
+ if ((ret == LOCKDOWN_E_SUCCESS) && service->port) {
+ PRINT_VERBOSE(1, "Started \"%s\" service on port %d.\n", MOBILEBACKUP2_SERVICE_NAME, service->port);
+ mobilebackup2_client_new(device, service, &mobilebackup2);
+
+ if (service) {
+ lockdownd_service_descriptor_free(service);
+ service = NULL;
+ }
/* send Hello message */
double local_versions[2] = {2.0, 2.1};
diff --git a/tools/idevicedebugserverproxy.c b/tools/idevicedebugserverproxy.c
index 3253e6a..32438ad 100644
--- a/tools/idevicedebugserverproxy.c
+++ b/tools/idevicedebugserverproxy.c
@@ -228,7 +228,7 @@ int main(int argc, char *argv[])
idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR;
thread_t th;
const char* udid = NULL;
- uint16_t port = 0;
+ lockdownd_service_descriptor_t service = NULL;
uint16_t local_port = 0;
int result = EXIT_SUCCESS;
int i;
@@ -297,14 +297,14 @@ int main(int argc, char *argv[])
goto leave_cleanup;
}
- if ((lockdownd_start_service(lockdown, "com.apple.debugserver", &port) != LOCKDOWN_E_SUCCESS) || !port) {
+ if ((lockdownd_start_service(lockdown, "com.apple.debugserver", &service) != LOCKDOWN_E_SUCCESS) || !service->port) {
fprintf(stderr, "Could not start com.apple.debugserver!\nPlease make sure to mount the developer disk image first.\n");
result = EXIT_FAILURE;
goto leave_cleanup;
}
- if (idevice_connect(device, port, &connection) != IDEVICE_E_SUCCESS) {
- fprintf(stderr, "Connection to debugserver port %d failed!\n", (int)port);
+ if (idevice_connect(device, service->port, &connection) != IDEVICE_E_SUCCESS) {
+ fprintf(stderr, "Connection to debugserver port %d failed!\n", (int)service->port);
result = EXIT_FAILURE;
goto leave_cleanup;
}
@@ -320,7 +320,12 @@ int main(int argc, char *argv[])
socket_info.device_connection = connection;
socket_info.local_port = local_port;
- socket_info.remote_port = port;
+ socket_info.remote_port = service->port;
+
+ if (service) {
+ lockdownd_service_descriptor_free(service);
+ service = NULL;
+ }
/* create local socket */
socket_info.server_fd = socket_create(socket_info.local_port);
diff --git a/tools/idevicediagnostics.c b/tools/idevicediagnostics.c
index 10dab77..410d054 100644
--- a/tools/idevicediagnostics.c
+++ b/tools/idevicediagnostics.c
@@ -57,7 +57,7 @@ int main(int argc, char **argv)
lockdownd_client_t lockdown_client = NULL;
diagnostics_relay_client_t diagnostics_client = NULL;
lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR;
- uint16_t port = 0;
+ lockdownd_service_descriptor_t service = NULL;
int result = -1;
int i;
const char *udid = NULL;
@@ -173,23 +173,23 @@ int main(int argc, char **argv)
goto cleanup;
}
- if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(device, &lockdown_client, NULL)) {
+ if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(device, &lockdown_client, "idevicediagnostics")) {
idevice_free(device);
printf("Unable to connect to lockdownd.\n");
goto cleanup;
}
/* attempt to use newer diagnostics service available on iOS 5 and later */
- ret = lockdownd_start_service(lockdown_client, "com.apple.mobile.diagnostics_relay", &port);
+ ret = lockdownd_start_service(lockdown_client, "com.apple.mobile.diagnostics_relay", &service);
if (ret != LOCKDOWN_E_SUCCESS) {
/* attempt to use older diagnostics service */
- ret = lockdownd_start_service(lockdown_client, "com.apple.iosdiagnostics.relay", &port);
+ ret = lockdownd_start_service(lockdown_client, "com.apple.iosdiagnostics.relay", &service);
}
lockdownd_client_free(lockdown_client);
- if ((ret == LOCKDOWN_E_SUCCESS) && (port > 0)) {
- if (diagnostics_relay_client_new(device, port, &diagnostics_client) != DIAGNOSTICS_RELAY_E_SUCCESS) {
+ if ((ret == LOCKDOWN_E_SUCCESS) && (service->port > 0)) {
+ if (diagnostics_relay_client_new(device, service, &diagnostics_client) != DIAGNOSTICS_RELAY_E_SUCCESS) {
printf("Could not connect to diagnostics_relay!\n");
result = -1;
} else {
@@ -258,6 +258,11 @@ int main(int argc, char **argv)
printf("Could not start diagnostics service!\n");
}
+ if (service) {
+ lockdownd_service_descriptor_free(service);
+ service = NULL;
+ }
+
idevice_free(device);
cleanup:
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)
lockdownd_client_t lckd = NULL;
mobile_image_mounter_client_t mim = NULL;
afc_client_t afc = NULL;
- uint16_t port = 0;
+ lockdownd_service_descriptor_t service = NULL;
int res = -1;
char *image_path = NULL;
char *image_sig_path = NULL;
@@ -303,30 +303,38 @@ int main(int argc, char **argv)
goto leave;
}
- lockdownd_start_service(lckd, "com.apple.mobile.mobile_image_mounter", &port);
+ lockdownd_start_service(lckd, "com.apple.mobile.mobile_image_mounter", &service);
- if (port == 0) {
+ if (service->port == 0) {
printf("ERROR: Could not start mobile_image_mounter service!\n");
goto leave;
}
- if (mobile_image_mounter_new(device, port, &mim) != MOBILE_IMAGE_MOUNTER_E_SUCCESS) {
+ if (mobile_image_mounter_new(device, service, &mim) != MOBILE_IMAGE_MOUNTER_E_SUCCESS) {
printf("ERROR: Could not connect to mobile_image_mounter!\n");
goto leave;
}
+ if (service) {
+ lockdownd_service_descriptor_free(service);
+ service = NULL;
+ }
+
if (!list_mode) {
struct stat fst;
- port = 0;
- if ((lockdownd_start_service(lckd, "com.apple.afc", &port) !=
- LOCKDOWN_E_SUCCESS) || !port) {
+ if ((lockdownd_start_service(lckd, "com.apple.afc", &service) !=
+ LOCKDOWN_E_SUCCESS) || !service->port) {
fprintf(stderr, "Could not start com.apple.afc!\n");
goto leave;
}
- if (afc_client_new(device, port, &afc) != AFC_E_SUCCESS) {
+ if (afc_client_new(device, service, &afc) != AFC_E_SUCCESS) {
fprintf(stderr, "Could not connect to AFC!\n");
goto leave;
}
+ if (service) {
+ lockdownd_service_descriptor_free(service);
+ service = NULL;
+ }
if (stat(image_path, &fst) != 0) {
fprintf(stderr, "ERROR: stat: %s: %s\n", image_path, strerror(errno));
goto leave;
diff --git a/tools/ideviceprovision.c b/tools/ideviceprovision.c
index 1c6866d..13fd239 100644
--- a/tools/ideviceprovision.c
+++ b/tools/ideviceprovision.c
@@ -193,6 +193,7 @@ static plist_t profile_get_embedded_plist(plist_t profile)
int main(int argc, char *argv[])
{
lockdownd_client_t client = NULL;
+ lockdownd_service_descriptor_t service = NULL;
idevice_t device = NULL;
idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR;
int i;
@@ -278,8 +279,7 @@ int main(int argc, char *argv[])
return -1;
}
- uint16_t port = 0;
- if (LOCKDOWN_E_SUCCESS != lockdownd_start_service(client, "com.apple.misagent", &port)) {
+ if (LOCKDOWN_E_SUCCESS != lockdownd_start_service(client, "com.apple.misagent", &service)) {
fprintf(stderr, "Could not start service \"com.apple.misagent\"\n");
lockdownd_client_free(client);
idevice_free(device);
@@ -289,13 +289,18 @@ int main(int argc, char *argv[])
client = NULL;
misagent_client_t mis = NULL;
- if (misagent_client_new(device, port, &mis) != MISAGENT_E_SUCCESS) {
+ if (misagent_client_new(device, service, &mis) != MISAGENT_E_SUCCESS) {
fprintf(stderr, "Could not connect to \"com.apple.misagent\" on device\n");
+ if (service)
+ lockdownd_service_descriptor_free(service);
lockdownd_client_free(client);
idevice_free(device);
return -1;
}
+ if (service)
+ lockdownd_service_descriptor_free(service);
+
switch (op) {
case OP_INSTALL:
{
diff --git a/tools/idevicescreenshot.c b/tools/idevicescreenshot.c
index cba62a2..23e7b41 100644
--- a/tools/idevicescreenshot.c
+++ b/tools/idevicescreenshot.c
@@ -36,7 +36,7 @@ int main(int argc, char **argv)
idevice_t device = NULL;
lockdownd_client_t lckd = NULL;
screenshotr_client_t shotr = NULL;
- uint16_t port = 0;
+ lockdownd_service_descriptor_t service = NULL;
int result = -1;
int i;
const char *udid = NULL;
@@ -81,10 +81,10 @@ int main(int argc, char **argv)
return -1;
}
- lockdownd_start_service(lckd, "com.apple.mobile.screenshotr", &port);
+ lockdownd_start_service(lckd, "com.apple.mobile.screenshotr", &service);
lockdownd_client_free(lckd);
- if (port > 0) {
- if (screenshotr_client_new(device, port, &shotr) != SCREENSHOTR_E_SUCCESS) {
+ if (service->port > 0) {
+ if (screenshotr_client_new(device, service, &shotr) != SCREENSHOTR_E_SUCCESS) {
printf("Could not connect to screenshotr!\n");
} else {
char *imgdata = NULL;
@@ -113,8 +113,12 @@ int main(int argc, char **argv)
} else {
printf("Could not start screenshotr service! Remember that you have to mount the Developer disk image on your device if you want to use the screenshotr service.\n");
}
+
+ if (service)
+ lockdownd_service_descriptor_free(service);
+
idevice_free(device);
-
+
return result;
}
diff --git a/tools/idevicesyslog.c b/tools/idevicesyslog.c
index a17999c..6ce6d0e 100644
--- a/tools/idevicesyslog.c
+++ b/tools/idevicesyslog.c
@@ -49,7 +49,7 @@ int main(int argc, char *argv[])
idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR;
int i;
const char* udid = NULL;
- uint16_t port = 0;
+ lockdownd_service_descriptor_t service = NULL;
signal(SIGINT, clean_exit);
signal(SIGTERM, clean_exit);
@@ -99,13 +99,13 @@ int main(int argc, char *argv[])
}
/* start syslog_relay service and retrieve port */
- ret = lockdownd_start_service(client, "com.apple.syslog_relay", &port);
- if ((ret == LOCKDOWN_E_SUCCESS) && port) {
+ ret = lockdownd_start_service(client, "com.apple.syslog_relay", &service);
+ if ((ret == LOCKDOWN_E_SUCCESS) && service->port) {
lockdownd_client_free(client);
-
+
/* connect to socket relay messages */
idevice_connection_t conn = NULL;
- if ((idevice_connect(device, port, &conn) != IDEVICE_E_SUCCESS) || !conn) {
+ if ((idevice_connect(device, service->port, &conn) != IDEVICE_E_SUCCESS) || !conn) {
printf("ERROR: Could not open usbmux connection.\n");
} else {
while (!quit_flag) {
@@ -126,6 +126,9 @@ int main(int argc, char *argv[])
printf("ERROR: Could not start service com.apple.syslog_relay.\n");
}
+ if (service)
+ lockdownd_service_descriptor_free(service);
+
idevice_free(device);
return 0;