summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AFC.c67
-rw-r--r--src/MobileSync.c4
-rw-r--r--src/NotificationProxy.c1
-rw-r--r--src/lockdown.c95
-rw-r--r--src/userpref.c5
-rw-r--r--src/utils.c3
6 files changed, 79 insertions, 96 deletions
diff --git a/src/AFC.c b/src/AFC.c
index cd120fc..8cc88f1 100644
--- a/src/AFC.c
+++ b/src/AFC.c
@@ -39,11 +39,7 @@ const int MAXIMUM_PACKET_SIZE = (2 << 15);
*/
static void afc_lock(afc_client_t client)
{
- log_debug_msg("Locked\n");
- /*while (client->lock) {
- usleep(500); // they say it's obsolete, but whatever
- }
- client->lock = 1; */
+ log_debug_msg("%s: Locked\n", __func__);
g_mutex_lock(client->mutex);
}
@@ -52,9 +48,8 @@ static void afc_lock(afc_client_t client)
* @param client The AFC
*/
static void afc_unlock(afc_client_t client)
-{ // just to be pretty
- log_debug_msg("Unlocked\n");
- //client->lock = 0;
+{
+ log_debug_msg("%s: Unlocked\n", __func__);
g_mutex_unlock(client->mutex);
}
@@ -245,12 +240,12 @@ static int dispatch_AFC_packet(afc_client_t client, const char *data, uint64_t l
memcpy(buffer, (char *) client->afc_packet, sizeof(AFCPacket));
offset = client->afc_packet->this_length - sizeof(AFCPacket);
- log_debug_msg("dispatch_AFC_packet: Offset: %i\n", offset);
+ log_debug_msg("%s: Offset: %i\n", __func__, offset);
if ((length) < (client->afc_packet->entire_length - client->afc_packet->this_length)) {
- log_debug_msg("dispatch_AFC_packet: Length did not resemble what it was supposed");
+ log_debug_msg("%s: Length did not resemble what it was supposed", __func__);
log_debug_msg("to based on the packet.\n");
- log_debug_msg("length minus offset: %i\n", length - offset);
- log_debug_msg("rest of packet: %i\n", client->afc_packet->entire_length - client->afc_packet->this_length);
+ log_debug_msg("%s: length minus offset: %i\n", __func__, length - offset);
+ log_debug_msg("%s: rest of packet: %i\n", __func__, client->afc_packet->entire_length - client->afc_packet->this_length);
free(buffer);
return -1;
}
@@ -261,19 +256,19 @@ static int dispatch_AFC_packet(afc_client_t client, const char *data, uint64_t l
return bytes;
}
- log_debug_msg("dispatch_AFC_packet: sent the first now go with the second\n");
- log_debug_msg("Length: %i\n", length - offset);
- log_debug_msg("Buffer: \n");
+ log_debug_msg("%s: sent the first now go with the second\n", __func__);
+ log_debug_msg("%s: Length: %i\n", __func__, length - offset);
+ log_debug_msg("%s: Buffer: \n", __func__);
log_debug_buffer(data + offset, length - offset);
usbmuxd_send(client->sfd, data + offset, length - offset, (uint32_t*)&bytes);
return bytes;
} else {
- log_debug_msg("dispatch_AFC_packet doin things the old way\n");
+ log_debug_msg("%s: doin things the old way\n", __func__);
buffer = (char *) malloc(sizeof(char) * client->afc_packet->this_length);
- log_debug_msg("dispatch_AFC_packet packet length = %i\n", client->afc_packet->this_length);
+ log_debug_msg("%s: packet length = %i\n", __func__, client->afc_packet->this_length);
memcpy(buffer, (char *) client->afc_packet, sizeof(AFCPacket));
- log_debug_msg("dispatch_AFC_packet packet data follows\n");
+ log_debug_msg("%s: packet data follows\n", __func__);
if (length > 0) {
memcpy(buffer + sizeof(AFCPacket), data, length);
}
@@ -354,7 +349,7 @@ static int receive_AFC_data(afc_client_t client, char **dump_here)
}
}
- log_debug_msg("%s: received AFC packet, full len=%lld, this len=%lld, operation=%lld\n", __func__, header.entire_length, header.this_length, header.operation);
+ log_debug_msg("%s: received AFC packet, full len=%lld, this len=%lld, operation=0x%llx\n", __func__, header.entire_length, header.this_length, header.operation);
entire_len = (uint32_t)header.entire_length - sizeof(AFCPacket);
this_len = (uint32_t)header.this_length - sizeof(AFCPacket);
@@ -758,7 +753,7 @@ afc_open_file(afc_client_t client, const char *filename,
free(data);
if (bytes <= 0) {
- log_debug_msg("afc_open_file: Didn't receive a response to the command\n");
+ log_debug_msg("%s: Didn't receive a response to the command\n", __func__);
afc_unlock(client);
return IPHONE_E_NOT_ENOUGH_DATA;
}
@@ -800,14 +795,14 @@ afc_read_file(afc_client_t client, uint64_t handle, char *data, int length, uint
if (!client || !client->afc_packet || client->sfd < 0 || handle == 0)
return IPHONE_E_INVALID_ARG;
- log_debug_msg("afc_read_file called for length %i\n", length);
+ log_debug_msg("%s: called for length %i\n", __func__, length);
afc_lock(client);
// Looping here to get around the maximum amount of data that
// recieve_AFC_data can handle
while (current_count < length) {
- log_debug_msg("afc_read_file: current count is %i but length is %i\n", current_count, length);
+ log_debug_msg("%s: current count is %i but length is %i\n", __func__, current_count, length);
// Send the read command
AFCFilePacket *packet = (AFCFilePacket *) malloc(sizeof(AFCFilePacket));
@@ -824,7 +819,7 @@ afc_read_file(afc_client_t client, uint64_t handle, char *data, int length, uint
}
// Receive the data
bytes_loc = receive_AFC_data(client, &input);
- log_debug_msg("afc_read_file: bytes returned: %i\n", bytes_loc);
+ log_debug_msg("%s: bytes returned: %i\n", __func__, bytes_loc);
if (bytes_loc < 0) {
afc_unlock(client);
return IPHONE_E_AFC_ERROR;
@@ -837,7 +832,7 @@ afc_read_file(afc_client_t client, uint64_t handle, char *data, int length, uint
// success
} else {
if (input) {
- log_debug_msg("afc_read_file: %d\n", bytes_loc);
+ log_debug_msg("%s: %d\n", __func__, bytes_loc);
memcpy(data + current_count, input, (bytes_loc > length) ? length : bytes_loc);
free(input);
input = NULL;
@@ -845,7 +840,7 @@ afc_read_file(afc_client_t client, uint64_t handle, char *data, int length, uint
}
}
}
- log_debug_msg("afc_read_file: returning current_count as %i\n", current_count);
+ log_debug_msg("%s: returning current_count as %i\n", __func__, current_count);
afc_unlock(client);
*bytes = current_count;
@@ -878,7 +873,7 @@ afc_write_file(afc_client_t client, uint64_t handle,
afc_lock(client);
- log_debug_msg("afc_write_file: Write length: %i\n", length);
+ log_debug_msg("%s: Write length: %i\n", __func__, length);
// Divide the file into segments.
for (i = 0; i < segments; i++) {
@@ -939,7 +934,7 @@ afc_write_file(afc_client_t client, uint64_t handle,
bytes_loc = receive_AFC_data(client, &acknowledgement);
afc_unlock(client);
if (bytes_loc < 0) {
- log_debug_msg("afc_write_file: uh oh?\n");
+ log_debug_msg("%s: uh oh?\n", __func__);
} else {
free(acknowledgement);
}
@@ -961,7 +956,7 @@ iphone_error_t afc_close_file(afc_client_t client, uint64_t handle)
afc_lock(client);
- log_debug_msg("afc_close_file: File handle %i\n", handle);
+ log_debug_msg("%s: File handle %i\n", __func__, handle);
// Send command
memcpy(buffer, &handle, sizeof(uint64_t));
@@ -971,18 +966,16 @@ iphone_error_t afc_close_file(afc_client_t client, uint64_t handle)
free(buffer);
buffer = NULL;
- // FIXME: Is this necesary?
- // client->afc_packet->entire_length = client->afc_packet->this_length
- // = 0;
-
if (bytes <= 0) {
afc_unlock(client);
return IPHONE_E_UNKNOWN_ERROR;
}
+
// Receive the response
bytes = receive_AFC_data(client, &buffer);
if (buffer)
free(buffer);
+
afc_unlock(client);
return IPHONE_E_SUCCESS;
}
@@ -1008,7 +1001,7 @@ iphone_error_t afc_lock_file(afc_client_t client, uint64_t handle, afc_lock_op_t
afc_lock(client);
- log_debug_msg("afc_lock_file: File handle %i\n", handle);
+ log_debug_msg("%s: file handle %i\n", __func__, handle);
// Send command
memcpy(buffer, &handle, sizeof(uint64_t));
@@ -1022,7 +1015,7 @@ iphone_error_t afc_lock_file(afc_client_t client, uint64_t handle, afc_lock_op_t
if (bytes <= 0) {
afc_unlock(client);
- log_debug_msg("Could not send lock command\n");
+ log_debug_msg("%s: could not send lock command\n", __func__);
return IPHONE_E_UNKNOWN_ERROR;
}
// Receive the response
@@ -1194,9 +1187,9 @@ iphone_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, cons
afc_lock(client);
- log_debug_msg("link type: %lld\n", type);
- log_debug_msg("target: %s, length:%d\n", target, strlen(target));
- log_debug_msg("linkname: %s, length:%d\n", linkname, strlen(linkname));
+ log_debug_msg("%s: link type: %lld\n", __func__, type);
+ log_debug_msg("%s: target: %s, length:%d\n", __func__, target, strlen(target));
+ log_debug_msg("%s: linkname: %s, length:%d\n", __func__, linkname, strlen(linkname));
// Send command
memcpy(send, &type, 8);
diff --git a/src/MobileSync.c b/src/MobileSync.c
index b9a1cb0..f544400 100644
--- a/src/MobileSync.c
+++ b/src/MobileSync.c
@@ -161,7 +161,7 @@ iphone_error_t mobilesync_recv(mobilesync_client_t client, plist_t * plist)
char *XMLContent = NULL;
uint32_t length = 0;
plist_to_xml(*plist, &XMLContent, &length);
- log_dbg_msg(DBGMASK_MOBILESYNC, "Recv msg :\nsize : %i\nbuffer :\n%s\n", length, XMLContent);
+ log_dbg_msg(DBGMASK_MOBILESYNC, "%s: plist size: %i\nbuffer :\n%s\n", __func__, length, XMLContent);
free(XMLContent);
return ret;
@@ -185,7 +185,7 @@ iphone_error_t mobilesync_send(mobilesync_client_t client, plist_t plist)
char *XMLContent = NULL;
uint32_t length = 0;
plist_to_xml(plist, &XMLContent, &length);
- log_dbg_msg(DBGMASK_MOBILESYNC, "Send msg :\nsize : %i\nbuffer :\n%s\n", length, XMLContent);
+ log_dbg_msg(DBGMASK_MOBILESYNC, "%s: plist size: %i\nbuffer :\n%s\n", __func__, length, XMLContent);
free(XMLContent);
char *content = NULL;
diff --git a/src/NotificationProxy.c b/src/NotificationProxy.c
index 374420c..1bbdc6d 100644
--- a/src/NotificationProxy.c
+++ b/src/NotificationProxy.c
@@ -226,7 +226,6 @@ iphone_error_t np_observe_notification( np_client_t client, const char *notifica
return res;
}
-
/** Notifies the iphone to send a notification on specified events.
*
* observation messages seen so far:
diff --git a/src/lockdown.c b/src/lockdown.c
index 1a434aa..bfb44d0 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -140,7 +140,7 @@ iphone_error_t lockdownd_stop_session(lockdownd_client_t client)
plist_add_sub_key_el(dict, "SessionID");
plist_add_sub_string_el(dict, client->session_id);
- log_dbg_msg(DBGMASK_LOCKDOWND, "iphone_lckd_stop_session() called\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: called\n", __func__);
ret = lockdownd_send(client, dict);
@@ -150,13 +150,13 @@ iphone_error_t lockdownd_stop_session(lockdownd_client_t client)
ret = lockdownd_recv(client, &dict);
if (!dict) {
- log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_stop_session(): IPHONE_E_PLIST_ERROR\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: LOCKDOWN_E_PLIST_ERROR\n", __func__);
return IPHONE_E_PLIST_ERROR;
}
ret = IPHONE_E_UNKNOWN_ERROR;
if (lockdown_check_result(dict, "StopSession") == RESULT_SUCCESS) {
- log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_stop_session(): success\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: success\n", __func__);
ret = IPHONE_E_SUCCESS;
}
plist_free(dict);
@@ -175,15 +175,15 @@ iphone_error_t lockdownd_stop_session(lockdownd_client_t client)
static iphone_error_t lockdownd_stop_ssl_session(lockdownd_client_t client)
{
if (!client) {
- log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_stop_ssl_session(): invalid argument!\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: invalid argument!\n", __func__);
return IPHONE_E_INVALID_ARG;
}
iphone_error_t ret = IPHONE_E_SUCCESS;
if (client->in_SSL) {
- log_dbg_msg(DBGMASK_LOCKDOWND, "Stopping SSL Session\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: stopping SSL session\n", __func__);
ret = lockdownd_stop_session(client);
- log_dbg_msg(DBGMASK_LOCKDOWND, "Sending SSL close notify\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: sending SSL close notify\n", __func__);
gnutls_bye(*client->ssl_session, GNUTLS_SHUT_RDWR);
}
if (client->ssl_session) {
@@ -281,7 +281,7 @@ iphone_error_t lockdownd_recv(lockdownd_client_t client, plist_t *plist)
return IPHONE_E_NOT_ENOUGH_DATA;
}
- log_dbg_msg(DBGMASK_LOCKDOWND, "Recv msg :\nsize : %i\nbuffer :\n%s\n", received_bytes, receive);
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: received msg size: %i, buffer follows:\n%s", __func__, received_bytes, receive);
plist_from_xml(receive, received_bytes, plist);
free(receive);
@@ -312,14 +312,14 @@ iphone_error_t lockdownd_send(lockdownd_client_t client, plist_t plist)
iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR;
plist_to_xml(plist, &XMLContent, &length);
- log_dbg_msg(DBGMASK_LOCKDOWND, "Send msg :\nsize : %i\nbuffer :\n%s\n", length, XMLContent);
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: sending msg size %i, buffer follows:\n%s", __func__, length, XMLContent);
real_query = (char *) malloc(sizeof(char) * (length + 4));
length = htonl(length);
memcpy(real_query, &length, sizeof(length));
memcpy(real_query + 4, XMLContent, ntohl(length));
free(XMLContent);
- log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_send(): made the query, sending it along\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: made the query, sending it along\n", __func__);
if (!client->in_SSL)
ret = usbmuxd_send(client->sfd, real_query, ntohl(length) + sizeof(length), (uint32_t*)&bytes);
@@ -334,9 +334,9 @@ iphone_error_t lockdownd_send(lockdownd_client_t client, plist_t plist)
}
}
if (ret == IPHONE_E_SUCCESS) {
- log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_send(): sent it!\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: sent it!\n", __func__);
} else {
- log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_send(): sending failed!\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: sending failed!\n", __func__);
}
free(real_query);
@@ -360,7 +360,7 @@ iphone_error_t lockdownd_query_type(lockdownd_client_t client)
plist_add_sub_key_el(dict, "Request");
plist_add_sub_string_el(dict, "QueryType");
- log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_query_type() called\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: called\n", __func__);
ret = lockdownd_send(client, dict);
plist_free(dict);
@@ -373,7 +373,7 @@ iphone_error_t lockdownd_query_type(lockdownd_client_t client)
ret = IPHONE_E_UNKNOWN_ERROR;
if (lockdown_check_result(dict, "QueryType") == RESULT_SUCCESS) {
- log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_query_type(): success\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: success\n", __func__);
ret = IPHONE_E_SUCCESS;
}
plist_free(dict);
@@ -445,7 +445,7 @@ iphone_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain
plist_get_key_val(value_key_node, &result_key);
if (!strcmp(result_key, "Value")) {
- log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_get_value(): has a value\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: has a value\n", __func__);
*value = plist_copy(value_value_node);
}
free(result_key);
@@ -669,17 +669,16 @@ iphone_error_t lockdownd_new_client(iphone_device_t device, lockdownd_client_t *
client_loc->ssl_session = (gnutls_session_t *) malloc(sizeof(gnutls_session_t));
client_loc->in_SSL = 0;
- if (IPHONE_E_SUCCESS != lockdownd_query_type(client_loc)) {
- log_debug_msg("QueryType failed in the lockdownd client.\n");
+ log_debug_msg("%s: QueryType failed in the lockdownd client.\n", __func__);
ret = IPHONE_E_NOT_ENOUGH_DATA;
}
char *uid = NULL;
ret = lockdownd_get_device_uid(client_loc, &uid);
if (IPHONE_E_SUCCESS != ret) {
- log_debug_msg("Device refused to send uid.\n");
+ log_debug_msg("%s: failed to get device uuid.\n", __func__);
}
- log_debug_msg("Device uid: %s\n", uid);
+ log_debug_msg("%s: device uuid: %s\n", __func__, uid);
host_id = get_host_id();
if (IPHONE_E_SUCCESS == ret && !host_id) {
@@ -698,7 +697,7 @@ iphone_error_t lockdownd_new_client(iphone_device_t device, lockdownd_client_t *
ret = lockdownd_start_ssl_session(client_loc, host_id);
if (IPHONE_E_SUCCESS != ret) {
ret = IPHONE_E_SSL_ERROR;
- log_debug_msg("SSL Session opening failed.\n");
+ log_debug_msg("%s: SSL Session opening failed.\n", __func__);
}
if (host_id) {
@@ -731,10 +730,10 @@ iphone_error_t lockdownd_pair(lockdownd_client_t client, char *uid, char *host_i
ret = lockdownd_get_device_public_key(client, &public_key);
if (ret != IPHONE_E_SUCCESS) {
- log_debug_msg("Device refused to send public key.\n");
+ log_debug_msg("%s: device refused to send public key.\n", __func__);
return ret;
}
- log_debug_msg("device public key :\n %s.\n", public_key.data);
+ log_debug_msg("%s: device public key follows:\n%s\n", __func__, public_key.data);
ret = lockdownd_gen_pair_cert(public_key, &device_cert, &host_cert, &root_cert);
if (ret != IPHONE_E_SUCCESS) {
@@ -780,11 +779,11 @@ iphone_error_t lockdownd_pair(lockdownd_client_t client, char *uid, char *host_i
/* store public key in config if pairing succeeded */
if (ret == IPHONE_E_SUCCESS) {
- log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_pair: pair success\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: pair success\n", __func__);
store_device_public_key(uid, public_key);
ret = IPHONE_E_SUCCESS;
} else {
- log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_pair: pair failure\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: pair failure\n", __func__);
ret = IPHONE_E_PAIRING_FAILED;
}
free(public_key.data);
@@ -809,7 +808,7 @@ iphone_error_t lockdownd_enter_recovery(lockdownd_client_t client)
plist_add_sub_key_el(dict, "Request");
plist_add_sub_string_el(dict, "EnterRecovery");
- log_dbg_msg(DBGMASK_LOCKDOWND, "%s: Telling device to enter recovery mode\n", __func__);
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: telling device to enter recovery mode\n", __func__);
ret = lockdownd_send(client, dict);
plist_free(dict);
@@ -845,21 +844,20 @@ iphone_error_t lockdownd_goodbye(lockdownd_client_t client)
plist_add_sub_key_el(dict, "Request");
plist_add_sub_string_el(dict, "Goodbye");
- log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_goodbye() called\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: called\n", __func__);
ret = lockdownd_send(client, dict);
plist_free(dict);
dict = NULL;
ret = lockdownd_recv(client, &dict);
-
if (!dict) {
- log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_goodbye(): IPHONE_E_PLIST_ERROR\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: did not get goodbye response back\n", __func__);
return IPHONE_E_PLIST_ERROR;
}
if (lockdown_check_result(dict, "Goodbye") == RESULT_SUCCESS) {
- log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_goodbye(): success\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: success\n", __func__);
ret = IPHONE_E_SUCCESS;
}
plist_free(dict);
@@ -1062,7 +1060,7 @@ iphone_error_t lockdownd_start_ssl_session(lockdownd_client_t client, const char
//gnutls_anon_client_credentials_t anoncred;
gnutls_certificate_credentials_t xcred;
- log_dbg_msg(DBGMASK_LOCKDOWND, "We started the session OK, now trying GnuTLS\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: started the session OK, now trying GnuTLS\n", __func__);
errno = 0;
gnutls_global_init();
//gnutls_anon_allocate_client_credentials(&anoncred);
@@ -1084,23 +1082,22 @@ iphone_error_t lockdownd_start_ssl_session(lockdownd_client_t client, const char
}
gnutls_credentials_set(*client->ssl_session, GNUTLS_CRD_CERTIFICATE, xcred); // this part is killing me.
- log_dbg_msg(DBGMASK_LOCKDOWND, "GnuTLS step 1...\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS step 1...\n", __func__);
gnutls_transport_set_ptr(*client->ssl_session, (gnutls_transport_ptr_t) client);
- log_dbg_msg(DBGMASK_LOCKDOWND, "GnuTLS step 2...\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS step 2...\n", __func__);
gnutls_transport_set_push_function(*client->ssl_session, (gnutls_push_func) & lockdownd_secuwrite);
- log_dbg_msg(DBGMASK_LOCKDOWND, "GnuTLS step 3...\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS step 3...\n", __func__);
gnutls_transport_set_pull_function(*client->ssl_session, (gnutls_pull_func) & lockdownd_securead);
- log_dbg_msg(DBGMASK_LOCKDOWND, "GnuTLS step 4 -- now handshaking...\n");
-
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS step 4 -- now handshaking...\n", __func__);
if (errno)
- log_dbg_msg(DBGMASK_LOCKDOWND, "WARN: errno says %s before handshake!\n", strerror(errno));
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: WARN: errno says %s before handshake!\n", __func__, strerror(errno));
return_me = gnutls_handshake(*client->ssl_session);
- log_dbg_msg(DBGMASK_LOCKDOWND, "GnuTLS handshake done...\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS handshake done...\n", __func__);
if (return_me != GNUTLS_E_SUCCESS) {
- log_dbg_msg(DBGMASK_LOCKDOWND, "GnuTLS reported something wrong.\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS reported something wrong.\n", __func__);
gnutls_perror(return_me);
- log_dbg_msg(DBGMASK_LOCKDOWND, "oh.. errno says %s\n", strerror(errno));
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: oh.. errno says %s\n", __func__, strerror(errno));
return IPHONE_E_SSL_ERROR;
} else {
client->in_SSL = 1;
@@ -1122,20 +1119,20 @@ iphone_error_t lockdownd_start_ssl_session(lockdownd_client_t client, const char
if (session_node_val_type == PLIST_STRING && session_id) {
// we need to store the session ID for StopSession
strcpy(client->session_id, session_id);
- log_dbg_msg(DBGMASK_LOCKDOWND, "SessionID: %s\n", client->session_id);
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: SessionID: %s\n", __func__, client->session_id);
}
if (session_id)
free(session_id);
}
} else
- log_dbg_msg(DBGMASK_LOCKDOWND, "Failed to get SessionID!\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: Failed to get SessionID!\n", __func__);
plist_free(dict);
dict = NULL;
if (ret == IPHONE_E_SUCCESS)
return ret;
- log_dbg_msg(DBGMASK_LOCKDOWND, "Apparently failed negotiating with lockdownd.\n");
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: Apparently failed negotiating with lockdownd.\n", __func__);
return IPHONE_E_SSL_ERROR;
}
@@ -1152,12 +1149,10 @@ ssize_t lockdownd_secuwrite(gnutls_transport_ptr_t transport, char *buffer, size
uint32_t bytes = 0;
lockdownd_client_t client;
client = (lockdownd_client_t) transport;
- log_dbg_msg(DBGMASK_LOCKDOWND, "lockdownd_secuwrite() called\n");
- log_dbg_msg(DBGMASK_LOCKDOWND, "pre-send\nlength = %zi\n", length);
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: called\n", __func__);
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: pre-send length = %zi\n", __func__, length);
usbmuxd_send(client->sfd, buffer, length, &bytes);
- log_dbg_msg(DBGMASK_LOCKDOWND, "post-send\nsent %i bytes\n", bytes);
-
- dump_debug_buffer("sslpacketwrite.out", buffer, length);
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: post-send sent %i bytes\n", __func__, bytes);
return bytes;
}
@@ -1179,9 +1174,7 @@ ssize_t lockdownd_securead(gnutls_transport_ptr_t transport, char *buffer, size_
client = (lockdownd_client_t) transport;
char *recv_buffer;
- log_debug_msg("lockdownd_securead() called\nlength = %zi\n", length);
-
- log_debug_msg("pre-read\nclient wants %zi bytes\n", length);
+ log_debug_msg("%s: pre-read client wants %zi bytes\n", __func__, length);
recv_buffer = (char *) malloc(sizeof(char) * this_len);
@@ -1191,7 +1184,7 @@ ssize_t lockdownd_securead(gnutls_transport_ptr_t transport, char *buffer, size_
log_debug_msg("%s: ERROR: usbmux_recv returned %d\n", __func__, res);
return res;
}
- log_debug_msg("post-read\nwe got %i bytes\n", bytes);
+ log_debug_msg("%s: post-read we got %i bytes\n", __func__, bytes);
// increase read count
tbytes += bytes;
@@ -1205,7 +1198,7 @@ ssize_t lockdownd_securead(gnutls_transport_ptr_t transport, char *buffer, size_
}
this_len = length - tbytes;
- log_debug_msg("re-read\ntrying to read missing %i bytes\n", this_len);
+ log_debug_msg("%s: re-read trying to read missing %i bytes\n", __func__, this_len);
} while (tbytes < length);
if (recv_buffer) {
diff --git a/src/userpref.c b/src/userpref.c
index 0e83133..f7ddaeb 100644
--- a/src/userpref.c
+++ b/src/userpref.c
@@ -102,7 +102,7 @@ static int write_host_id(char *host_id)
key_file = g_key_file_new();
/* Store in config file */
- log_debug_msg("init_config_file(): setting hostID to %s\n", host_id);
+ log_debug_msg("%s: setting hostID to %s\n", __func__, host_id);
g_key_file_set_value(key_file, "Global", "HostID", host_id);
/* Write config file on disk */
@@ -152,7 +152,7 @@ char *get_host_id(void)
write_host_id(host_id);
}
- log_debug_msg("get_host_id(): Using %s as HostID\n", host_id);
+ log_debug_msg("%s: Using %s as HostID\n", __func__, host_id);
return host_id;
}
@@ -275,7 +275,6 @@ static iphone_error_t gen_keys_and_cert(void)
gnutls_x509_crt_set_expiration_time(root_cert, time(NULL) + (60 * 60 * 24 * 365 * 10));
gnutls_x509_crt_sign(root_cert, root_cert, root_privkey);
-
gnutls_x509_crt_set_key(host_cert, host_privkey);
gnutls_x509_crt_set_serial(host_cert, "\x00", 1);
gnutls_x509_crt_set_version(host_cert, 3);
diff --git a/src/utils.c b/src/utils.c
index 121bc55..6535a07 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -116,13 +116,12 @@ inline void log_debug_buffer(const char *data, const int length)
inline void dump_debug_buffer(const char *file, const char *data, const int length)
{
#ifndef STRIP_DEBUG_CODE
-
/* run the real fprintf */
if (toto_debug) {
FILE *my_ssl_packet = fopen(file, "w+");
fwrite(data, 1, length, my_ssl_packet);
fflush(my_ssl_packet);
- fprintf(stderr, "Wrote SSL packet to drive, too.\n");
+ fprintf(stderr, "%s: Wrote SSL packet to drive, too.\n", __func__);
fclose(my_ssl_packet);
}
#endif