summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2010-01-08 14:37:51 +0100
committerGravatar Martin Szulecki2010-01-08 14:37:51 +0100
commit7ff00ff9dc3039f811e6b2ac234958acc0a02d78 (patch)
tree37bde18512001aa0b36892485582399573587405
parente87f65f1b17186c6246fce26cdbd05d087ec28b9 (diff)
downloadlibimobiledevice-7ff00ff9dc3039f811e6b2ac234958acc0a02d78.tar.gz
libimobiledevice-7ff00ff9dc3039f811e6b2ac234958acc0a02d78.tar.bz2
Implement lockdown unpair request
-rw-r--r--include/libiphone/lockdown.h1
-rw-r--r--src/lockdown.c25
2 files changed, 24 insertions, 2 deletions
diff --git a/include/libiphone/lockdown.h b/include/libiphone/lockdown.h
index 55dc3eb..da684c6 100644
--- a/include/libiphone/lockdown.h
+++ b/include/libiphone/lockdown.h
@@ -66,6 +66,7 @@ lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist);
lockdownd_error_t lockdownd_recv(lockdownd_client_t client, plist_t *plist);
lockdownd_error_t lockdownd_pair(lockdownd_client_t client, char *host_id);
lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, char *host_id);
+lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, char *host_id);
lockdownd_error_t lockdownd_get_device_uuid(lockdownd_client_t control, char **uuid);
lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **device_name);
lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client);
diff --git a/src/lockdown.c b/src/lockdown.c
index 6616e72..c27cd59 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -813,10 +813,16 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, char *host
plist_free(dict);
dict = NULL;
- /* store public key in config if pairing succeeded */
+ /* if pairing succeeded */
if (ret == LOCKDOWN_E_SUCCESS) {
log_dbg_msg(DBGMASK_LOCKDOWND, "%s: %s success\n", __func__, verb);
- userpref_set_device_public_key(client->uuid, public_key);
+ if (!strcmp("Unpair", verb)) {
+ /* remove public key from config */
+ userpref_remove_device_public_key(client->uuid);
+ } else {
+ /* store public key in config */
+ userpref_set_device_public_key(client->uuid, public_key);
+ }
} else {
log_dbg_msg(DBGMASK_LOCKDOWND, "%s: %s failure\n", __func__, verb);
}
@@ -857,6 +863,21 @@ lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, char *host_
return lockdownd_do_pair(client, host_id, "ValidatePair");
}
+/**
+ * Unpairs the device with the given HostID and removes the pairing records
+ * from the device and host.
+ *
+ * @param client The lockdown client to pair with.
+ * @param host_id The HostID to use for unpairing. If NULL is passed, then
+ * the HostID of the current machine is used.
+ *
+ * @return an error code (LOCKDOWN_E_SUCCESS on success)
+ */
+lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, char *host_id)
+{
+ return lockdownd_do_pair(client, host_id, "Unpair");
+}
+
/**
* Tells the device to immediately enter recovery mode.
*