diff options
| -rw-r--r-- | src/Makefile.am | 6 | ||||
| -rw-r--r-- | src/initconf.c | 33 | ||||
| -rw-r--r-- | src/lockdown.h | 2 |
3 files changed, 14 insertions, 27 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index dc32c04..674f19c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
| @@ -5,6 +5,6 @@ bin_PROGRAMS = iphoneclient ifuse libiphone-initconf | |||
| 5 | iphoneclient_SOURCES = usbmux.c main.c iphone.c plist.c lockdown.c AFC.c userpref.c | 5 | iphoneclient_SOURCES = usbmux.c main.c iphone.c plist.c lockdown.c AFC.c userpref.c |
| 6 | ifuse_SOURCES = ifuse.c usbmux.c iphone.c plist.c lockdown.c AFC.c userpref.c | 6 | ifuse_SOURCES = ifuse.c usbmux.c iphone.c plist.c lockdown.c AFC.c userpref.c |
| 7 | 7 | ||
| 8 | libiphone_initconf_SOURCES = initconf.c userpref.c | 8 | libiphone_initconf_SOURCES = initconf.c userpref.c lockdown.c plist.c usbmux.c iphone.c |
| 9 | libiphone_initconf_CFLAGS = $(libgthread2_CFLAGS) | 9 | libiphone_initconf_CFLAGS = $(libgthread2_CFLAGS) $(AM_CFLAGS) |
| 10 | libiphone_initconf_LDFLAGS = $(libgthread2_LIBS) | 10 | libiphone_initconf_LDFLAGS = $(libgthread2_LIBS) $(AM_LDFLAGS) |
diff --git a/src/initconf.c b/src/initconf.c index 8944ab4..b900f7f 100644 --- a/src/initconf.c +++ b/src/initconf.c | |||
| @@ -25,38 +25,23 @@ | |||
| 25 | #include <gnutls/gnutls.h> | 25 | #include <gnutls/gnutls.h> |
| 26 | #include <gnutls/x509.h> | 26 | #include <gnutls/x509.h> |
| 27 | #include <glib.h> | 27 | #include <glib.h> |
| 28 | |||
| 28 | #include "userpref.h" | 29 | #include "userpref.h" |
| 30 | #include "lockdown.h" | ||
| 29 | 31 | ||
| 30 | int debug = 1; | 32 | int debug = 1; |
| 31 | 33 | ||
| 32 | int get_rand(int min, int max) { | 34 | /** Generates a 2048 byte key, split into a function so that it can be run in a |
| 33 | int retval = (rand() % (max - min)) + min; | 35 | * thread. |
| 34 | return retval; | 36 | * |
| 35 | } | 37 | * @param key The pointer to the desired location of the new key. |
| 36 | 38 | */ | |
| 37 | char *lockdownd_generate_hostid() { | ||
| 38 | char *hostid = (char*)malloc(sizeof(char) * 37); // HostID's are just UUID's, and UUID's are 36 characters long | ||
| 39 | const char *chars = "ABCDEF0123456789"; | ||
| 40 | srand(time(NULL)); | ||
| 41 | int i = 0; | ||
| 42 | |||
| 43 | for (i = 0; i < 36; i++) { | ||
| 44 | if (i == 8 || i == 13 || i == 18 || i == 23) { | ||
| 45 | hostid[i] = '-'; | ||
| 46 | continue; | ||
| 47 | } else { | ||
| 48 | hostid[i] = chars[get_rand(0,16)]; | ||
| 49 | } | ||
| 50 | } | ||
| 51 | hostid[36] = '\0'; | ||
| 52 | return hostid; | ||
| 53 | } | ||
| 54 | |||
| 55 | void generate_key(gpointer key){ | 39 | void generate_key(gpointer key){ |
| 56 | gnutls_x509_privkey_generate(*((gnutls_x509_privkey_t*)key), GNUTLS_PK_RSA, 2048, 0); | 40 | gnutls_x509_privkey_generate(*((gnutls_x509_privkey_t*)key), GNUTLS_PK_RSA, 2048, 0); |
| 57 | g_thread_exit(0); | 41 | g_thread_exit(0); |
| 58 | } | 42 | } |
| 59 | 43 | /** Simple function that generates a spinner until the mutex is released. | |
| 44 | */ | ||
| 60 | void progress_bar(gpointer mutex){ | 45 | void progress_bar(gpointer mutex){ |
| 61 | const char *spinner = "|/-\\|/-\\"; | 46 | const char *spinner = "|/-\\|/-\\"; |
| 62 | int i = 0; | 47 | int i = 0; |
diff --git a/src/lockdown.h b/src/lockdown.h index 56c133d..6b27900 100644 --- a/src/lockdown.h +++ b/src/lockdown.h | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #ifndef LOCKDOWND_H | 22 | #ifndef LOCKDOWND_H |
| 23 | #define LOCKDOWND_H | 23 | #define LOCKDOWND_H |
| 24 | 24 | ||
| 25 | #include "usbmux.h" | ||
| 25 | #include "plist.h" | 26 | #include "plist.h" |
| 26 | 27 | ||
| 27 | #include <gnutls/gnutls.h> | 28 | #include <gnutls/gnutls.h> |
| @@ -36,6 +37,7 @@ typedef struct { | |||
| 36 | } lockdownd_client; | 37 | } lockdownd_client; |
| 37 | 38 | ||
| 38 | int lockdownd_init(iPhone *phone, lockdownd_client **control); | 39 | int lockdownd_init(iPhone *phone, lockdownd_client **control); |
| 40 | char *lockdownd_generate_hostid(); | ||
| 39 | 41 | ||
| 40 | lockdownd_client *new_lockdownd_client(iPhone *phone); | 42 | lockdownd_client *new_lockdownd_client(iPhone *phone); |
| 41 | int lockdownd_hello(lockdownd_client *control); | 43 | int lockdownd_hello(lockdownd_client *control); |
