diff options
author | Nikias Bassen | 2018-01-17 13:10:05 +0200 |
---|---|---|
committer | Nikias Bassen | 2018-01-17 13:10:05 +0200 |
commit | 3a37a4e4a334ea2de52db534f105fe8dbe928628 (patch) | |
tree | 52df872d1e563cc18c2ca856f3ee24b81be3471d | |
parent | 344729536e49d6a98aa05d76a3637856748911cd (diff) | |
download | libimobiledevice-3a37a4e4a334ea2de52db534f105fe8dbe928628.tar.gz libimobiledevice-3a37a4e4a334ea2de52db534f105fe8dbe928628.tar.bz2 |
idevicesyslog: Wait for passcode entry on device when required
After device bootup several services cannot be used until the passcode
is entered on the device. This commit will detect this state and wait for
the passcode to be entered. Before this change you would have to restart
idevicesyslog or replug the device after entering the passcode to make
the logging work again.
-rw-r--r-- | tools/idevicesyslog.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/tools/idevicesyslog.c b/tools/idevicesyslog.c index 47d2f8c..0a923b8 100644 --- a/tools/idevicesyslog.c +++ b/tools/idevicesyslog.c @@ -63,9 +63,40 @@ static int start_logging(void) return -1; } - /* start and connect to syslog_relay service */ + lockdownd_client_t lockdown = NULL; + lockdownd_error_t lerr = lockdownd_client_new_with_handshake(device, &lockdown, "idevicesyslog"); + if (lerr != LOCKDOWN_E_SUCCESS) { + fprintf(stderr, "ERROR: Could not connect to lockdownd: %d\n", lerr); + idevice_free(device); + device = NULL; + return -1; + } + + /* start syslog_relay service */ + lockdownd_service_descriptor_t svc = NULL; + lerr = lockdownd_start_service(lockdown, SYSLOG_RELAY_SERVICE_NAME, &svc); + if (lerr == LOCKDOWN_E_PASSWORD_PROTECTED) { + fprintf(stderr, "*** Device is passcode protected, enter passcode on the device to continue ***\n"); + while (1) { + lerr = lockdownd_start_service(lockdown, SYSLOG_RELAY_SERVICE_NAME, &svc); + if (lerr != LOCKDOWN_E_PASSWORD_PROTECTED) { + break; + } + sleep(1); + } + } + if (lerr != LOCKDOWN_E_SUCCESS) { + fprintf(stderr, "ERROR: Could not connect to lockdownd: %d\n", lerr); + idevice_free(device); + device = NULL; + return -1; + } + lockdownd_client_free(lockdown); + + /* connect to syslog_relay service */ syslog_relay_error_t serr = SYSLOG_RELAY_E_UNKNOWN_ERROR; - serr = syslog_relay_client_start_service(device, &syslog, "idevicesyslog"); + serr = syslog_relay_client_new(device, svc, &syslog); + lockdownd_service_descriptor_free(svc); if (serr != SYSLOG_RELAY_E_SUCCESS) { fprintf(stderr, "ERROR: Could not start service com.apple.syslog_relay.\n"); idevice_free(device); |