summaryrefslogtreecommitdiffstats
path: root/tools/ideviceactivation.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2019-01-27 05:06:51 +0100
committerGravatar Nikias Bassen2019-01-27 05:06:51 +0100
commitf2ebaf2b564ca4b9e875d1b6c724bea2087b9489 (patch)
treefc0624fe8c03184b0a50cbbeb1eb2d078c34c435 /tools/ideviceactivation.c
parent3100d735cf8887df1c1dc1946bc9d7ea20b27d34 (diff)
downloadlibideviceactivation-f2ebaf2b564ca4b9e875d1b6c724bea2087b9489.tar.gz
libideviceactivation-f2ebaf2b564ca4b9e875d1b6c724bea2087b9489.tar.bz2
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.
Diffstat (limited to 'tools/ideviceactivation.c')
-rw-r--r--tools/ideviceactivation.c19
1 files 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;
+ }
}
}