diff options
author | Nikias Bassen | 2021-02-09 02:45:06 +0100 |
---|---|---|
committer | Nikias Bassen | 2021-03-05 09:09:39 +0100 |
commit | 25059d4c7d75e03aab516af2929d7c6e6d4c17de (patch) | |
tree | e40097de160e2599b64206465bf31b566f6a9a5f /tools | |
parent | 4837527745d98b9314eec1a250e2e13ce1ec3031 (diff) | |
download | libimobiledevice-25059d4c7d75e03aab516af2929d7c6e6d4c17de.tar.gz libimobiledevice-25059d4c7d75e03aab516af2929d7c6e6d4c17de.tar.bz2 |
tools: Fix entering recovery mode on iOS 14.5+ which now requires a pairing
Diffstat (limited to 'tools')
-rw-r--r-- | tools/ideviceenterrecovery.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/tools/ideviceenterrecovery.c b/tools/ideviceenterrecovery.c index 822c10a..0cc9936 100644 --- a/tools/ideviceenterrecovery.c +++ b/tools/ideviceenterrecovery.c @@ -92,25 +92,37 @@ int main(int argc, char *argv[]) ret = idevice_new(&device, udid); if (ret != IDEVICE_E_SUCCESS) { printf("No device found with udid %s.\n", udid); - return -1; + return 1; } if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new(device, &client, TOOL_NAME))) { - printf("ERROR: Could not connect to lockdownd, error code %d\n", ldret); + printf("ERROR: Could not connect to lockdownd: %s (%d)\n", lockdownd_strerror(ldret), ldret); idevice_free(device); - return -1; + return 1; } - /* run query and output information */ + int res = 0; printf("Telling device with udid %s to enter recovery mode.\n", udid); - if(lockdownd_enter_recovery(client) != LOCKDOWN_E_SUCCESS) - { + ldret = lockdownd_enter_recovery(client); + if (ldret == LOCKDOWN_E_SESSION_INACTIVE) { + lockdownd_client_free(client); + client = NULL; + if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &client, TOOL_NAME))) { + printf("ERROR: Could not connect to lockdownd: %s (%d)\n", lockdownd_strerror(ldret), ldret); + idevice_free(device); + return 1; + } + ldret = lockdownd_enter_recovery(client); + } + if (ldret != LOCKDOWN_E_SUCCESS) { printf("Failed to enter recovery mode.\n"); + res = 1; + } else { + printf("Device is successfully switching to recovery mode.\n"); } - printf("Device is successfully switching to recovery mode.\n"); lockdownd_client_free(client); idevice_free(device); - return 0; + return res; } |