Skip to content

Commit

Permalink
ideviceactivation: Check ActivationState for success if lockdownd_act…
Browse files Browse the repository at this point in the history
…ivate() 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.
  • Loading branch information
nikias committed Jan 27, 2019
1 parent 3100d73 commit f2ebaf2
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions tools/ideviceactivation.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit f2ebaf2

Please sign in to comment.