From f2ebaf2b564ca4b9e875d1b6c724bea2087b9489 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Sun, 27 Jan 2019 05:06:51 +0100 Subject: ideviceactivation: Check ActivationState for success if lockdownd_activate() returns no result On older devices it might happen that lockdownd does not return any result, neither success nor failure, when invoking lockdownd_activate(). This results in the code to assume the operation failed. Instead of relying on the return value of that function we query the actual ActivationState to see if it is not "Unactivated" anymore to determine if the activation was successful. --- tools/ideviceactivation.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tools/ideviceactivation.c b/tools/ideviceactivation.c index 93e6717..f7b3da6 100644 --- a/tools/ideviceactivation.c +++ b/tools/ideviceactivation.c @@ -447,9 +447,22 @@ int main(int argc, char *argv[]) } else { // activate device using lockdown if (LOCKDOWN_E_SUCCESS != lockdownd_activate(lockdown, record)) { - fprintf(stderr, "Failed to activate device with record.\n"); - result = EXIT_FAILURE; - goto cleanup; + plist_t state = NULL; + lockdownd_get_value(lockdown, NULL, "ActivationState", &state); + int success = 0; + if (state && plist_get_node_type(state) == PLIST_STRING) { + char *strval = NULL; + plist_get_string_val(state, &strval); + if (strval && strcmp(strval, "Unactivated")) { + success = 1; + } + free(strval); + } + if (!success) { + fprintf(stderr, "Failed to activate device with record.\n"); + result = EXIT_FAILURE; + goto cleanup; + } } } -- cgit v1.1-32-gdbae