diff --git a/Changes b/Changes index 925afe449..2c74e46c9 100644 --- a/Changes +++ b/Changes @@ -1906,3 +1906,12 @@ UHNAMES may increase the time of the nick list being loaded from 1 to 4 seconds when joining several channels with more than 1000 users. As this problem is only present on some networks, we keep UHNAMES enabled by default. +- Added patch from ohnobinki (#0003888), only slightly edited, which improves + curl detection, added checks to see if curl actually works (print out a + clear curl error during configure, instead of getting an error during + 'make'), and we now error when using --enable-libcurl without + --with-system-cares if the system curl depends on c-ares. This is because + this can cause ABI incompatability between curl's c-ares and our c-ares, + which leads to odd issues such as: + Could not resolve host: www.example.net (Successful completion) + And possibly other weird issues, perhaps even crashes. diff --git a/Config b/Config index da7127706..df1248be7 100755 --- a/Config +++ b/Config @@ -692,6 +692,14 @@ if [ "$REMOTEINC" = "1" ] ; then INSTALLCURL="0" if [ "$CURLDIR" = "" ]; then + # There is no reason to support this: + if [ -d "/usr/local/include/curl" ]; then + CURLDIR="/usr/local" + fi + # Zeroeth, let's act SANE + if [ -d "/usr/include/curl" ]; then + CURLDIR="/usr" + fi # First, let's make shell admins happy... if [ -d "/usr/share/unreal-curl" ]; then CURLDIR="/usr/share/unreal-curl" diff --git a/autoconf/aclocal.m4 b/autoconf/aclocal.m4 index 081fe650c..901e257fe 100644 --- a/autoconf/aclocal.m4 +++ b/autoconf/aclocal.m4 @@ -50,34 +50,107 @@ AC_DEFUN(CHECK_LIBCURL, [ AC_ARG_ENABLE(libcurl, [AC_HELP_STRING([--enable-libcurl=DIR],[enable libcurl (remote include) support])], + [enable_curl=$enableval], + [enable_curl=no]) + + AS_IF([test "x$enable_curl" != "xno"], [ - CURLCFLAG=`$enableval/bin/curl-config --cflags` - CURLLIBS=`$enableval/bin/curl-config --libs` + dnl sane, default directory for Operating System-managed libcURL + dnl (when --enable-libcurl is passed without any arguments). On + dnl systems with stuff in /usr/local, /usr/local/bin should already + dnl be in PATH. On sane systems, this will invoke the curl-config + dnl installed by the package manager. + CURLCONFIG="curl-config" + AS_IF([test "x$enable_curl" != "xyes"], + [CURLCONFIG="$enable_curl/bin/curl-config"]) + + AC_MSG_CHECKING([$CURLCONFIG]) + AS_IF([$CURLCONFIG --version 2>/dev/null >/dev/null], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_FAILURE([Could not find curl-config, try editing --enable-libcurl])]) + + CURLCFLAG="`$CURLCONFIG --cflags`" + CURLLIBS="`$CURLCONFIG --libs`" + + CURLUSESCARES="`echo $CURLLIBS|grep c-ares|wc -l`" + AS_IF([test "$CURLUSESCARES" = "0"], + [AC_MSG_WARN([cURL is compiled without c-ares support. Your IRCd will possibly stall when REHASHing!])]) + + dnl sanity warnings + AS_IF([test -z "${CURLLIBS}"], + [AC_MSG_WARN([CURLLIBS is empty, that probably means that I could not find $enableval/bin/curl-config])]) dnl Ok this is ugly, basically we need to strip the version of c-ares that curl uses dnl because we want to use our own version (which is hopefully fully binary dnl compatible with the curl one as well). dnl Therefore we need to strip the cares libs in a weird way... dnl If anyone can come up with something better and still portable (no awk!?) - dnl then let us know. - if test "x`echo $CURLLIBS |grep ares`" != x ; then + dnl then let us know. -- Syzop + dnl + dnl It is dangerous to mix and match cURL with potentially ABI-incompatible versions of + dnl c-ares, just use --with-system-cares. + dnl Thus, make sure to use --with-system-cares when using system-cURL. If the user + dnl wants bundled c-ares + system libcURL, then we should filter out c-ares + dnl flags. _Only_ in that case should we mess with the flags. -- ohnobinki + + AS_IF([test "x$with_system_cares" = "xno" && test "x$HOME/curl" != "x$enable_curl" && test "x/usr/share/unreal-curl" != "x$enable_curl" && test "$CURLUSESCARES" != "0" ], + [ + AC_MSG_ERROR([[ + + You have decided to build unrealIRCd with libcURL (remote includes) support. + However, you have disabled system-installed c-ares support (--with-system-cares). + Because UnrealIRCd will use a bundled copy of c-ares which may be incompatible + with the system-installed libcURL, this is a bad idea which may result in error + messages looking like: + + \`\`[error] unrealircd.conf:9: include: error downloading '(http://example.net/ex.conf)': Could not resolve host: example.net (Successful completion)'' + + Or UnrealIRCd might even crash. + + Please build UnrealIRCd with --with-system-cares when enabling --enable-libcurl +]]) + ]) + + AS_IF([test "x`echo $CURLLIBS |grep ares`" != x && test "x$with_system_cares" = "xno"], + [ dnl Attempt one: Linux sed XCURLLIBS="`echo "$CURLLIBS"|sed -r 's/(@<:@^ @:>@+ @<:@^ @:>@+ )(@<:@^ @:>@+ @<:@^ @:>@+ )(.+)/\1\3/g' 2>/dev/null`" - if test x"$XCURLLIBS" = x; then + AS_IF([test x"$XCURLLIBS" = x], + [ dnl Attempt two: FreeBSD (and others?) sed XCURLLIBS="`echo "$CURLLIBS"|sed -E 's/(@<:@^ @:>@+ @<:@^ @:>@+ )(@<:@^ @:>@+ @<:@^ @:>@+ )(.+)/\1\3/g' 2>/dev/null`" - if test x"$XCURLLIBS" = x; then + AS_IF([test x"$XCURLLIBS" = x], + [ AC_MSG_ERROR([sed appears to be broken. It is needed for a remote includes compile hack.]) - fi - fi + ]) + ]) CURLLIBS="$XCURLLIBS" - fi + ]) + dnl Make sure that linking against cURL works rather than letting the user + dnl find out after compiling most of his program. ~ohnobinki IRCDLIBS="$IRCDLIBS $CURLLIBS" CFLAGS="$CFLAGS $CURLCFLAG -DUSE_LIBCURL" + + AC_MSG_CHECKING([curl_easy_init() in $CURLLIBS]) + LIBS_SAVEDA="$LIBS" + LIBS="$IRCDLIBS" + AC_LINK_IFELSE( + [ + AC_LANG_PROGRAM( + [[#include ]], + [[CURL *curl = curl_easy_init();]]) + ], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_FAILURE([You asked for libcURL (remote includes) support, but it can't be found at $enable_curl]) dnl for emac's sh-mode ]) + ]) + LIBS="$LIBS_SAVEDA" + URL="url.o" AC_SUBST(URL) - ]) + ]) dnl AS_IF(enable_curl) ]) dnl the following 2 macros are based on CHECK_SSL by Mark Ethan Trostler diff --git a/configure b/configure index 05e8234e3..38a9cf3ae 100755 --- a/configure +++ b/configure @@ -12468,30 +12468,175 @@ fi # Check whether --enable-libcurl was given. if test "${enable_libcurl+set}" = set; then - enableval=$enable_libcurl; - CURLCFLAG=`$enableval/bin/curl-config --cflags` - CURLLIBS=`$enableval/bin/curl-config --libs` + enableval=$enable_libcurl; enable_curl=$enableval +else + enable_curl=no +fi + + + if test "x$enable_curl" != "xno"; then + + CURLCONFIG="curl-config" + if test "x$enable_curl" != "xyes"; then + CURLCONFIG="$enable_curl/bin/curl-config" +fi + + + { echo "$as_me:$LINENO: checking $CURLCONFIG" >&5 +echo $ECHO_N "checking $CURLCONFIG... $ECHO_C" >&6; } + if $CURLCONFIG --version 2>/dev/null >/dev/null; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + { { echo "$as_me:$LINENO: error: Could not find curl-config, try editing --enable-libcurl +See \`config.log' for more details." >&5 +echo "$as_me: error: Could not find curl-config, try editing --enable-libcurl +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + + + CURLCFLAG="`$CURLCONFIG --cflags`" + CURLLIBS="`$CURLCONFIG --libs`" + + CURLUSESCARES="`echo $CURLLIBS|grep c-ares|wc -l`" + if test "$CURLUSESCARES" = "0"; then + { echo "$as_me:$LINENO: WARNING: cURL is compiled without c-ares support. Your IRCd will possibly stall when REHASHing!" >&5 +echo "$as_me: WARNING: cURL is compiled without c-ares support. Your IRCd will possibly stall when REHASHing!" >&2;} +fi + + + if test -z "${CURLLIBS}"; then + { echo "$as_me:$LINENO: WARNING: CURLLIBS is empty, that probably means that I could not find $enableval/bin/curl-config" >&5 +echo "$as_me: WARNING: CURLLIBS is empty, that probably means that I could not find $enableval/bin/curl-config" >&2;} +fi + + + + if test "x$with_system_cares" = "xno" && test "x$HOME/curl" != "x$enable_curl" && test "x/usr/share/unreal-curl" != "x$enable_curl" && test "$CURLUSESCARES" != "0" ; then + + { { echo "$as_me:$LINENO: error: + + You have decided to build unrealIRCd with libcURL (remote includes) support. + However, you have disabled system-installed c-ares support (--with-system-cares). + Because UnrealIRCd will use a bundled copy of c-ares which may be incompatible + with the system-installed libcURL, this is a bad idea which may result in error + messages looking like: + + \`\`[error] unrealircd.conf:9: include: error downloading '(http://example.net/ex.conf)': Could not resolve host: example.net (Successful completion)'' + + Or UnrealIRCd might even crash. + + Please build UnrealIRCd with --with-system-cares when enabling --enable-libcurl +" >&5 +echo "$as_me: error: + + You have decided to build unrealIRCd with libcURL (remote includes) support. + However, you have disabled system-installed c-ares support (--with-system-cares). + Because UnrealIRCd will use a bundled copy of c-ares which may be incompatible + with the system-installed libcURL, this is a bad idea which may result in error + messages looking like: + + \`\`[error] unrealircd.conf:9: include: error downloading '(http://example.net/ex.conf)': Could not resolve host: example.net (Successful completion)'' + + Or UnrealIRCd might even crash. + + Please build UnrealIRCd with --with-system-cares when enabling --enable-libcurl +" >&2;} + { (exit 1); exit 1; }; } + +fi + + + if test "x`echo $CURLLIBS |grep ares`" != x && test "x$with_system_cares" = "xno"; then - if test "x`echo $CURLLIBS |grep ares`" != x ; then XCURLLIBS="`echo "$CURLLIBS"|sed -r 's/([^ ]+ [^ ]+ )([^ ]+ [^ ]+ )(.+)/\1\3/g' 2>/dev/null`" if test x"$XCURLLIBS" = x; then + XCURLLIBS="`echo "$CURLLIBS"|sed -E 's/([^ ]+ [^ ]+ )([^ ]+ [^ ]+ )(.+)/\1\3/g' 2>/dev/null`" if test x"$XCURLLIBS" = x; then + { { echo "$as_me:$LINENO: error: sed appears to be broken. It is needed for a remote includes compile hack." >&5 echo "$as_me: error: sed appears to be broken. It is needed for a remote includes compile hack." >&2;} { (exit 1); exit 1; }; } - fi - fi - CURLLIBS="$XCURLLIBS" - fi - IRCDLIBS="$IRCDLIBS $CURLLIBS" - CFLAGS="$CFLAGS $CURLCFLAG -DUSE_LIBCURL" - URL="url.o" +fi fi + CURLLIBS="$XCURLLIBS" + +fi + + + IRCDLIBS="$IRCDLIBS $CURLLIBS" + CFLAGS="$CFLAGS $CURLCFLAG -DUSE_LIBCURL" + + { echo "$as_me:$LINENO: checking curl_easy_init() in $CURLLIBS" >&5 +echo $ECHO_N "checking curl_easy_init() in $CURLLIBS... $ECHO_C" >&6; } + LIBS_SAVEDA="$LIBS" + LIBS="$IRCDLIBS" + cat >conftest.$ac_ext <<_ACEOF + + /* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ +CURL *curl = curl_easy_init(); + ; + return 0; +} + +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + { { echo "$as_me:$LINENO: error: You asked for libcURL (remote includes) support, but it can't be found at $enable_curl +See \`config.log' for more details." >&5 +echo "$as_me: error: You asked for libcURL (remote includes) support, but it can't be found at $enable_curl +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + +fi + + LIBS="$LIBS_SAVEDA" + + URL="url.o" + # Check whether --enable-dynamic-linking was given. if test "${enable_dynamic_linking+set}" = set; then