diff -Nur telepathy-haze-0.8.0.old/configure.ac telepathy-haze-0.8.0/configure.ac --- telepathy-haze-0.8.0.old/configure.ac 2013-11-22 16:29:57.589038402 +0300 +++ telepathy-haze-0.8.0/configure.ac 2013-11-22 19:21:42.317009774 +0300 @@ -76,6 +76,7 @@ PKG_CHECK_MODULES(PURPLE,[purple >= 2.7]) PKG_CHECK_MODULES(TP_GLIB,[telepathy-glib >= 0.15.1]) PKG_CHECK_MODULES(GLIB,[glib-2.0 >= 2.22, gobject-2.0, gio-2.0]) +PKG_CHECK_MODULES(GIO,[gio-2.0]) PKG_CHECK_MODULES(DBUS_GLIB,[dbus-glib-1 >= 0.73]) dnl MIN_REQUIRED must stay to 2.30 because of GValueArray diff -Nur telepathy-haze-0.8.0.old/src/main.c telepathy-haze-0.8.0/src/main.c --- telepathy-haze-0.8.0.old/src/main.c 2013-11-22 16:29:57.592038425 +0300 +++ telepathy-haze-0.8.0/src/main.c 2013-11-22 19:20:33.604477142 +0300 @@ -31,6 +31,8 @@ #include #include +#include + #include #include #include @@ -175,6 +177,105 @@ } + +static void +copy_one_cert_dir (const gchar *source_root, + GFile *target_dir) +{ + gchar *source_path; + GFile *source_dir; + GFileEnumerator *contents; + GFileInfo *child_info; + GError *error = NULL; + + source_path = g_build_filename (source_root, "telepathy-haze", + "certificates", NULL); + source_dir = g_file_new_for_path (source_path); + + contents = g_file_enumerate_children (source_dir, + G_FILE_ATTRIBUTE_STANDARD_NAME, G_FILE_QUERY_INFO_NONE, NULL, &error); + + if (contents == NULL) + { + if (error->domain != G_IO_ERROR || error->code != G_IO_ERROR_NOT_FOUND) + DEBUG ("couldn't list %s (%s, %d, %s); skipping", source_path, + g_quark_to_string (error->domain), error->code, error->message); + + g_error_free (error); + goto finally; + } + + while ((child_info = g_file_enumerator_next_file (contents, NULL, &error))) + { + const gchar *child_name = g_file_info_get_name (child_info); + GFile *source_file = g_file_get_child (source_dir, child_name); + GFile *target_file = g_file_get_child (target_dir, child_name); + gboolean yay; + + yay = g_file_copy (source_file, target_file, 0, NULL, NULL, NULL, + &error); + + if (!yay) + { + DEBUG ("couldn't copy %s to %s: %s", g_file_get_basename + (source_file), g_file_get_basename (target_file), + error->message); + g_clear_error (&error); + } + + g_object_unref (source_file); + g_object_unref (target_file); + g_object_unref (child_info); + } + + g_object_unref (contents); + +finally: + g_object_unref (source_dir); + g_free (source_path); +} + + +/** + * seed_tls_peers: + * + * Adds known-trusted certificates from haze's data dirs to the temporary + * libpurple config directory. Thus, people can work around haze falling down + * a well if libpurple wants to ask the user to accept or decline a cert. + */ +static void +seed_tls_peers (void) +{ + const gchar * const *dirs = g_get_system_data_dirs (); + gchar *target_path; + GFile *target_dir; + int ret; + + target_path = g_build_filename (user_dir, "certificates", "x509", + "tls_peers", NULL); + ret = g_mkdir_with_parents (target_path, 0755); + DEBUG ("%s", target_path); + + if (ret != 0) + { + g_warning ("Couldn't mkdir -p %s: %s", target_path, g_strerror (errno)); + goto finally; + } + + target_dir = g_file_new_for_path (target_path); + + copy_one_cert_dir (g_get_user_data_dir (), target_dir); + + for (; *dirs != NULL; dirs++) + copy_one_cert_dir (*dirs, target_dir); + + g_object_unref (target_dir); + +finally: + g_free (target_path); +} + + static void init_libpurple (void) { @@ -202,6 +303,8 @@ purple_dbus_uninit (); #endif + seed_tls_peers (); + purple_set_blist(purple_blist_new()); purple_blist_load(); diff -Nur telepathy-haze-0.8.0.old/src/Makefile.am telepathy-haze-0.8.0/src/Makefile.am --- telepathy-haze-0.8.0.old/src/Makefile.am 2013-11-22 16:29:57.591038418 +0300 +++ telepathy-haze-0.8.0/src/Makefile.am 2013-11-22 19:22:25.103341446 +0300 @@ -65,6 +65,7 @@ @PURPLE_CFLAGS@ \ @TP_GLIB_CFLAGS@ \ @DBUS_GLIB_CFLAGS@ \ - @GLIB_CFLAGS@ + @GLIB_CFLAGS@ \ + @GIO_CFLAGS@ -AM_LDFLAGS = @PURPLE_LIBS@ @TP_GLIB_LIBS@ @DBUS_GLIB_LIBS@ @GLIB_LIBS@ +AM_LDFLAGS = @PURPLE_LIBS@ @TP_GLIB_LIBS@ @DBUS_GLIB_LIBS@ @GLIB_LIBS@ @GIO_LIBS@