diff options
author | 2021-07-30 19:40:09 +0200 | |
---|---|---|
committer | 2021-07-30 19:40:09 +0200 | |
commit | 265578a2037a4f4a371a439686d2258f3e466a16 (patch) | |
tree | ca93b660b6a8aebc11dfa9d445de6de642f0a1ef | |
parent | 537766a9032b7c1f952ccf4343e587a202ca1526 (diff) | |
download | libimobiledevice-265578a2037a4f4a371a439686d2258f3e466a16.tar.gz libimobiledevice-265578a2037a4f4a371a439686d2258f3e466a16.tar.bz2 |
tools: idevicebackup2: Exit on service startup failure and improve error messages
-rw-r--r-- | tools/idevicebackup2.c | 20 |
1 files changed, 14 insertions, 6 deletions
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) | |||
638 | return; | 638 | return; |
639 | } | 639 | } |
640 | 640 | ||
641 | lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service); | 641 | lockdownd_error_t ldret = lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service); |
642 | if (service && service->port) { | 642 | if (service && service->port) { |
643 | np_client_new(device, service, &np); | 643 | np_client_new(device, service, &np); |
644 | if (np) { | 644 | if (np) { |
@@ -646,7 +646,7 @@ static void do_post_notification(idevice_t device, const char *notification) | |||
646 | np_client_free(np); | 646 | np_client_free(np); |
647 | } | 647 | } |
648 | } else { | 648 | } else { |
649 | printf("Could not start %s\n", NP_SERVICE_NAME); | 649 | printf("ERROR: Could not start service %s: %s\n", NP_SERVICE_NAME, lockdownd_strerror(ldret)); |
650 | } | 650 | } |
651 | 651 | ||
652 | if (service) { | 652 | if (service) { |
@@ -1822,17 +1822,25 @@ int main(int argc, char *argv[]) | |||
1822 | }; | 1822 | }; |
1823 | np_observe_notifications(np, noties); | 1823 | np_observe_notifications(np, noties); |
1824 | } else { | 1824 | } else { |
1825 | printf("ERROR: Could not start service %s.\n", NP_SERVICE_NAME); | 1825 | printf("ERROR: Could not start service %s: %s\n", NP_SERVICE_NAME, lockdownd_strerror(ldret)); |
1826 | cmd = CMD_LEAVE; | ||
1827 | goto checkpoint; | ||
1828 | } | ||
1829 | if (service) { | ||
1830 | lockdownd_service_descriptor_free(service); | ||
1831 | service = NULL; | ||
1826 | } | 1832 | } |
1827 | 1833 | ||
1828 | afc_client_t afc = NULL; | 1834 | afc_client_t afc = NULL; |
1829 | if (cmd == CMD_BACKUP || cmd == CMD_RESTORE) { | 1835 | if (cmd == CMD_BACKUP || cmd == CMD_RESTORE) { |
1830 | /* start AFC, we need this for the lock file */ | 1836 | /* start AFC, we need this for the lock file */ |
1831 | service->port = 0; | ||
1832 | service->ssl_enabled = 0; | ||
1833 | ldret = lockdownd_start_service(lockdown, AFC_SERVICE_NAME, &service); | 1837 | ldret = lockdownd_start_service(lockdown, AFC_SERVICE_NAME, &service); |
1834 | if ((ldret == LOCKDOWN_E_SUCCESS) && service->port) { | 1838 | if ((ldret == LOCKDOWN_E_SUCCESS) && service->port) { |
1835 | afc_client_new(device, service, &afc); | 1839 | afc_client_new(device, service, &afc); |
1840 | } else { | ||
1841 | printf("ERROR: Could not start service %s: %s\n", AFC_SERVICE_NAME, lockdownd_strerror(ldret)); | ||
1842 | cmd = CMD_LEAVE; | ||
1843 | goto checkpoint; | ||
1836 | } | 1844 | } |
1837 | } | 1845 | } |
1838 | 1846 | ||
@@ -2568,7 +2576,7 @@ files_out: | |||
2568 | do_post_notification(device, NP_SYNC_DID_FINISH); | 2576 | do_post_notification(device, NP_SYNC_DID_FINISH); |
2569 | } | 2577 | } |
2570 | } else { | 2578 | } else { |
2571 | printf("ERROR: Could not start service %s.\n", MOBILEBACKUP2_SERVICE_NAME); | 2579 | printf("ERROR: Could not start service %s: %s\n", MOBILEBACKUP2_SERVICE_NAME, lockdownd_strerror(ldret)); |
2572 | lockdownd_client_free(lockdown); | 2580 | lockdownd_client_free(lockdown); |
2573 | lockdown = NULL; | 2581 | lockdown = NULL; |
2574 | } | 2582 | } |