diff options
| author | 2009-11-18 20:03:44 +0100 | |
|---|---|---|
| committer | 2009-11-18 20:03:44 +0100 | |
| commit | b15705c7b8cf85df53d610bbe5dd34654cdadc6f (patch) | |
| tree | 057f33e097c4d6ee1538b7f752b5120d0a77bad4 | |
| parent | fea0152549d5e77f914f75c0ac315f30f9e26426 (diff) | |
| parent | 91f9e449f7432d8b609d5550a2abae47bb7b9aff (diff) | |
| download | libimobiledevice-b15705c7b8cf85df53d610bbe5dd34654cdadc6f.tar.gz libimobiledevice-b15705c7b8cf85df53d610bbe5dd34654cdadc6f.tar.bz2 | |
Merge branch 'master' of git://github.com/MattColyer/libiphone into martin
| -rw-r--r-- | configure.ac | 4 | ||||
| -rw-r--r-- | doxygen.cfg | 2 | ||||
| -rw-r--r-- | src/lockdown.c | 47 | ||||
| -rw-r--r-- | src/lockdown.h | 3 | ||||
| -rw-r--r-- | swig/Makefile.am | 22 | ||||
| -rw-r--r-- | swig/__init__.py | 3 | ||||
| -rw-r--r-- | swig/iphone.i | 2 |
7 files changed, 43 insertions, 40 deletions
diff --git a/configure.ac b/configure.ac index 58aee42..7c59171 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | # Process this file with autoconf to produce a configure script. | 2 | # Process this file with autoconf to produce a configure script. |
| 3 | 3 | ||
| 4 | AC_PREREQ(2.61) | 4 | AC_PREREQ(2.61) |
| 5 | AC_INIT(libiphone, 0.9.4, nospam@nowhere.com) | 5 | AC_INIT(libiphone, 0.9.5, nospam@nowhere.com) |
| 6 | AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip]) | 6 | AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip]) |
| 7 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES]) | 7 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES]) |
| 8 | AC_CONFIG_SRCDIR([src/]) | 8 | AC_CONFIG_SRCDIR([src/]) |
| @@ -104,4 +104,6 @@ if test "$enable_largefile" != no; then | |||
| 104 | fi | 104 | fi |
| 105 | AC_SUBST(LFS_CFLAGS) | 105 | AC_SUBST(LFS_CFLAGS) |
| 106 | 106 | ||
| 107 | m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) | ||
| 108 | |||
| 107 | AC_OUTPUT(Makefile src/Makefile include/Makefile fdi/Makefile dev/Makefile tools/Makefile swig/Makefile libiphone-1.0.pc) | 109 | AC_OUTPUT(Makefile src/Makefile include/Makefile fdi/Makefile dev/Makefile tools/Makefile swig/Makefile libiphone-1.0.pc) |
diff --git a/doxygen.cfg b/doxygen.cfg index c51aed7..c411c3d 100644 --- a/doxygen.cfg +++ b/doxygen.cfg | |||
| @@ -31,7 +31,7 @@ PROJECT_NAME = libiphone | |||
| 31 | # This could be handy for archiving the generated documentation or | 31 | # This could be handy for archiving the generated documentation or |
| 32 | # if some version control system is used. | 32 | # if some version control system is used. |
| 33 | 33 | ||
| 34 | PROJECT_NUMBER = 0.9.4 | 34 | PROJECT_NUMBER = 0.9.5 |
| 35 | 35 | ||
| 36 | # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) | 36 | # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) |
| 37 | # base path where the generated documentation will be put. | 37 | # base path where the generated documentation will be put. |
diff --git a/src/lockdown.c b/src/lockdown.c index 80a89dc..3bfd16f 100644 --- a/src/lockdown.c +++ b/src/lockdown.c | |||
| @@ -172,12 +172,14 @@ static lockdownd_error_t lockdownd_stop_ssl_session(lockdownd_client_t client) | |||
| 172 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: stopping SSL session\n", __func__); | 172 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: stopping SSL session\n", __func__); |
| 173 | ret = lockdownd_stop_session(client, client->session_id); | 173 | ret = lockdownd_stop_session(client, client->session_id); |
| 174 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: sending SSL close notify\n", __func__); | 174 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: sending SSL close notify\n", __func__); |
| 175 | gnutls_bye(*client->ssl_session, GNUTLS_SHUT_RDWR); | 175 | gnutls_bye(client->ssl_session, GNUTLS_SHUT_RDWR); |
| 176 | } | 176 | } |
| 177 | if (client->ssl_session) { | 177 | if (client->ssl_session) { |
| 178 | gnutls_deinit(*client->ssl_session); | 178 | gnutls_deinit(client->ssl_session); |
| 179 | free(client->ssl_session); | 179 | } |
| 180 | } | 180 | if (client->ssl_certificate) { |
| 181 | gnutls_certificate_free_credentials(client->ssl_certificate); | ||
| 182 | } | ||
| 181 | client->in_SSL = 0; | 183 | client->in_SSL = 0; |
| 182 | 184 | ||
| 183 | return ret; | 185 | return ret; |
| @@ -229,7 +231,7 @@ lockdownd_error_t lockdownd_recv(lockdownd_client_t client, plist_t *plist) | |||
| 229 | if (!client->in_SSL) | 231 | if (!client->in_SSL) |
| 230 | ret = iphone_device_recv(client->connection, (char *) &datalen, sizeof(datalen), &bytes); | 232 | ret = iphone_device_recv(client->connection, (char *) &datalen, sizeof(datalen), &bytes); |
| 231 | else { | 233 | else { |
| 232 | ssize_t res = gnutls_record_recv(*client->ssl_session, &datalen, sizeof(datalen)); | 234 | ssize_t res = gnutls_record_recv(client->ssl_session, &datalen, sizeof(datalen)); |
| 233 | if (res < 0) { | 235 | if (res < 0) { |
| 234 | log_dbg_msg(DBGMASK_LOCKDOWND, "gnutls_record_recv: Error occured: %s\n", gnutls_strerror(res)); | 236 | log_dbg_msg(DBGMASK_LOCKDOWND, "gnutls_record_recv: Error occured: %s\n", gnutls_strerror(res)); |
| 235 | return LOCKDOWN_E_SSL_ERROR; | 237 | return LOCKDOWN_E_SSL_ERROR; |
| @@ -252,7 +254,7 @@ lockdownd_error_t lockdownd_recv(lockdownd_client_t client, plist_t *plist) | |||
| 252 | } else { | 254 | } else { |
| 253 | ssize_t res = 0; | 255 | ssize_t res = 0; |
| 254 | while ((received_bytes < datalen) && (ret == LOCKDOWN_E_SUCCESS)) { | 256 | while ((received_bytes < datalen) && (ret == LOCKDOWN_E_SUCCESS)) { |
| 255 | res = gnutls_record_recv(*client->ssl_session, receive + received_bytes, datalen - received_bytes); | 257 | res = gnutls_record_recv(client->ssl_session, receive + received_bytes, datalen - received_bytes); |
| 256 | if (res < 0) { | 258 | if (res < 0) { |
| 257 | log_dbg_msg(DBGMASK_LOCKDOWND, "gnutls_record_recv: Error occured: %s\n", gnutls_strerror(res)); | 259 | log_dbg_msg(DBGMASK_LOCKDOWND, "gnutls_record_recv: Error occured: %s\n", gnutls_strerror(res)); |
| 258 | ret = LOCKDOWN_E_SSL_ERROR; | 260 | ret = LOCKDOWN_E_SSL_ERROR; |
| @@ -316,7 +318,7 @@ lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist) | |||
| 316 | if (!client->in_SSL) | 318 | if (!client->in_SSL) |
| 317 | ret = iphone_device_send(client->connection, real_query, ntohl(length) + sizeof(length), (uint32_t*)&bytes); | 319 | ret = iphone_device_send(client->connection, real_query, ntohl(length) + sizeof(length), (uint32_t*)&bytes); |
| 318 | else { | 320 | else { |
| 319 | ssize_t res = gnutls_record_send(*client->ssl_session, real_query, ntohl(length) + sizeof(length)); | 321 | ssize_t res = gnutls_record_send(client->ssl_session, real_query, ntohl(length) + sizeof(length)); |
| 320 | if (res < 0) { | 322 | if (res < 0) { |
| 321 | log_dbg_msg(DBGMASK_LOCKDOWND, "gnutls_record_send: Error occured: %s\n", gnutls_strerror(res)); | 323 | log_dbg_msg(DBGMASK_LOCKDOWND, "gnutls_record_send: Error occured: %s\n", gnutls_strerror(res)); |
| 322 | ret = LOCKDOWN_E_SSL_ERROR; | 324 | ret = LOCKDOWN_E_SSL_ERROR; |
| @@ -637,7 +639,7 @@ lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_ | |||
| 637 | 639 | ||
| 638 | lockdownd_client_t client_loc = (lockdownd_client_t) malloc(sizeof(struct lockdownd_client_int)); | 640 | lockdownd_client_t client_loc = (lockdownd_client_t) malloc(sizeof(struct lockdownd_client_int)); |
| 639 | client_loc->connection = connection; | 641 | client_loc->connection = connection; |
| 640 | client_loc->ssl_session = (gnutls_session_t *) malloc(sizeof(gnutls_session_t)); | 642 | client_loc->ssl_session = NULL; |
| 641 | client_loc->in_SSL = 0; | 643 | client_loc->in_SSL = 0; |
| 642 | 644 | ||
| 643 | if (LOCKDOWN_E_SUCCESS != lockdownd_query_type(client_loc)) { | 645 | if (LOCKDOWN_E_SUCCESS != lockdownd_query_type(client_loc)) { |
| @@ -1037,16 +1039,13 @@ lockdownd_error_t lockdownd_start_ssl_session(lockdownd_client_t client, const c | |||
| 1037 | ret = LOCKDOWN_E_SSL_ERROR; | 1039 | ret = LOCKDOWN_E_SSL_ERROR; |
| 1038 | if (lockdown_check_result(dict, "StartSession") == RESULT_SUCCESS) { | 1040 | if (lockdown_check_result(dict, "StartSession") == RESULT_SUCCESS) { |
| 1039 | // Set up GnuTLS... | 1041 | // Set up GnuTLS... |
| 1040 | //gnutls_anon_client_credentials_t anoncred; | ||
| 1041 | gnutls_certificate_credentials_t xcred; | ||
| 1042 | |||
| 1043 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: started the session OK, now trying GnuTLS\n", __func__); | 1042 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: started the session OK, now trying GnuTLS\n", __func__); |
| 1044 | errno = 0; | 1043 | errno = 0; |
| 1045 | gnutls_global_init(); | 1044 | gnutls_global_init(); |
| 1046 | //gnutls_anon_allocate_client_credentials(&anoncred); | 1045 | //gnutls_anon_allocate_client_credentials(&anoncred); |
| 1047 | gnutls_certificate_allocate_credentials(&xcred); | 1046 | gnutls_certificate_allocate_credentials(&client->ssl_certificate); |
| 1048 | gnutls_certificate_set_x509_trust_file(xcred, "hostcert.pem", GNUTLS_X509_FMT_PEM); | 1047 | gnutls_certificate_set_x509_trust_file(client->ssl_certificate, "hostcert.pem", GNUTLS_X509_FMT_PEM); |
| 1049 | gnutls_init(client->ssl_session, GNUTLS_CLIENT); | 1048 | gnutls_init(&client->ssl_session, GNUTLS_CLIENT); |
| 1050 | { | 1049 | { |
| 1051 | int protocol_priority[16] = { GNUTLS_SSL3, 0 }; | 1050 | int protocol_priority[16] = { GNUTLS_SSL3, 0 }; |
| 1052 | int kx_priority[16] = { GNUTLS_KX_ANON_DH, GNUTLS_KX_RSA, 0 }; | 1051 | int kx_priority[16] = { GNUTLS_KX_ANON_DH, GNUTLS_KX_RSA, 0 }; |
| @@ -1054,24 +1053,24 @@ lockdownd_error_t lockdownd_start_ssl_session(lockdownd_client_t client, const c | |||
| 1054 | int mac_priority[16] = { GNUTLS_MAC_SHA1, GNUTLS_MAC_MD5, 0 }; | 1053 | int mac_priority[16] = { GNUTLS_MAC_SHA1, GNUTLS_MAC_MD5, 0 }; |
| 1055 | int comp_priority[16] = { GNUTLS_COMP_NULL, 0 }; | 1054 | int comp_priority[16] = { GNUTLS_COMP_NULL, 0 }; |
| 1056 | 1055 | ||
| 1057 | gnutls_cipher_set_priority(*client->ssl_session, cipher_priority); | 1056 | gnutls_cipher_set_priority(client->ssl_session, cipher_priority); |
| 1058 | gnutls_compression_set_priority(*client->ssl_session, comp_priority); | 1057 | gnutls_compression_set_priority(client->ssl_session, comp_priority); |
| 1059 | gnutls_kx_set_priority(*client->ssl_session, kx_priority); | 1058 | gnutls_kx_set_priority(client->ssl_session, kx_priority); |
| 1060 | gnutls_protocol_set_priority(*client->ssl_session, protocol_priority); | 1059 | gnutls_protocol_set_priority(client->ssl_session, protocol_priority); |
| 1061 | gnutls_mac_set_priority(*client->ssl_session, mac_priority); | 1060 | gnutls_mac_set_priority(client->ssl_session, mac_priority); |
| 1062 | } | 1061 | } |
| 1063 | gnutls_credentials_set(*client->ssl_session, GNUTLS_CRD_CERTIFICATE, xcred); // this part is killing me. | 1062 | gnutls_credentials_set(client->ssl_session, GNUTLS_CRD_CERTIFICATE, client->ssl_certificate); // this part is killing me. |
| 1064 | 1063 | ||
| 1065 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS step 1...\n", __func__); | 1064 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS step 1...\n", __func__); |
| 1066 | gnutls_transport_set_ptr(*client->ssl_session, (gnutls_transport_ptr_t) client); | 1065 | gnutls_transport_set_ptr(client->ssl_session, (gnutls_transport_ptr_t) client); |
| 1067 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS step 2...\n", __func__); | 1066 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS step 2...\n", __func__); |
| 1068 | gnutls_transport_set_push_function(*client->ssl_session, (gnutls_push_func) & lockdownd_secuwrite); | 1067 | gnutls_transport_set_push_function(client->ssl_session, (gnutls_push_func) & lockdownd_secuwrite); |
| 1069 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS step 3...\n", __func__); | 1068 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS step 3...\n", __func__); |
| 1070 | gnutls_transport_set_pull_function(*client->ssl_session, (gnutls_pull_func) & lockdownd_securead); | 1069 | gnutls_transport_set_pull_function(client->ssl_session, (gnutls_pull_func) & lockdownd_securead); |
| 1071 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS step 4 -- now handshaking...\n", __func__); | 1070 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS step 4 -- now handshaking...\n", __func__); |
| 1072 | if (errno) | 1071 | if (errno) |
| 1073 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: WARN: errno says %s before handshake!\n", __func__, strerror(errno)); | 1072 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: WARN: errno says %s before handshake!\n", __func__, strerror(errno)); |
| 1074 | return_me = gnutls_handshake(*client->ssl_session); | 1073 | return_me = gnutls_handshake(client->ssl_session); |
| 1075 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS handshake done...\n", __func__); | 1074 | log_dbg_msg(DBGMASK_LOCKDOWND, "%s: GnuTLS handshake done...\n", __func__); |
| 1076 | 1075 | ||
| 1077 | if (return_me != GNUTLS_E_SUCCESS) { | 1076 | if (return_me != GNUTLS_E_SUCCESS) { |
diff --git a/src/lockdown.h b/src/lockdown.h index 19cf9f2..9312867 100644 --- a/src/lockdown.h +++ b/src/lockdown.h | |||
| @@ -29,7 +29,8 @@ | |||
| 29 | 29 | ||
| 30 | struct lockdownd_client_int { | 30 | struct lockdownd_client_int { |
| 31 | iphone_connection_t connection; | 31 | iphone_connection_t connection; |
| 32 | gnutls_session_t *ssl_session; | 32 | gnutls_session_t ssl_session; |
| 33 | gnutls_certificate_credentials_t ssl_certificate; | ||
| 33 | int in_SSL; | 34 | int in_SSL; |
| 34 | char session_id[40]; | 35 | char session_id[40]; |
| 35 | }; | 36 | }; |
diff --git a/swig/Makefile.am b/swig/Makefile.am index 0da739b..a38534d 100644 --- a/swig/Makefile.am +++ b/swig/Makefile.am | |||
| @@ -6,25 +6,25 @@ SWIG_SOURCES = iphone.i | |||
| 6 | CLEANFILES = \ | 6 | CLEANFILES = \ |
| 7 | *.pyc \ | 7 | *.pyc \ |
| 8 | *.pyo \ | 8 | *.pyo \ |
| 9 | _iPhone.so \ | 9 | _iphone.so \ |
| 10 | iPhone.py \ | 10 | iphone.py \ |
| 11 | iphone_wrap.cxx | 11 | iphone_wrap.cxx |
| 12 | 12 | ||
| 13 | EXTRA_DIST = \ | 13 | EXTRA_DIST = \ |
| 14 | __init__.py \ | 14 | __init__.py \ |
| 15 | iphone.i | 15 | iphone.i |
| 16 | 16 | ||
| 17 | swigincludedir =$(includedir)/libiphone/swig | 17 | swigincludedir =$(includedir)/libiphone/swig |
| 18 | swiginclude_HEADERS = $(SWIG_SOURCES) | 18 | swiginclude_HEADERS = $(SWIG_SOURCES) |
| 19 | 19 | ||
| 20 | iPhonedir = $(pyexecdir)/libiphone | 20 | iphonedir = $(pyexecdir)/iphone |
| 21 | iPhone_PYTHON = __init__.py | 21 | iphone_PYTHON = __init__.py |
| 22 | nodist_iPhone_PYTHON = iPhone.py | 22 | nodist_iphone_PYTHON = iphone.py |
| 23 | iPhone_LTLIBRARIES = _iPhone.la | 23 | iphone_LTLIBRARIES = _iphone.la |
| 24 | nodist__iPhone_la_SOURCES = iphone_wrap.cxx $(SWIG_SOURCES) | 24 | nodist__iphone_la_SOURCES = iphone_wrap.cxx $(SWIG_SOURCES) |
| 25 | _iPhone_la_CFLAGS = $(PYTHON_CPPFLAGS) -I$(top_srcdir)/src | 25 | _iphone_la_CFLAGS = $(PYTHON_CPPFLAGS) -I$(top_srcdir)/src |
| 26 | _iPhone_la_LDFLAGS = -module -avoid-version $(PYTHON_LDFLAGS) | 26 | _iphone_la_LDFLAGS = -module -avoid-version $(PYTHON_LDFLAGS) |
| 27 | _iPhone_la_LIBADD = $(top_builddir)/src/libiphone.la $(libplistmm_LIBS) | 27 | _iphone_la_LIBADD = $(top_builddir)/src/libiphone.la $(libplistmm_LIBS) |
| 28 | 28 | ||
| 29 | iphone_wrap.cxx : $(SWIG_SOURCES) | 29 | iphone_wrap.cxx : $(SWIG_SOURCES) |
| 30 | $(SWIG) $(SWIG_PYTHON_OPT) $(INCLUDES) -I$(top_srcdir)/src -o $@ $< | 30 | $(SWIG) $(SWIG_PYTHON_OPT) $(INCLUDES) -I$(top_srcdir)/src -o $@ $< |
diff --git a/swig/__init__.py b/swig/__init__.py index 8d1c8b6..e70dcce 100644 --- a/swig/__init__.py +++ b/swig/__init__.py | |||
| @@ -1 +1,2 @@ | |||
| 1 | 1 | # -*- coding: utf-8 -*- | |
| 2 | from iphone import * | ||
diff --git a/swig/iphone.i b/swig/iphone.i index 6604c63..a0ee509 100644 --- a/swig/iphone.i +++ b/swig/iphone.i | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* swig.i */ | 1 | /* swig.i */ |
| 2 | %module(package="libiphone") iPhone | 2 | %module iphone |
| 3 | %feature("autodoc", "1"); | 3 | %feature("autodoc", "1"); |
| 4 | %{ | 4 | %{ |
| 5 | /* Includes the header in the wrapper code */ | 5 | /* Includes the header in the wrapper code */ |
