diff options
author | Nikias Bassen | 2013-09-24 03:46:22 +0200 |
---|---|---|
committer | Nikias Bassen | 2013-09-24 03:46:22 +0200 |
commit | 4356659dfad264fb89bfcf0e4410797db4e908a8 (patch) | |
tree | 403f48351bc28c2b82d67c73112a7df0015162a4 | |
parent | 6b42686e8addecf76beaa171427a81fd65c6a895 (diff) | |
download | usbmuxd-4356659dfad264fb89bfcf0e4410797db4e908a8.tar.gz usbmuxd-4356659dfad264fb89bfcf0e4410797db4e908a8.tar.bz2 |
preflight: handle invalid pair records properly
-rw-r--r-- | src/preflight.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/preflight.c b/src/preflight.c index 30a2217..97fdb8b 100644 --- a/src/preflight.c +++ b/src/preflight.c @@ -115,9 +115,10 @@ static void* preflight_worker_handle_device_add(void* userdata) idevice_t dev = (idevice_t)_dev; - lockdownd_client_t lockdown; + lockdownd_client_t lockdown = NULL; lockdownd_error_t lerr; +retry: lerr = lockdownd_client_new(dev, &lockdown, "usbmuxd"); if (lerr != LOCKDOWN_E_SUCCESS) { usbmuxd_log(LL_ERROR, "%s: ERROR: Could not connect to lockdownd on device %s, lockdown error %d", __func__, _dev->udid, lerr); @@ -149,10 +150,23 @@ static void* preflight_worker_handle_device_add(void* userdata) } usbmuxd_log(LL_INFO, "%s: StartSession failed on device %s, lockdown error %d", __func__, _dev->udid, lerr); - if (lerr == LOCKDOWN_E_INVALID_HOST_ID) { + switch (lerr) { + case LOCKDOWN_E_INVALID_HOST_ID: usbmuxd_log(LL_INFO, "%s: Device %s is not paired with this host.", __func__, _dev->udid); - } else { + break; + case LOCKDOWN_E_SSL_ERROR: + usbmuxd_log(LL_ERROR, "%s: The stored pair record for device %s is invalid. Removing.", __func__, _dev->udid); + if (userpref_remove_device_record(_dev->udid) == 0) { + lockdownd_client_free(lockdown); + lockdown = NULL; + goto retry; + } else { + usbmuxd_log(LL_ERROR, "%s: Could not remove pair record for device %s\n", __func__, _dev->udid); + } + break; + default: is_device_paired = 1; + break; } plist_t value = NULL; |