diff --git a/src/libexchangemapi/Makefile.am b/src/libexchangemapi/Makefile.am index 1e0e75d..89dccce 100644 --- a/src/libexchangemapi/Makefile.am +++ b/src/libexchangemapi/Makefile.am @@ -2,6 +2,7 @@ AM_CPPFLAGS = \ -DG_LOG_DOMAIN=\"libexchangemapi\" \ -DMAPI_DATADIR=\""$(mapidatadir)"\" \ -DLIBMAPI_LDIF_DIR=\""$(libmapi_ldif_dir)"\" \ + -DLIBMAPI_LIBS=\""$(LIBMAPI_LIBS)"\" \ -I$(top_srcdir) \ $(EVOLUTION_DATA_SERVER_CFLAGS) \ $(LIBEDATASERVER_CFLAGS) \ diff --git a/src/libexchangemapi/exchange-mapi-connection.c b/src/libexchangemapi/exchange-mapi-connection.c index c285365..81cd6ae 100644 --- a/src/libexchangemapi/exchange-mapi-connection.c +++ b/src/libexchangemapi/exchange-mapi-connection.c @@ -26,6 +26,7 @@ #include #endif +#include #include #include #include @@ -3578,6 +3579,38 @@ mapi_debug_logger_muted (const gchar * domain, GLogLevelFlags level, const gchar /*Nothing here. Just a dummy function*/ } +/* this is to workaround dynamic symbol lookup bug, + entered as https://bugzilla.samba.org/show_bug.cgi?id=7654 +*/ +static void +preload_libmapi_libs (void) +{ + #ifdef LIBMAPI_LIBS + gchar **tmp; + + tmp = g_strsplit (LIBMAPI_LIBS, " ", -1); + if (tmp) { + gint i; + + for (i = 0; tmp[i]; i++) { + if (g_str_has_prefix (tmp[i], "-l")) { + gchar *libname = g_strdup_printf ("lib%s.so.0", tmp[i] + 2); + + printf ("%s: preloading '%s'\n", __FUNCTION__, libname); + if (!dlopen (libname, RTLD_NOW | RTLD_DEEPBIND)) { + g_printerr ("exchange-mapi: Failed to preload '%s'\n", libname); + } + + g_free (libname); + } + } + + g_strfreev (tmp); + } + + #endif +} + static gboolean ensure_mapi_init_called (GError **perror) { @@ -3593,6 +3626,8 @@ ensure_mapi_init_called (GError **perror) return TRUE; } + preload_libmapi_libs (); + user_data_dir = e_get_user_data_dir (); profpath = g_build_filename (user_data_dir, DEFAULT_PROF_NAME, NULL);