From 752e5965b197d70a9125dc3319a8c5e5673a8f8b Mon Sep 17 00:00:00 2001 From: Stefan Gehn Date: Sat, 27 Aug 2011 16:32:31 +0200 Subject: [PATCH] Only use Libgcrypt for GnuTLS < 2.12 Only initialize Libgcrypt threading functions on GnuTLS < 2.12 which does not do this automatically. Also drop explicit linking against Libgcrypt on newer GnuTLS version. This should allow GKrellM to work with a GnuTLS that uses Nettle instead of Libgcrypt as its cryptographic backend. --- Changelog | 3 +++ src/configure | 7 ++++++- src/mail.c | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index c553b88..ab5172c 100644 --- a/Changelog +++ b/Changelog @@ -16,6 +16,9 @@ GKrellM Changelog * Bugfixes o Store lockfiles under /var/lock/gkrellm-UID directories to make lockfiles work for multiple users. + * Only link against and initialize Libgcrypt when building with + GnuTLS < 2.12. This allows using GKrellM with GnuTLS versions built + against Nettle instead of Libgcrypt. 2.3.5 - Thu Oct 7, 2010 ------------------------ diff --git a/src/configure b/src/configure index bfe29c6..620f1e9 100755 --- a/src/configure +++ b/src/configure @@ -96,7 +96,12 @@ echo -n "Checking for gnutls... " echo "Checking for gnutls... " 1>& 5 GNUTLS_INCLUDE="$(pkg-config gnutls --cflags 2>& 5 || true)" -GNUTLS_LIBS="$(pkg-config gnutls --libs 2>& 5 || true) -lgnutls-openssl -lgcrypt" +GNUTLS_LIBS="$(pkg-config gnutls --libs 2>& 5 || true) -lgnutls-openssl" + +# GnuTLS >= 2.12 does not need explicit gcrypt linking anymore +if $(pkg-config --max-version=2.11.99 gnutls 2>& 5 || false); then + GNUTLS_LIBS="$GNUTLS_LIBS -lgcrypt" +fi cat << EOF > test.c #include diff --git a/src/mail.c b/src/mail.c index a4e04bf..3ae5227 100644 --- a/src/mail.c +++ b/src/mail.c @@ -51,6 +51,9 @@ #define MD5Update MD5_Update #define MD5Final MD5_Final +#if GNUTLS_VERSION_NUMBER <= 0x020b00 +/* gcrypt mutex setup is only needed for GnuTLS < 2.12 */ + static int gk_gcry_glib_mutex_init (void **priv) { GMutex *lock = g_mutex_new(); if (!lock) @@ -90,6 +93,8 @@ static struct gcry_thread_cbs gk_gcry_threads_glib = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; +#endif + #else #if defined(HAVE_SSL) @@ -4340,7 +4345,10 @@ gkrellm_init_mail_monitor(void) _GK.decal_mail_delay = 1; #ifdef HAVE_GNUTLS +#if GNUTLS_VERSION_NUMBER <= 0x020b00 + /* gcrypt mutex setup, only needed for GnuTLS < 2.12 */ gcry_control (GCRYCTL_SET_THREAD_CBS, &gk_gcry_threads_glib); +#endif gnutls_global_init(); SSL_load_error_strings(); SSL_library_init();