summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2010-01-10 23:38:27 +0100
committerGravatar Martin Szulecki2010-01-10 23:38:27 +0100
commitf60d22f4ae41521d33ed85189733c7538ab65794 (patch)
tree19e822a91402fdd60008626b3d7aa5b177c8bb28
parentb85fe20245809fb5a62a95c1b1efcd6ca4df9282 (diff)
downloadlibimobiledevice-f60d22f4ae41521d33ed85189733c7538ab65794.tar.gz
libimobiledevice-f60d22f4ae41521d33ed85189733c7538ab65794.tar.bz2
Extend lockdown_query_type to actually return the type of the service daemon
-rw-r--r--include/libiphone/lockdown.h2
-rw-r--r--src/lockdown.c22
2 files changed, 19 insertions, 5 deletions
diff --git a/include/libiphone/lockdown.h b/include/libiphone/lockdown.h
index 459fbbd..4a82258 100644
--- a/include/libiphone/lockdown.h
+++ b/include/libiphone/lockdown.h
@@ -58,7 +58,7 @@ typedef struct lockdownd_client_int *lockdownd_client_t;
lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_t *client, const char *label);
lockdownd_error_t lockdownd_client_free(lockdownd_client_t client);
void lockdownd_client_set_label(lockdownd_client_t client, const char *label);
-lockdownd_error_t lockdownd_query_type(lockdownd_client_t client);
+lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type);
lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain, const char *key, plist_t *value);
lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *domain, const char *key, plist_t value);
lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *domain, const char *key);
diff --git a/src/lockdown.c b/src/lockdown.c
index 24dd4a1..1b33250 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -324,13 +324,15 @@ lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist)
return ret;
}
-/** Initiates the handshake for the lockdown session. Part of the lockdownd handshake.
+/** Query the type of the service daemon. Depending on whether the device is
+ * queried in normal mode or restore mode, different types will be returned.
*
* @param client The lockdownd client
+ * @param type The type returned by the service daemon. Can be NULL to ignore.
*
* @return an error code (LOCKDOWN_E_SUCCESS on success)
*/
-lockdownd_error_t lockdownd_query_type(lockdownd_client_t client)
+lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type)
{
if (!client)
return LOCKDOWN_E_INVALID_ARG;
@@ -354,7 +356,12 @@ lockdownd_error_t lockdownd_query_type(lockdownd_client_t client)
ret = LOCKDOWN_E_UNKNOWN_ERROR;
if (lockdown_check_result(dict, "QueryType") == RESULT_SUCCESS) {
- log_dbg_msg(DBGMASK_LOCKDOWND, "%s: success\n", __func__);
+ /* return the type if requested */
+ if (type != NULL) {
+ plist_t type_node = plist_dict_get_item(dict, "Type");
+ plist_get_string_val(type_node, type);
+ }
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: success with type %s\n", __func__, *type);
ret = LOCKDOWN_E_SUCCESS;
}
plist_free(dict);
@@ -622,6 +629,7 @@ lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_
return LOCKDOWN_E_INVALID_ARG;
lockdownd_error_t ret = LOCKDOWN_E_SUCCESS;
char *host_id = NULL;
+ char *type = NULL;
iphone_connection_t connection;
if (iphone_device_connect(device, 0xf27e, &connection) != IPHONE_E_SUCCESS) {
@@ -638,9 +646,15 @@ lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_
client_loc->uuid = NULL;
client_loc->label = strdup(label);
- if (LOCKDOWN_E_SUCCESS != lockdownd_query_type(client_loc)) {
+ if (LOCKDOWN_E_SUCCESS != lockdownd_query_type(client_loc, &type)) {
log_debug_msg("%s: QueryType failed in the lockdownd client.\n", __func__);
ret = LOCKDOWN_E_NOT_ENOUGH_DATA;
+ } else {
+ if (strcmp("com.apple.mobile.lockdown", type)) {
+ log_debug_msg("%s: Warning QueryType request returned \"%s\".\n", __func__, type);
+ }
+ if (type)
+ free(type);
}
ret = iphone_device_get_uuid(device, &client_loc->uuid);