From 25059d4c7d75e03aab516af2929d7c6e6d4c17de Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 9 Feb 2021 02:45:06 +0100 Subject: tools: Fix entering recovery mode on iOS 14.5+ which now requires a pairing --- tools/ideviceenterrecovery.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'tools') 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; } -- cgit v1.1-32-gdbae