summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2022-02-04 02:15:56 +0100
committerGravatar Nikias Bassen2022-02-04 02:15:56 +0100
commita64fcc3988f75cb4fc2388013c245e5e884bb96f (patch)
tree1b122ace4e0c658fbb80a2980a86eabc1114e0d2
parentac89a1fed5ad916c81bca1515b10934e3e01b057 (diff)
downloadlibimobiledevice-a64fcc3988f75cb4fc2388013c245e5e884bb96f.tar.gz
libimobiledevice-a64fcc3988f75cb4fc2388013c245e5e884bb96f.tar.bz2
tools: Print meaningful error messages when service startup fails
-rw-r--r--src/service.c4
-rw-r--r--tools/idevicebackup.c14
-rw-r--r--tools/idevicebackup2.c2
-rw-r--r--tools/idevicecrashreport.c9
-rw-r--r--tools/idevicediagnostics.c9
-rw-r--r--tools/idevicenotificationproxy.c2
-rw-r--r--tools/ideviceprovision.c7
-rw-r--r--tools/idevicescreenshot.c6
-rw-r--r--tools/idevicesetlocation.c5
9 files changed, 36 insertions, 22 deletions
diff --git a/src/service.c b/src/service.c
index 88132d2..db529bb 100644
--- a/src/service.c
+++ b/src/service.c
@@ -91,11 +91,11 @@ LIBIMOBILEDEVICE_API service_error_t service_client_factory_start_service(idevic
}
lockdownd_service_descriptor_t service = NULL;
- lockdownd_start_service(lckd, service_name, &service);
+ lockdownd_error_t lerr = lockdownd_start_service(lckd, service_name, &service);
lockdownd_client_free(lckd);
if (!service || service->port == 0) {
- debug_info("Could not start service %s!", service_name);
+ debug_info("Could not start service %s: %s", service_name, lockdownd_strerror(lerr));
return SERVICE_E_START_SERVICE_ERROR;
}
diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c
index 42f020d..1759f50 100644
--- a/tools/idevicebackup.c
+++ b/tools/idevicebackup.c
@@ -598,15 +598,15 @@ static void do_post_notification(const char *notification)
}
}
- lockdownd_start_service(client, NP_SERVICE_NAME, &service);
- if (service && service->port) {
+ lockdownd_error_t ldret = lockdownd_start_service(client, NP_SERVICE_NAME, &service);
+ if (ldret == LOCKDOWN_E_SUCCESS) {
np_client_new(device, service, &np);
if (np) {
np_post_notification(np, notification);
np_client_free(np);
}
} else {
- printf("Could not start %s\n", NP_SERVICE_NAME);
+ printf("Could not start %s: %s\n", NP_SERVICE_NAME, lockdownd_strerror(ldret));
}
if (service) {
@@ -826,7 +826,7 @@ int main(int argc, char *argv[])
};
np_observe_notifications(np, noties);
} else {
- printf("ERROR: Could not start service %s.\n", NP_SERVICE_NAME);
+ printf("ERROR: Could not start service %s: %s\n", NP_SERVICE_NAME, lockdownd_strerror(ldret));
}
afc_client_t afc = NULL;
@@ -834,9 +834,11 @@ int main(int argc, char *argv[])
/* start AFC, we need this for the lock file */
service->port = 0;
service->ssl_enabled = 0;
- ldret = lockdownd_start_service(client, "com.apple.afc", &service);
+ ldret = lockdownd_start_service(client, AFC_SERVICE_NAME, &service);
if ((ldret == LOCKDOWN_E_SUCCESS) && service->port) {
afc_client_new(device, service, &afc);
+ } else {
+ printf("ERROR: Could not start service %s: %s\n", AFC_SERVICE_NAME, lockdownd_strerror(ldret));
}
}
@@ -1588,7 +1590,7 @@ files_out:
if (manifest_path)
free(manifest_path);
} else {
- printf("ERROR: Could not start service %s.\n", MOBILEBACKUP_SERVICE_NAME);
+ printf("ERROR: Could not start service %s: %s\n", MOBILEBACKUP_SERVICE_NAME, lockdownd_strerror(ldret));
lockdownd_client_free(client);
client = NULL;
}
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c
index eff05ee..b024721 100644
--- a/tools/idevicebackup2.c
+++ b/tools/idevicebackup2.c
@@ -639,7 +639,7 @@ static void do_post_notification(idevice_t device, const char *notification)
}
lockdownd_error_t ldret = lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service);
- if (service && service->port) {
+ if (ldret == LOCKDOWN_E_SUCCESS) {
np_client_new(device, service, &np);
if (np) {
np_post_notification(np, notification);
diff --git a/tools/idevicecrashreport.c b/tools/idevicecrashreport.c
index 4d3b686..7df8dd9 100644
--- a/tools/idevicecrashreport.c
+++ b/tools/idevicecrashreport.c
@@ -47,6 +47,9 @@
#define S_IFSOCK S_IFREG
#endif
+#define CRASH_REPORT_MOVER_SERVICE "com.apple.crashreportmover"
+#define CRASH_REPORT_COPY_MOBILE_SERVICE "com.apple.crashreportcopymobile"
+
const char* target_directory = NULL;
static int extract_raw_crash_reports = 0;
static int keep_crash_reports = 0;
@@ -422,8 +425,9 @@ int main(int argc, char* argv[])
/* start crash log mover service */
lockdownd_service_descriptor_t service = NULL;
- lockdownd_error = lockdownd_start_service(lockdownd, "com.apple.crashreportmover", &service);
+ lockdownd_error = lockdownd_start_service(lockdownd, CRASH_REPORT_MOVER_SERVICE, &service);
if (lockdownd_error != LOCKDOWN_E_SUCCESS) {
+ fprintf(stderr, "ERROR: Could not start service %s: %s\n", CRASH_REPORT_MOVER_SERVICE, lockdownd_strerror(lockdownd_error));
lockdownd_client_free(lockdownd);
idevice_free(device);
return -1;
@@ -465,8 +469,9 @@ int main(int argc, char* argv[])
return -1;
}
- lockdownd_error = lockdownd_start_service(lockdownd, "com.apple.crashreportcopymobile", &service);
+ lockdownd_error = lockdownd_start_service(lockdownd, CRASH_REPORT_COPY_MOBILE_SERVICE, &service);
if (lockdownd_error != LOCKDOWN_E_SUCCESS) {
+ fprintf(stderr, "ERROR: Could not start service %s: %s\n", CRASH_REPORT_COPY_MOBILE_SERVICE, lockdownd_strerror(lockdownd_error));
lockdownd_client_free(lockdownd);
idevice_free(device);
return -1;
diff --git a/tools/idevicediagnostics.c b/tools/idevicediagnostics.c
index 0e3e66e..66ed589 100644
--- a/tools/idevicediagnostics.c
+++ b/tools/idevicediagnostics.c
@@ -213,13 +213,18 @@ int main(int argc, char **argv)
/* attempt to use newer diagnostics service available on iOS 5 and later */
ret = lockdownd_start_service(lockdown_client, "com.apple.mobile.diagnostics_relay", &service);
- if (ret != LOCKDOWN_E_SUCCESS) {
+ if (ret == LOCKDOWN_E_INVALID_SERVICE) {
/* attempt to use older diagnostics service */
ret = lockdownd_start_service(lockdown_client, "com.apple.iosdiagnostics.relay", &service);
}
-
lockdownd_client_free(lockdown_client);
+ if (ret != LOCKDOWN_E_SUCCESS) {
+ idevice_free(device);
+ printf("ERROR: Could not start diagnostics relay service: %s\n", lockdownd_strerror(ret));
+ goto cleanup;
+ }
+
result = EXIT_FAILURE;
if ((ret == LOCKDOWN_E_SUCCESS) && service && (service->port > 0)) {
diff --git a/tools/idevicenotificationproxy.c b/tools/idevicenotificationproxy.c
index cfc9260..00bcba8 100644
--- a/tools/idevicenotificationproxy.c
+++ b/tools/idevicenotificationproxy.c
@@ -250,7 +250,7 @@ int main(int argc, char *argv[])
}
}
} else {
- printf("Could not start notification_proxy service on device.\n");
+ printf("ERROR: Could not start service %s: %s\n", NP_SERVICE_NAME, lockdownd_strerror(ret));
}
if (service) {
diff --git a/tools/ideviceprovision.c b/tools/ideviceprovision.c
index 36c69b0..1dee899 100644
--- a/tools/ideviceprovision.c
+++ b/tools/ideviceprovision.c
@@ -481,8 +481,9 @@ int main(int argc, char *argv[])
}
int product_version = ((product_version_major & 0xFF) << 16) | ((product_version_minor & 0xFF) << 8) | (product_version_patch & 0xFF);
- if (LOCKDOWN_E_SUCCESS != lockdownd_start_service(client, "com.apple.misagent", &service)) {
- fprintf(stderr, "Could not start service \"com.apple.misagent\"\n");
+ lockdownd_error_t lerr = lockdownd_start_service(client, MISAGENT_SERVICE_NAME, &service);
+ if (lerr != LOCKDOWN_E_SUCCESS) {
+ fprintf(stderr, "Could not start service %s: %s\n", MISAGENT_SERVICE_NAME, lockdownd_strerror(lerr));
lockdownd_client_free(client);
idevice_free(device);
return -1;
@@ -492,7 +493,7 @@ int main(int argc, char *argv[])
misagent_client_t mis = NULL;
if (misagent_client_new(device, service, &mis) != MISAGENT_E_SUCCESS) {
- fprintf(stderr, "Could not connect to \"com.apple.misagent\" on device\n");
+ fprintf(stderr, "Could not connect to %s on device\n", MISAGENT_SERVICE_NAME);
if (service)
lockdownd_service_descriptor_free(service);
lockdownd_client_free(client);
diff --git a/tools/idevicescreenshot.c b/tools/idevicescreenshot.c
index 62bb4a3..9b1ffa3 100644
--- a/tools/idevicescreenshot.c
+++ b/tools/idevicescreenshot.c
@@ -110,9 +110,9 @@ int main(int argc, char **argv)
return -1;
}
- lockdownd_start_service(lckd, "com.apple.mobile.screenshotr", &service);
+ lockdownd_error_t lerr = lockdownd_start_service(lckd, SCREENSHOTR_SERVICE_NAME, &service);
lockdownd_client_free(lckd);
- if (service && service->port > 0) {
+ if (lerr == LOCKDOWN_E_SUCCESS) {
if (screenshotr_client_new(device, service, &shotr) != SCREENSHOTR_E_SUCCESS) {
printf("Could not connect to screenshotr!\n");
} else {
@@ -142,7 +142,7 @@ int main(int argc, char **argv)
screenshotr_client_free(shotr);
}
} 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");
+ printf("Could not start screenshotr service: %s\nRemember that you have to mount the Developer disk image on your device if you want to use the screenshotr service.\n", lockdownd_strerror(lerr));
}
if (service)
diff --git a/tools/idevicesetlocation.c b/tools/idevicesetlocation.c
index 412b47c..6237a1a 100644
--- a/tools/idevicesetlocation.c
+++ b/tools/idevicesetlocation.c
@@ -141,10 +141,11 @@ int main(int argc, char **argv)
lockdownd_client_new_with_handshake(device, &lockdown, TOOL_NAME);
lockdownd_service_descriptor_t svc = NULL;
- if (lockdownd_start_service(lockdown, DT_SIMULATELOCATION_SERVICE, &svc) != LOCKDOWN_E_SUCCESS) {
+ lockdownd_error_t lerr = lockdownd_start_service(lockdown, DT_SIMULATELOCATION_SERVICE, &svc);
+ if (lerr != LOCKDOWN_E_SUCCESS) {
lockdownd_client_free(lockdown);
idevice_free(device);
- printf("ERROR: Could not start the simulatelocation service. Make sure a developer disk image is mounted!\n");
+ printf("ERROR: Could not start the simulatelocation service: %s\nMake sure a developer disk image is mounted!\n", lockdownd_strerror(lerr));
return -1;
}
lockdownd_client_free(lockdown);