diff options
author | Martin Szulecki | 2010-01-08 21:38:40 +0100 |
---|---|---|
committer | Martin Szulecki | 2010-01-08 21:38:40 +0100 |
commit | cec7e6b7591d018dd700c6fa6b5c85b29ec43b34 (patch) | |
tree | 74eb3d798169152329c67d3f7174e463071bfadc | |
parent | 3d157a4762119e28433003e42f4af469e32ba860 (diff) | |
download | libimobiledevice-cec7e6b7591d018dd700c6fa6b5c85b29ec43b34.tar.gz libimobiledevice-cec7e6b7591d018dd700c6fa6b5c85b29ec43b34.tar.bz2 |
Detect pairing failure for device having a password set
[#101 state:resolved]
The first pairing fails if a user has a password set on the device.
-rw-r--r-- | include/libiphone/lockdown.h | 1 | ||||
-rw-r--r-- | src/lockdown.c | 18 |
2 files changed, 17 insertions, 2 deletions
diff --git a/include/libiphone/lockdown.h b/include/libiphone/lockdown.h index f076cf2..459fbbd 100644 --- a/include/libiphone/lockdown.h +++ b/include/libiphone/lockdown.h @@ -45,6 +45,7 @@ extern "C" { #define LOCKDOWN_E_REMOVE_VALUE_PROHIBITED -11 #define LOCKDOWN_E_MUX_ERROR -12 #define LOCKDOWN_E_ACTIVATION_FAILED -13 +#define LOCKDOWN_E_PASSWORD_PROTECTED -14 #define LOCKDOWN_E_UNKNOWN_ERROR -256 diff --git a/src/lockdown.c b/src/lockdown.c index 6ddd7c0..1b33830 100644 --- a/src/lockdown.c +++ b/src/lockdown.c @@ -810,8 +810,6 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, char *host if (lockdown_check_result(dict, verb) != RESULT_SUCCESS) { ret = LOCKDOWN_E_PAIRING_FAILED; } - plist_free(dict); - dict = NULL; /* if pairing succeeded */ if (ret == LOCKDOWN_E_SUCCESS) { @@ -825,7 +823,23 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, char *host } } else { log_dbg_msg(DBGMASK_LOCKDOWND, "%s: %s failure\n", __func__, verb); + plist_t error_node = NULL; + /* verify error condition */ + error_node = plist_dict_get_item(dict, "Error"); + if (error_node) { + char *value = NULL; + plist_get_string_val(error_node, &value); + /* the first pairing fails if the device is password protected */ + if (value && !strcmp(value, "PasswordProtected")) { + ret = LOCKDOWN_E_PASSWORD_PROTECTED; + free(value); + } + plist_free(error_node); + error_node = NULL; + } } + plist_free(dict); + dict = NULL; free(public_key.data); return ret; } |