From 8719f4fcc1685a320e648166cf6720c3e33f0434 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 30 Apr 2019 20:46:17 +0200 Subject: [PATCH] Make gnurl and curl mutually exclusive. This prevents issues when both curl and gnurl are available, but one of them is outdated. To get curl.h, we also now just include gnunet_curl_lib.h instead of writing the preprocessor conditionals manually. Fixes #5707 --- configure.ac | 50 +++++++------------- src/curl/curl.c | 5 -- src/gns/gnunet-gns-proxy.c | 7 +-- src/gns/test_gns_proxy.c | 7 +-- src/hostlist/gnunet-daemon-hostlist_client.c | 7 +-- src/include/gnunet_curl_lib.h | 4 +- src/pt/test_gns_vpn.c | 7 +-- src/pt/test_gnunet_vpn.c | 7 +-- src/transport/plugin_transport_http.h | 7 +-- src/transport/plugin_transport_http_client.c | 7 +-- 10 files changed, 33 insertions(+), 75 deletions(-) diff --git a/configure.ac b/configure.ac index a9845d202..e00b8ae1b 100644 --- a/configure.ac +++ b/configure.ac @@ -763,14 +763,6 @@ fi # libgnurl LIBGNURL_CHECK_CONFIG(,7.34.0,gnurl=1,gnurl=0) -if test "$gnurl" = 1 -then - AM_CONDITIONAL(HAVE_LIBGNURL, true) - AC_DEFINE([HAVE_LIBGNURL],[1],[Have libgnurl]) -else - AM_CONDITIONAL(HAVE_LIBGNURL, false) - AC_DEFINE([HAVE_LIBGNURL],[0],[Lacking libgnurl]) -fi SAVE_CPPFLAGS=$CPPFLAGS CPPFLAGS="$LIBGNURL_CPPFLAGS $LIBCURL_CPPFLAGS $CPPFLAGS" @@ -780,38 +772,30 @@ LIBS="$LIBGNURL $LIBCURL $LIBS" LIBCURL_CHECK_CONFIG(,7.34.0,[curl=true],[curl=false]) if test "x$curl" = xtrue then - - AC_CHECK_HEADERS([curl/curl.h], + AC_CHECK_HEADER([curl/curl.h], AC_CHECK_DECLS(CURLINFO_TLS_SESSION,[curl=true],[curl=false],[[#include ]]), [curl=false]) - AC_CHECK_HEADERS([gnurl/curl.h], - AC_CHECK_DECLS(CURLINFO_TLS_SESSION,[curl=true],,[[#include ]])) # need libcurl-gnutls.so, everything else is not acceptable AC_CHECK_LIB([curl-gnutls],[curl_easy_getinfo],,[curl=false]) # cURL must support CURLINFO_TLS_SESSION, version >= 7.34 fi -# Check for curl/curl.h and gnurl/curl.h so we can use #ifdef -# HAVE_CURL_CURL_H later (the above LIBCURL_CHECK_CONFIG accepted -# *either* header set). -AC_CHECK_HEADERS([curl/curl.h],, - curl=false - AC_CHECK_HEADERS([gnurl/curl.h],, - gnurl=false)) - - - -if test x$curl = xfalse -then - AM_CONDITIONAL(HAVE_LIBCURL, false) -if test "$gnurl" = 0 -then - AC_MSG_WARN([ERROR: GNUnet requires libcurl-gnutls or gnurl >= 7.34]) -fi -else - AM_CONDITIONAL(HAVE_LIBCURL, true) - AC_DEFINE([HAVE_LIBCURL],[1],[Have CURL]) -fi +# libcurl and libgnurl should be mutually exclusive +AS_IF([test "$gnurl" = 1], + [AM_CONDITIONAL(HAVE_LIBGNURL, true) + AC_DEFINE([HAVE_LIBGNURL],[1],[Have libgnurl]) + AM_CONDITIONAL(HAVE_LIBCURL, false) + AC_DEFINE([HAVE_LIBCURL],[0],[Lacking libcurl])], + [AS_IF([test "$curl" = true], + [AM_CONDITIONAL(HAVE_LIBGNURL, false) + AC_DEFINE([HAVE_LIBGNURL],[0],[Lacking libgnurl]) + AM_CONDITIONAL(HAVE_LIBCURL, true) + AC_DEFINE([HAVE_LIBCURL],[1],[Have libcurl])], + [AC_MSG_WARN([ERROR: GNUnet requires libcurl-gnutls or gnurl >= 7.34]) + AM_CONDITIONAL(HAVE_LIBGNURL, false) + AC_DEFINE([HAVE_LIBGNURL],[0],[Lacking libgnurl]) + AM_CONDITIONAL(HAVE_LIBCURL, false) + AC_DEFINE([HAVE_LIBCURL],[0],[Lacking libcurl])])]) AC_SEARCH_LIBS(__atomic_load_8, atomic, [have_libatomic=1 AC_DEFINE(HAVE_LIBATOMIC,1,[external libatomic])]) AM_CONDITIONAL(HAVE_LIBATOMIC, [test "$have_libatomic" = 1]) diff --git a/src/curl/curl.c b/src/curl/curl.c index 10475fe2e..5e1c216ab 100644 --- a/src/curl/curl.c +++ b/src/curl/curl.c @@ -24,11 +24,6 @@ * @author Christian Grothoff */ #include "platform.h" -#if HAVE_CURL_CURL_H -#include -#elif HAVE_GNURL_CURL_H -#include -#endif #include #include "gnunet_curl_lib.h" diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index bae222499..eb8115026 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c @@ -29,11 +29,8 @@ */ #include "platform.h" #include -#if HAVE_CURL_CURL_H -#include -#elif HAVE_GNURL_CURL_H -#include -#endif +/* Just included for the right curl.h */ +#include "gnunet_curl_lib.h" #include #include #include diff --git a/src/gns/test_gns_proxy.c b/src/gns/test_gns_proxy.c index 2a7f8104b..053f5f898 100644 --- a/src/gns/test_gns_proxy.c +++ b/src/gns/test_gns_proxy.c @@ -24,11 +24,8 @@ * @author Martin Schanzenbach */ #include "platform.h" -#if HAVE_CURL_CURL_H -#include -#elif HAVE_GNURL_CURL_H -#include -#endif +/* Just included for the right curl.h */ +#include "gnunet_curl_lib.h" #include #include "gnunet_util_lib.h" #include "gnutls/x509.h" diff --git a/src/hostlist/gnunet-daemon-hostlist_client.c b/src/hostlist/gnunet-daemon-hostlist_client.c index f15cda2f3..539760966 100644 --- a/src/hostlist/gnunet-daemon-hostlist_client.c +++ b/src/hostlist/gnunet-daemon-hostlist_client.c @@ -30,11 +30,8 @@ #include "gnunet_transport_service.h" #include "gnunet_peerinfo_service.h" #include "gnunet-daemon-hostlist.h" -#if HAVE_CURL_CURL_H -#include -#elif HAVE_GNURL_CURL_H -#include -#endif +/* Just included for the right curl.h */ +#include "gnunet_curl_lib.h" diff --git a/src/include/gnunet_curl_lib.h b/src/include/gnunet_curl_lib.h index 0cbef9c73..86cb54f6b 100644 --- a/src/include/gnunet_curl_lib.h +++ b/src/include/gnunet_curl_lib.h @@ -29,9 +29,9 @@ */ #ifndef GNUNET_CURL_LIB_H #define GNUNET_CURL_LIB_H -#if HAVE_CURL_CURL_H +#if HAVE_LIBCURL #include -#elif HAVE_GNURL_CURL_H +#elif HAVE_LIBGNURL #include #else #error "needs curl or gnurl" diff --git a/src/pt/test_gns_vpn.c b/src/pt/test_gns_vpn.c index 069277a00..90405fe37 100644 --- a/src/pt/test_gns_vpn.c +++ b/src/pt/test_gns_vpn.c @@ -37,11 +37,8 @@ * you should get a warning that gnunet-dns2gns failed to 'bind'. */ #include "platform.h" -#if HAVE_CURL_CURL_H -#include -#elif HAVE_GNURL_CURL_H -#include -#endif +/* Just included for the right curl.h */ +#include "gnunet_curl_lib.h" #include #include "gnunet_identity_service.h" #include "gnunet_namestore_service.h" diff --git a/src/pt/test_gnunet_vpn.c b/src/pt/test_gnunet_vpn.c index 0afd0f94b..7cc77fe24 100644 --- a/src/pt/test_gnunet_vpn.c +++ b/src/pt/test_gnunet_vpn.c @@ -24,11 +24,8 @@ * @author Christian Grothoff */ #include "platform.h" -#if HAVE_CURL_CURL_H -#include -#elif HAVE_GNURL_CURL_H -#include -#endif +/* Just included for the right curl.h */ +#include "gnunet_curl_lib.h" #include #include "gnunet_vpn_service.h" #include "gnunet_testing_lib.h" diff --git a/src/transport/plugin_transport_http.h b/src/transport/plugin_transport_http.h index 6867d3b9d..b6ada8f86 100644 --- a/src/transport/plugin_transport_http.h +++ b/src/transport/plugin_transport_http.h @@ -41,11 +41,8 @@ #include "gnunet_os_lib.h" #include "gnunet_nat_lib.h" #include "microhttpd.h" -#if HAVE_CURL_CURL_H -#include -#elif HAVE_GNURL_CURL_H -#include -#endif +/* Just included for the right curl.h */ +#include "gnunet_curl_lib.h" #define DEBUG_HTTP GNUNET_EXTRA_LOGGING diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index 3c8dc21e5..c4d70d4c3 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c @@ -49,11 +49,8 @@ #include "gnunet_protocols.h" #include "gnunet_transport_plugin.h" #include "plugin_transport_http_common.h" -#if HAVE_CURL_CURL_H -#include -#elif HAVE_GNURL_CURL_H -#include -#endif +/* Just included for the right curl.h */ +#include "gnunet_curl_lib.h" #define LOG(kind,...) GNUNET_log_from(kind, PLUGIN_NAME, __VA_ARGS__) -- 2.25.1