From 265578a2037a4f4a371a439686d2258f3e466a16 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Fri, 30 Jul 2021 19:40:09 +0200 Subject: tools: idevicebackup2: Exit on service startup failure and improve error messages --- tools/idevicebackup2.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'tools/idevicebackup2.c') diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index 068420d..0ab434e 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c @@ -638,7 +638,7 @@ static void do_post_notification(idevice_t device, const char *notification) return; } - lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service); + lockdownd_error_t ldret = lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service); if (service && service->port) { np_client_new(device, service, &np); if (np) { @@ -646,7 +646,7 @@ static void do_post_notification(idevice_t device, const char *notification) np_client_free(np); } } else { - printf("Could not start %s\n", NP_SERVICE_NAME); + printf("ERROR: Could not start service %s: %s\n", NP_SERVICE_NAME, lockdownd_strerror(ldret)); } if (service) { @@ -1822,17 +1822,25 @@ 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)); + cmd = CMD_LEAVE; + goto checkpoint; + } + if (service) { + lockdownd_service_descriptor_free(service); + service = NULL; } afc_client_t afc = NULL; if (cmd == CMD_BACKUP || cmd == CMD_RESTORE) { /* start AFC, we need this for the lock file */ - service->port = 0; - service->ssl_enabled = 0; ldret = lockdownd_start_service(lockdown, 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)); + cmd = CMD_LEAVE; + goto checkpoint; } } @@ -2568,7 +2576,7 @@ files_out: do_post_notification(device, NP_SYNC_DID_FINISH); } } else { - printf("ERROR: Could not start service %s.\n", MOBILEBACKUP2_SERVICE_NAME); + printf("ERROR: Could not start service %s: %s\n", MOBILEBACKUP2_SERVICE_NAME, lockdownd_strerror(ldret)); lockdownd_client_free(lockdown); lockdown = NULL; } -- cgit v1.1-32-gdbae