summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dev/afccheck.c2
-rw-r--r--dev/iphoneclient.c2
-rw-r--r--dev/iphoneenterrecovery.c2
-rw-r--r--dev/lckdclient.c2
-rw-r--r--dev/msyncclient.c2
-rw-r--r--include/libiphone/lockdown.h3
-rw-r--r--src/lockdown.c46
-rw-r--r--src/lockdown.h1
-rw-r--r--swig/iphone.i2
-rw-r--r--tools/iphone_id.c2
-rw-r--r--tools/iphoneinfo.c2
-rw-r--r--tools/iphonesyslog.c2
12 files changed, 57 insertions, 11 deletions
diff --git a/dev/afccheck.c b/dev/afccheck.c
index 88935a0..00c0f52 100644
--- a/dev/afccheck.c
+++ b/dev/afccheck.c
@@ -109,7 +109,7 @@ int main(int argc, char *argv[])
return 1;
}
- if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) {
+ if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "afccheck")) {
iphone_device_free(phone);
return 1;
}
diff --git a/dev/iphoneclient.c b/dev/iphoneclient.c
index d62d23f..685f6ef 100644
--- a/dev/iphoneclient.c
+++ b/dev/iphoneclient.c
@@ -87,7 +87,7 @@ int main(int argc, char *argv[])
if (uuid)
free(uuid);
- if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) {
+ if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "iphoneclient")) {
iphone_device_free(phone);
printf("Exiting.\n");
return -1;
diff --git a/dev/iphoneenterrecovery.c b/dev/iphoneenterrecovery.c
index 1d4d332..126941c 100644
--- a/dev/iphoneenterrecovery.c
+++ b/dev/iphoneenterrecovery.c
@@ -74,7 +74,7 @@ int main(int argc, char *argv[])
return -1;
}
- if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) {
+ if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "iphoneenterrecovery")) {
iphone_device_free(phone);
return -1;
}
diff --git a/dev/lckdclient.c b/dev/lckdclient.c
index d866435..c8d717c 100644
--- a/dev/lckdclient.c
+++ b/dev/lckdclient.c
@@ -48,7 +48,7 @@ int main(int argc, char *argv[])
if (uuid)
free(uuid);
- if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) {
+ if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "lckdclient")) {
iphone_device_free(phone);
return -1;
}
diff --git a/dev/msyncclient.c b/dev/msyncclient.c
index 53018ac..dfe2a2b 100644
--- a/dev/msyncclient.c
+++ b/dev/msyncclient.c
@@ -153,7 +153,7 @@ int main(int argc, char *argv[])
return -1;
}
- if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) {
+ if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "msyncclient")) {
iphone_device_free(phone);
return -1;
}
diff --git a/include/libiphone/lockdown.h b/include/libiphone/lockdown.h
index 31ffeab..55dc3eb 100644
--- a/include/libiphone/lockdown.h
+++ b/include/libiphone/lockdown.h
@@ -53,8 +53,9 @@ struct lockdownd_client_int;
typedef struct lockdownd_client_int *lockdownd_client_t;
/* Interface */
-lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_t *client);
+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_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);
diff --git a/src/lockdown.c b/src/lockdown.c
index fb5f8f5..76d063c 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -108,6 +108,21 @@ static int lockdown_check_result(plist_t dict, const char *query_match)
}
/**
+ * Adds a label key with the passed value to a plist dict node.
+ *
+ * @param plist The plist to add the key to
+ * @param label The value for the label key
+ *
+ */
+static void plist_dict_add_label(plist_t plist, const char *label)
+{
+ if (plist && label) {
+ if (plist_get_node_type(plist) == PLIST_DICT)
+ plist_dict_insert_item(plist, "Label", plist_new_string(label));
+ }
+}
+
+/**
* Closes the lockdownd communication session, by sending
* the StopSession Request to the device.
*
@@ -128,6 +143,7 @@ lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client)
lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR;
plist_t dict = plist_new_dict();
+ plist_dict_add_label(dict, client->label);
plist_dict_insert_item(dict,"Request", plist_new_string("StopSession"));
plist_dict_insert_item(dict,"SessionID", plist_new_string(client->session_id));
@@ -223,11 +239,27 @@ lockdownd_error_t lockdownd_client_free(lockdownd_client_t client)
if (client->uuid) {
free(client->uuid);
}
+ if (client->label) {
+ free(client->label);
+ }
free(client);
return ret;
}
+/**
+ * Sets the label to send for requests to lockdownd.
+ *
+ * @param client The lockdown client
+ * @param label The label to set or NULL to disable
+ *
+ */
+void lockdownd_client_set_label(lockdownd_client_t client, const char *label)
+{
+ if (client)
+ client->label = strdup(label);
+}
+
/** Polls the iPhone for lockdownd data.
*
* @param control The lockdownd client
@@ -366,6 +398,7 @@ lockdownd_error_t lockdownd_query_type(lockdownd_client_t client)
lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR;
plist_t dict = plist_new_dict();
+ plist_dict_add_label(dict, client->label);
plist_dict_insert_item(dict,"Request", plist_new_string("QueryType"));
log_dbg_msg(DBGMASK_LOCKDOWND, "%s: called\n", __func__);
@@ -409,6 +442,7 @@ lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *dom
/* setup request plist */
dict = plist_new_dict();
+ plist_dict_add_label(dict, client->label);
if (domain) {
plist_dict_insert_item(dict,"Domain", plist_new_string(domain));
}
@@ -470,6 +504,7 @@ lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *dom
/* setup request plist */
dict = plist_new_dict();
+ plist_dict_add_label(dict, client->label);
if (domain) {
plist_dict_insert_item(dict,"Domain", plist_new_string(domain));
}
@@ -527,6 +562,7 @@ lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *
/* setup request plist */
dict = plist_new_dict();
+ plist_dict_add_label(dict, client->label);
if (domain) {
plist_dict_insert_item(dict,"Domain", plist_new_string(domain));
}
@@ -636,10 +672,11 @@ lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **de
*
* @param phone The iPhone to create a lockdownd client for
* @param client The pointer to the location of the new lockdownd_client
+ * @param label The label to use for communication. Usually the program name
*
* @return an error code (LOCKDOWN_E_SUCCESS on success)
*/
-lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_t *client)
+lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_t *client, const char *label)
{
if (!client)
return LOCKDOWN_E_INVALID_ARG;
@@ -659,6 +696,7 @@ lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_
client_loc->in_SSL = 0;
client_loc->session_id = NULL;
client_loc->uuid = NULL;
+ client_loc->label = strdup(label);
if (LOCKDOWN_E_SUCCESS != lockdownd_query_type(client_loc)) {
log_debug_msg("%s: QueryType failed in the lockdownd client.\n", __func__);
@@ -741,6 +779,7 @@ static lockdownd_error_t lockdownd_do_pair(lockdownd_client_t client, char *host
/* Setup Pair request plist */
dict = plist_new_dict();
dict_record = plist_new_dict();
+ plist_dict_add_label(dict, client->label);
plist_dict_insert_item(dict,"PairRecord", dict_record);
plist_dict_insert_item(dict_record, "DeviceCertificate", plist_new_data((const char*)device_cert.data, device_cert.size));
@@ -833,6 +872,7 @@ lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client)
lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR;
plist_t dict = plist_new_dict();
+ plist_dict_add_label(dict, client->label);
plist_dict_insert_item(dict,"Request", plist_new_string("EnterRecovery"));
log_dbg_msg(DBGMASK_LOCKDOWND, "%s: telling device to enter recovery mode\n", __func__);
@@ -868,6 +908,7 @@ lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client)
lockdownd_error_t ret = LOCKDOWN_E_UNKNOWN_ERROR;
plist_t dict = plist_new_dict();
+ plist_dict_add_label(dict, client->label);
plist_dict_insert_item(dict,"Request", plist_new_string("Goodbye"));
log_dbg_msg(DBGMASK_LOCKDOWND, "%s: called\n", __func__);
@@ -1050,6 +1091,7 @@ lockdownd_error_t lockdownd_start_ssl_session(lockdownd_client_t client, const c
/* Setup DevicePublicKey request plist */
dict = plist_new_dict();
+ plist_dict_add_label(dict, client->label);
plist_dict_insert_item(dict,"HostID", plist_new_string(HostID));
plist_dict_insert_item(dict,"Request", plist_new_string("StartSession"));
@@ -1080,6 +1122,7 @@ lockdownd_error_t lockdownd_start_ssl_session(lockdownd_client_t client, const c
/* start session again */
plist_free(dict);
dict = plist_new_dict();
+ plist_dict_add_label(dict, client->label);
plist_dict_insert_item(dict,"HostID", plist_new_string(HostID));
plist_dict_insert_item(dict,"Request", plist_new_string("StartSession"));
@@ -1277,6 +1320,7 @@ lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char
host_id = NULL;
dict = plist_new_dict();
+ plist_dict_add_label(dict, client->label);
plist_dict_insert_item(dict,"Request", plist_new_string("StartService"));
plist_dict_insert_item(dict,"Service", plist_new_string(service));
diff --git a/src/lockdown.h b/src/lockdown.h
index 931623a..6dac391 100644
--- a/src/lockdown.h
+++ b/src/lockdown.h
@@ -34,6 +34,7 @@ struct lockdownd_client_int {
int in_SSL;
char *session_id;
char *uuid;
+ char *label;
};
lockdownd_error_t lockdownd_get_device_public_key(lockdownd_client_t client, gnutls_datum_t * public_key);
diff --git a/swig/iphone.i b/swig/iphone.i
index a0ee509..6e1849e 100644
--- a/swig/iphone.i
+++ b/swig/iphone.i
@@ -71,7 +71,7 @@ Lockdownd* my_new_Lockdownd(iPhone* phone) {
Lockdownd* client = (Lockdownd*) malloc(sizeof(Lockdownd));
client->dev = phone;
client->client = NULL;
- if (LOCKDOWN_E_SUCCESS == lockdownd_client_new(phone->dev , &(client->client))) {
+ if (LOCKDOWN_E_SUCCESS == lockdownd_client_new(phone->dev , &(client->client), NULL)) {
return client;
}
else {
diff --git a/tools/iphone_id.c b/tools/iphone_id.c
index 80f22e1..a293469 100644
--- a/tools/iphone_id.c
+++ b/tools/iphone_id.c
@@ -70,7 +70,7 @@ int main(int argc, char **argv)
return -2;
}
- if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) {
+ if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "iphone_id")) {
iphone_device_free(phone);
fprintf(stderr, "ERROR: Connecting to device failed!\n");
return -2;
diff --git a/tools/iphoneinfo.c b/tools/iphoneinfo.c
index e0d7693..423c57e 100644
--- a/tools/iphoneinfo.c
+++ b/tools/iphoneinfo.c
@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
}
}
- if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) {
+ if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "iphoneinfo")) {
iphone_device_free(phone);
return -1;
}
diff --git a/tools/iphonesyslog.c b/tools/iphonesyslog.c
index 8fa3b04..5d4f564 100644
--- a/tools/iphonesyslog.c
+++ b/tools/iphonesyslog.c
@@ -99,7 +99,7 @@ int main(int argc, char *argv[])
}
}
- if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) {
+ if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "iphonesyslog")) {
iphone_device_free(phone);
return -1;
}