]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Do not assign OpenSSL callbacks if not needed 1850/head
authorNikolai Kondrashov <Nikolai.Kondrashov@redhat.com>
Wed, 23 Nov 2016 08:27:45 +0000 (10:27 +0200)
committerNikolai Kondrashov <Nikolai.Kondrashov@redhat.com>
Wed, 7 Dec 2016 12:44:05 +0000 (14:44 +0200)
Check if CRYPTO_set_id_callback and CRYPTO_set_locking_callback are
defined as functions (as opposed to stub macros), and if they aren't,
don't call them and don't define the corresponding callbacks.

This avoids the "unused function" warnings with OpenSSL v1.1.

configure
configure.ac
src/include/autoconf.h.in
src/main/threads.c

index 7ccfc171931521f61356b76b4542fc210aa2c536..05860f885c116bb6c75c98c7bd8dc29688cf6ca3 100755 (executable)
--- a/configure
+++ b/configure
@@ -8790,6 +8790,8 @@ fi
       HMAC_CTX_free \
       ASN1_STRING_get0_data \
       CONF_modules_load_file \
+      CRYPTO_set_id_callback \
+      CRYPTO_set_locking_callback
 
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
index 53a27a1015faba0e39a4ad2e85672b89f95dcabe..9ead51dbb66cedba8807e94d1e15853d5e5e9752 100644 (file)
@@ -1188,6 +1188,8 @@ if test "x$WITH_OPENSSL" = xyes; then
       HMAC_CTX_free \
       ASN1_STRING_get0_data \
       CONF_modules_load_file \
+      CRYPTO_set_id_callback \
+      CRYPTO_set_locking_callback
     )
     CPPFLAGS="$old_CPPFLAGS"
   fi
index d38228199c42f25f69691d26b0acd124ecde8bae..7fc5127704fe3f2181e643c1480f6da50685947e 100644 (file)
 /* Do we have the crypt function */
 #undef HAVE_CRYPT
 
+/* Define to 1 if you have the `CRYPTO_set_id_callback' function. */
+#undef HAVE_CRYPTO_SET_ID_CALLBACK
+
+/* Define to 1 if you have the `CRYPTO_set_locking_callback' function. */
+#undef HAVE_CRYPTO_SET_LOCKING_CALLBACK
+
 /* Define to 1 if you have the <crypt.h> header file. */
 #undef HAVE_CRYPT_H
 
index cc79d0c555aba410e5e16b328ecd541b42cd5ee8..ae5a5ae06c1050c9f0223944a4c565a9624c7b08 100644 (file)
@@ -222,6 +222,7 @@ static const CONF_PARSER thread_config[] = {
 
 static pthread_mutex_t *ssl_mutexes = NULL;
 
+#ifdef HAVE_CRYPTO_SET_ID_CALLBACK
 static unsigned long ssl_id_function(void)
 {
        unsigned long ret;
@@ -235,7 +236,9 @@ static unsigned long ssl_id_function(void)
 
        return ret;
 }
+#endif
 
+#ifdef HAVE_CRYPTO_SET_LOCKING_CALLBACK
 static void ssl_locking_function(int mode, int n, UNUSED char const *file, UNUSED int line)
 {
        if (mode & CRYPTO_LOCK) {
@@ -244,6 +247,7 @@ static void ssl_locking_function(int mode, int n, UNUSED char const *file, UNUSE
                pthread_mutex_unlock(&(ssl_mutexes[n]));
        }
 }
+#endif
 
 static int setup_ssl_mutexes(void)
 {
@@ -259,8 +263,12 @@ static int setup_ssl_mutexes(void)
                pthread_mutex_init(&(ssl_mutexes[i]), NULL);
        }
 
+#ifdef HAVE_CRYPTO_SET_ID_CALLBACK
        CRYPTO_set_id_callback(ssl_id_function);
+#endif
+#ifdef HAVE_CRYPTO_SET_LOCKING_CALLBACK
        CRYPTO_set_locking_callback(ssl_locking_function);
+#endif
 
        return 1;
 }
@@ -1105,8 +1113,12 @@ void thread_pool_stop(void)
         *      We're no longer threaded.  Remove the mutexes and free
         *      the memory.
         */
+#ifdef HAVE_CRYPTO_SET_ID_CALLBACK
        CRYPTO_set_id_callback(NULL);
+#endif
+#ifdef HAVE_CRYPTO_SET_LOCKING_CALLBACK
        CRYPTO_set_locking_callback(NULL);
+#endif
 
        free(ssl_mutexes);
 #endif