diff options
author | Jonathan Beck | 2009-01-29 18:02:04 +0100 |
---|---|---|
committer | Jonathan Beck | 2009-01-29 18:02:04 +0100 |
commit | c1b2004461aaf2912af749620e7504345bf409ba (patch) | |
tree | 2c238a2d8c1598265a07a2fd52beec0939d08a73 | |
parent | 0934d1ac021dfb7907e4b580b38aa4a938cf2180 (diff) | |
parent | f7fbac7803c5cb5934aab58925babc70af4ab848 (diff) | |
download | libimobiledevice-c1b2004461aaf2912af749620e7504345bf409ba.tar.gz libimobiledevice-c1b2004461aaf2912af749620e7504345bf409ba.tar.bz2 |
Merge branch 'master' into contact_sync
Conflicts:
src/Makefile.am
src/iphone.c
src/lockdown.c
src/lockdown.h
src/utils.c
-rw-r--r-- | AUTHORS | 2 | ||||
-rw-r--r-- | README | 65 | ||||
-rw-r--r-- | include/libiphone/libiphone.h | 9 | ||||
-rw-r--r-- | src/AFC.c | 2 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/iphone.c | 26 | ||||
-rw-r--r-- | src/lockdown.c | 16 | ||||
-rw-r--r-- | src/lockdown.h | 3 | ||||
-rw-r--r-- | src/utils.c | 1 |
9 files changed, 36 insertions, 90 deletions
@@ -6,3 +6,5 @@ Christophe Fergeau Martin S. Paul Sladen Patrick Walton +Zoltan Balaton +Nikias Bassen @@ -47,71 +47,6 @@ run _once_. It MUST be run otherwise communication will not work: The generated keys are saved in '~/.config/libiphone/' in your home directory. -== Tools == - -There are currently two more executables 'ifuse' and 'iphoneclient', -both located in src/. - - -=== iFuse === - -This is probably what you're after; this mounts a view of your -iPhone/iPod Touch's filesystem over the USB interface using the native -Apple protocol (AFC/"com.apple.afc"). - -ifuse is a Fuse filesystem which allows you to mount your iPhone to a directory -like this: - - ./src/ifuse <mountpoint> -s - -To unmount: - umount <mountpoint> - -(nb: '-s' is to force single-threaded mode, as ifuse maybe unstable without it). - -Eg: - mkdir ~/iphone - - ifuse ~/iphone -s - ls -l ~/iphone - ... - umount ~/iphone - -Currently ifuse (via the AFC protocol) only gives access to the -'/var/root/Media/' chroot on the iPhone (containing music/pictures). - -If you have a device that has been jailedbreaked then an additional -("com.apple.afc2") service will have been installed, without the chroot. -On jailbroken devices only, you can do: - - ifuse ~/iphone --root -s - -And this will mount a full view of the iPhone's filesystem. - - -==== Setting up FUSE ==== - -Note that on some systems, you may have to load the 'fuse' kernel -module first and to ensure that you are a member of the 'fuse' group: - - sudo modprobe fuse - sudo adduser $USER fuse - -You can check your membership of the 'fuse' group with: - - id | grep fuse && echo yes! || echo not yet... - -If you have just added yourself, you will need to logout and log back -in for the group change to become visible. - - -=== iphoneclient === - -'iphoneclient' is a basic commandline interface for testing, it just -runs a few various test operations such as attempting to view/create a -test file in the iPhone, but is mainly a developer tool. - - == Who/what/where? == wiki: diff --git a/include/libiphone/libiphone.h b/include/libiphone/libiphone.h index 6197923..9823bed 100644 --- a/include/libiphone/libiphone.h +++ b/include/libiphone/libiphone.h @@ -53,10 +53,10 @@ extern "C" { typedef int16_t iphone_error_t; typedef enum { - IPHONE_AFC_FILE_READ = 0x00000002, // seems to be able to read and write files - IPHONE_AFC_FILE_WRITE = 0x00000003, // writes and creates a file, blanks it out, etc. - IPHONE_AFC_FILE_RW = 0x00000005, // seems to do the same as 2. Might even create the file. - IPHONE_AFC_FILE_OP4 = 0x00000004, // no idea -- appears to be "write" -- clears file beforehand like 3 + IPHONE_AFC_FILE_READ = 0x00000001, // seems to be able to read and write files + IPHONE_AFC_FILE_WRITE = 0x00000002, // writes and creates a file, blanks it out, etc. + IPHONE_AFC_FILE_RW = 0x00000003, // seems to do the same as 2. Might even create the file. + IPHONE_AFC_FILE_CREAT = 0x00000004, // no idea -- appears to be "write" -- clears file beforehand like 3 IPHONE_AFC_FILE_OP6 = 0x00000006, // no idea yet -- appears to be the same as 5. IPHONE_AFC_FILE_OP1 = 0x00000001, // no idea juuust yet... probably read. IPHONE_AFC_FILE_OP0 = 0x00000000, @@ -97,6 +97,7 @@ iphone_error_t iphone_free_device ( iphone_device_t device ); //lockdownd related functions +iphone_error_t lockdownd_get_device_uid(iphone_lckd_client_t control, char **uid); iphone_error_t iphone_lckd_new_client ( iphone_device_t device, iphone_lckd_client_t *client ); iphone_error_t iphone_lckd_free_client( iphone_lckd_client_t client ); @@ -227,7 +227,7 @@ static int receive_AFC_data(iphone_afc_client_t client, char **dump_here) iphone_mux_recv(client->connection, buffer, sizeof(AFCPacket) * 4, &bytes); if (bytes <= 0) { free(buffer); - fprintf(stderr, "Just didn't get enough.\n"); + log_debug_msg("Just didn't get enough.\n"); *dump_here = NULL; return -1; } diff --git a/src/Makefile.am b/src/Makefile.am index 2e92fd1..1b97f45 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ INCLUDES = -I$(top_srcdir)/include -AM_CFLAGS = $(libxml2_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(libplist_CFLAGS) -g +AM_CFLAGS = $(libxml2_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(libplist_CFLAGS) -g -Wall AM_LDFLAGS = $(libxml2_LIBS) $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) $(libplist_LIBS) bin_PROGRAMS = libiphone-initconf diff --git a/src/iphone.c b/src/iphone.c index 1f68180..6eb56f7 100644 --- a/src/iphone.c +++ b/src/iphone.c @@ -38,6 +38,8 @@ static void iphone_config_usb_device(iphone_device_t phone) { int ret; + int bytes; + unsigned char buf[512]; log_debug_msg("setting configuration... "); ret = usb_set_configuration(phone->device, 3); @@ -70,6 +72,14 @@ static void iphone_config_usb_device(iphone_device_t phone) } else { log_debug_msg("done.\n"); } + + do { + bytes = usb_bulk_read(phone->device, BULKIN, (void *) &buf, 512, 800); + if (bytes > 0) { + log_debug_msg("iphone_config_usb_device: initial read returned %d bytes of data.\n", bytes); + log_debug_buffer(buf, bytes); + } + } while (bytes > 0); } /** @@ -151,7 +161,7 @@ static iphone_error_t iphone_get_specific_device(unsigned int bus_n, int dev_n, // Check for correct version if (ntohl(version->major) == 1 && ntohl(version->minor) == 0) { // We're all ready to roll. - fprintf(stderr, "get_iPhone() success\n"); + log_debug_msg("get_iPhone() success\n"); free(version); *device = phone; return IPHONE_E_SUCCESS; @@ -219,12 +229,14 @@ iphone_error_t iphone_free_device(iphone_device_t device) int bytes; unsigned char buf[512]; - // read final package - bytes = usb_bulk_read(device->device, BULKIN, (void *) &buf, 512, 1000); - if (bytes > 0) { - log_debug_msg("iphone_free_device: final read returned\n"); - log_debug_buffer(buf, bytes); - } + // read final package(s) + do { + bytes = usb_bulk_read(device->device, BULKIN, (void *) &buf, 512, 800); + if (bytes > 0) { + log_debug_msg("iphone_free_device: final read returned\n"); + log_debug_buffer(buf, bytes); + } + } while (bytes > 0); if (device->buffer) { free(device->buffer); diff --git a/src/lockdown.c b/src/lockdown.c index b83b8cf..a02e6a8 100644 --- a/src/lockdown.c +++ b/src/lockdown.c @@ -77,7 +77,6 @@ static void iphone_lckd_stop_session(iphone_lckd_client_t control) if (!control) return; //IPHONE_E_INVALID_ARG; - int bytes = 0, i = 0; iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; plist_t dict = plist_new_dict(); @@ -128,7 +127,6 @@ static void iphone_lckd_stop_session(iphone_lckd_client_t control) return; // ret; } - /** * Shuts down the SSL session by first calling iphone_lckd_stop_session * to cleanly close the lockdownd communication session, and then @@ -159,7 +157,6 @@ static void iphone_lckd_stop_SSL_session(iphone_lckd_client_t client) return; } - /** Closes the lockdownd client and does the necessary housekeeping. * * @param control The lockdown client @@ -471,7 +468,7 @@ iphone_error_t iphone_lckd_new_client(iphone_device_t device, iphone_lckd_client iphone_lckd_client_t client_loc = new_lockdownd_client(device); if (IPHONE_E_SUCCESS != lockdownd_hello(client_loc)) { - fprintf(stderr, "Hello failed in the lockdownd client.\n"); + log_debug_msg("Hello failed in the lockdownd client.\n"); ret = IPHONE_E_NOT_ENOUGH_DATA; } @@ -479,12 +476,12 @@ iphone_error_t iphone_lckd_new_client(iphone_device_t device, iphone_lckd_client char *uid = NULL; ret = lockdownd_get_device_uid(client_loc, &uid); if (IPHONE_E_SUCCESS != ret) { - fprintf(stderr, "Device refused to send uid.\n"); + log_debug_msg("Device refused to send uid.\n"); } host_id = get_host_id(); if (IPHONE_E_SUCCESS == ret && !host_id) { - fprintf(stderr, "No HostID found, run libiphone-initconf.\n"); + log_debug_msg("No HostID found, run libiphone-initconf.\n"); ret = IPHONE_E_INVALID_CONF; } @@ -499,7 +496,7 @@ iphone_error_t iphone_lckd_new_client(iphone_device_t device, iphone_lckd_client ret = lockdownd_start_SSL_session(client_loc, host_id); if (IPHONE_E_SUCCESS != ret) { ret = IPHONE_E_SSL_ERROR; - fprintf(stderr, "SSL Session opening failed.\n"); + log_debug_msg("SSL Session opening failed.\n"); } if (host_id) { @@ -532,7 +529,7 @@ iphone_error_t lockdownd_pair_device(iphone_lckd_client_t control, char *uid, ch ret = lockdownd_get_device_public_key(control, &public_key); if (ret != IPHONE_E_SUCCESS) { - fprintf(stderr, "Device refused to send public key.\n"); + log_debug_msg("Device refused to send public key.\n"); return ret; } @@ -804,8 +801,7 @@ iphone_error_t lockdownd_gen_pair_cert(gnutls_datum_t public_key, gnutls_datum_t iphone_error_t lockdownd_start_SSL_session(iphone_lckd_client_t control, const char *HostID) { plist_t dict = NULL; - char *XML_content = NULL; - uint32_t length = 0, bytes = 0, return_me = 0; + uint32_t return_me = 0; iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; control->session_id[0] = '\0'; diff --git a/src/lockdown.h b/src/lockdown.h index cdc46b8..2f2a4b9 100644 --- a/src/lockdown.h +++ b/src/lockdown.h @@ -42,9 +42,10 @@ struct iphone_lckd_client_int { iphone_lckd_client_t new_lockdownd_client(iphone_device_t phone); iphone_error_t lockdownd_hello(iphone_lckd_client_t control); + iphone_error_t lockdownd_generic_get_value(iphone_lckd_client_t control, const char *req_key, char *req_string, gnutls_datum_t * value); -iphone_error_t lockdownd_get_device_uid(iphone_lckd_client_t control, char **uid); + iphone_error_t lockdownd_get_device_public_key(iphone_lckd_client_t control, gnutls_datum_t * public_key); iphone_error_t lockdownd_gen_pair_cert(gnutls_datum_t public_key, gnutls_datum_t * device_cert, diff --git a/src/utils.c b/src/utils.c index 988cb03..5b0872d 100644 --- a/src/utils.c +++ b/src/utils.c @@ -66,7 +66,6 @@ void log_debug_msg(const char *format, ...) void log_dbg_msg(uint16_t id, const char *format, ...) { #ifndef STRIP_DEBUG_CODE - if (id & dbg_mask) { va_list args; /* run the real fprintf */ |