]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
configure detect ssl get_compression_methods and ctime_r fix.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 25 Aug 2009 13:05:31 +0000 (13:05 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 25 Aug 2009 13:05:31 +0000 (13:05 +0000)
git-svn-id: file:///svn/unbound/trunk@1780 be551aaa-1e26-0410-a405-d3ace91eadb9

compat/ctime_r.c
config.h.in
configure
configure.ac
daemon/daemon.c
doc/Changelog

index 75454d7a393295e2cd42267a1e4e1cf58044eb0f..bdc4baf3d1edafaf66f7eaac0defc9dcfc30d7b5 100644 (file)
@@ -1,15 +1,39 @@
 /* taken from ldns 1.6.1 */
 #include "config.h"
-
 #ifdef HAVE_TIME_H
 #include <time.h>
 #endif
+#include "util/locks.h"
+
+/** the lock for ctime buffer */
+static lock_basic_t ctime_lock;
+/** has it been inited */
+static int ctime_r_init = 0;
+
+/** cleanup ctime_r on exit */
+static void
+ctime_r_cleanup(void)
+{
+       if(ctime_r_init) {
+               ctime_r_init = 0;
+               lock_basic_destroy(&ctime_lock);
+       }
+}
 
 char *ctime_r(const time_t *timep, char *buf)
 {
-       /* no thread safety. */
-       char* result = ctime(timep);
+       char* result;
+       if(!ctime_r_init) {
+               /* still small race where this init can be done twice,
+                * which is mostly harmless */
+               ctime_r_init = 1;
+               lock_basic_init(&ctime_lock);
+               atexit(&ctime_r_cleanup);
+       }
+       lock_basic_lock(&ctime_lock);
+       result = ctime(timep);
        if(buf && result)
                strcpy(buf, result);
+       lock_basic_unlock(&ctime_lock);
        return result;
 }
index 71c0be2881be483011d5d6035d0138a71ba23327..02962bac57a1e49d7298a20a1d8b8a20afcef0c6 100644 (file)
 /* Define to 1 if you have the `daemon' function. */
 #undef HAVE_DAEMON
 
+/* Define to 1 if you have the declaration of
+   `SSL_COMP_get_compression_methods', and to 0 if you don't. */
+#undef HAVE_DECL_SSL_COMP_GET_COMPRESSION_METHODS
+
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
@@ -765,6 +769,11 @@ struct tm *gmtime_r(const time_t *timep, struct tm *result);
 
 
 
+#ifndef HAVE_CTIME_R
+#define ctime_r unbound_ctime_r
+char *ctime_r(const time_t *timep, char *buf);
+#endif
+
 #if defined(HAVE_EVENT_H) && !defined(HAVE_EVENT_BASE_ONCE) && (defined(HAVE_PTHREAD) || defined(HAVE_SOLARIS_THREADS))
    /* using version of libevent that is not threadsafe. */
 #  define LIBEVENT_SIGNAL_PROBLEM 1
index 74c5f525e2508e9ab1424ca3016ae757f19ac83d..cd17c6850b6870a0537de10e3adf7ffe02d1df31 100755 (executable)
--- a/configure
+++ b/configure
@@ -17812,6 +17812,95 @@ _ACEOF
 fi
 done
 
+{ $as_echo "$as_me:$LINENO: checking whether SSL_COMP_get_compression_methods is declared" >&5
+$as_echo_n "checking whether SSL_COMP_get_compression_methods is declared... " >&6; }
+if test "${ac_cv_have_decl_SSL_COMP_get_compression_methods+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+$ac_includes_default
+#ifdef HAVE_OPENSSL_ERR_H
+#include <openssl/err.h>
+#endif
+
+#ifdef HAVE_OPENSSL_RAND_H
+#include <openssl/rand.h>
+#endif
+
+#ifdef HAVE_OPENSSL_CONF_H
+#include <openssl/conf.h>
+#endif
+
+#ifdef HAVE_OPENSSL_ENGINE_H
+#include <openssl/engine.h>
+#endif
+#include <openssl/ssl.h>
+#include <openssl/evp.h>
+
+
+int
+main ()
+{
+#ifndef SSL_COMP_get_compression_methods
+  (void) SSL_COMP_get_compression_methods;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_have_decl_SSL_COMP_get_compression_methods=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_cv_have_decl_SSL_COMP_get_compression_methods=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_SSL_COMP_get_compression_methods" >&5
+$as_echo "$ac_cv_have_decl_SSL_COMP_get_compression_methods" >&6; }
+if test "x$ac_cv_have_decl_SSL_COMP_get_compression_methods" = x""yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_SSL_COMP_GET_COMPRESSION_METHODS 1
+_ACEOF
+
+
+else
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_SSL_COMP_GET_COMPRESSION_METHODS 0
+_ACEOF
+
+
+fi
+
+
 
 # Check whether --enable-sha2 was given.
 if test "${enable_sha2+set}" = set; then
index 900e4510b387761d2baea9eeea5f3e212da80ed6..8728053c8bd4236c9aa09917172d8735b50a566f 100644 (file)
@@ -363,6 +363,26 @@ ACX_LIB_SSL
 AC_CHECK_HEADERS([openssl/conf.h],,, [AC_INCLUDES_DEFAULT])
 AC_CHECK_HEADERS([openssl/engine.h],,, [AC_INCLUDES_DEFAULT])
 AC_CHECK_FUNCS([OPENSSL_config EVP_sha1 EVP_sha256 EVP_sha512])
+AC_CHECK_DECLS([SSL_COMP_get_compression_methods], [], [], [
+AC_INCLUDES_DEFAULT
+#ifdef HAVE_OPENSSL_ERR_H
+#include <openssl/err.h>
+#endif
+
+#ifdef HAVE_OPENSSL_RAND_H
+#include <openssl/rand.h>
+#endif
+
+#ifdef HAVE_OPENSSL_CONF_H
+#include <openssl/conf.h>
+#endif
+
+#ifdef HAVE_OPENSSL_ENGINE_H
+#include <openssl/engine.h>
+#endif
+#include <openssl/ssl.h>
+#include <openssl/evp.h>
+])
 
 AC_ARG_ENABLE(sha2, AC_HELP_STRING([--enable-sha2], [Enable SHA256 and SHA512 RRSIG support, experimental]))
 case "$enable_sha2" in
@@ -691,6 +711,11 @@ AHX_CONFIG_W32_FD_SET_T
 AHX_CONFIG_IPV6_MIN_MTU
 
 [
+#ifndef HAVE_CTIME_R
+#define ctime_r unbound_ctime_r
+char *ctime_r(const time_t *timep, char *buf);
+#endif
+
 #if defined(HAVE_EVENT_H) && !defined(HAVE_EVENT_BASE_ONCE) && (defined(HAVE_PTHREAD) || defined(HAVE_SOLARIS_THREADS))
    /* using version of libevent that is not threadsafe. */
 #  define LIBEVENT_SIGNAL_PROBLEM 1
index 16be3534e020267f3f38887bac6d03c82ff34614..6f17c7145ffa0be7bb8f450f0defe92ca9c187a3 100644 (file)
@@ -63,8 +63,10 @@ static int sig_record_quit = 0;
 /** How many reload requests happened. */
 static int sig_record_reload = 0;
 
+#if HAVE_DECL_SSL_COMP_GET_COMPRESSION_METHODS
 /** cleaner ssl memory freeup */
 static void* comp_meth = NULL;
+#endif
 
 /** used when no other sighandling happens, so we don't die
   * when multiple signals in quick succession are sent to us. 
@@ -175,8 +177,10 @@ daemon_init()
        (void)ldns_key_EVP_load_gost_id();
 #endif
        OpenSSL_add_all_algorithms();
+#if HAVE_DECL_SSL_COMP_GET_COMPRESSION_METHODS
        /* grab the COMP method ptr because openssl leaks it */
        comp_meth = (void*)SSL_COMP_get_compression_methods();
+#endif
        (void)SSL_library_init();
 #ifdef HAVE_TZSET
        /* init timezone info while we are not chrooted yet */
@@ -504,7 +508,9 @@ daemon_delete(struct daemon* daemon)
        free(daemon->env);
        free(daemon);
        /* libcrypto cleanup */
+#if HAVE_DECL_SSL_COMP_GET_COMPRESSION_METHODS
        sk_SSL_COMP_free(comp_meth);
+#endif
 #ifdef HAVE_OPENSSL_CONFIG
        EVP_cleanup();
        ENGINE_cleanup();
index 50c6c6295c905c35c31c4b1d50e5bae9e97a116c..c403135486fbedb027cd0b5812292499d501a93d 100644 (file)
@@ -4,7 +4,8 @@
        - autotrust options: add-holddown, del-holddown, keep-missing.
        - autotrust store revoked status of trust points.
        - ctime_r compat definition.
-       - detect yylex_destroy().
+       - detect yylex_destroy() in configure.
+       - detect SSL_get_compression_methods declaration in configure.
 
 24 August 2009: Wouter
        - cleaner memory allocation on exit. autotrust test routines.