diff options
-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); |