commit 4f68ea1: [Minor] Fix some of the moved functions

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Feb 13 17:14:08 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-02-13 17:10:35 +0000
URL: https://github.com/rspamd/rspamd/commit/4f68ea16a3619d2206c652ba8c7c76c4158dcdca

[Minor] Fix some of the moved functions

---
 src/libserver/cfg_file.h          |  1 -
 src/libserver/cfg_utils.c         | 39 ------------------------------------
 src/libserver/http/http_context.c |  2 +-
 src/libserver/ssl_util.c          | 42 +++++++++++++++++++++++++++++++++++++++
 src/libserver/ssl_util.h          |  1 +
 5 files changed, 44 insertions(+), 41 deletions(-)

diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index e37bccc69..1d782dd8b 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -856,7 +856,6 @@ gboolean rspamd_ip_is_local_cfg (struct rspamd_config *cfg,
  */
 gboolean rspamd_config_libs (struct rspamd_external_libs_ctx *ctx,
 							 struct rspamd_config *cfg);
-void rspamd_openssl_maybe_init (void);
 
 #define msg_err_config(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \
         cfg->cfg_pool->tag.tagname, cfg->checksum, \
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index dac2e13c4..0d4953d51 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -46,7 +46,6 @@
 #include <openssl/evp.h>
 #include <openssl/ssl.h>
 #include <openssl/conf.h>
-#include <openssl/engine.h>
 #endif
 #ifdef HAVE_LOCALE_H
 #include <locale.h>
@@ -2639,44 +2638,6 @@ rspamd_config_ev_backend_to_string (int ev_backend, gboolean *effective)
 #undef SET_EFFECTIVE
 }
 
-void
-rspamd_openssl_maybe_init (void)
-{
-	static gboolean openssl_initialized = FALSE;
-
-	if (!openssl_initialized) {
-		ERR_load_crypto_strings ();
-		SSL_load_error_strings ();
-
-		OpenSSL_add_all_algorithms ();
-		OpenSSL_add_all_digests ();
-		OpenSSL_add_all_ciphers ();
-
-#if OPENSSL_VERSION_NUMBER >= 0x1000104fL && !defined(LIBRESSL_VERSION_NUMBER)
-		ENGINE_load_builtin_engines ();
-#endif
-#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
-		SSL_library_init ();
-#else
-		OPENSSL_init_ssl (0, NULL);
-#endif
-
-#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
-		OPENSSL_config (NULL);
-#endif
-		if (RAND_status () == 0) {
-			guchar seed[128];
-
-			/* Try to use ottery to seed rand */
-			ottery_rand_bytes (seed, sizeof (seed));
-			RAND_seed (seed, sizeof (seed));
-			rspamd_explicit_memzero (seed, sizeof (seed));
-		}
-
-		openssl_initialized = TRUE;
-	}
-}
-
 struct rspamd_external_libs_ctx *
 rspamd_init_libs (void)
 {
diff --git a/src/libserver/http/http_context.c b/src/libserver/http/http_context.c
index d7e530d56..8db43841d 100644
--- a/src/libserver/http/http_context.c
+++ b/src/libserver/http/http_context.c
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-#include <contrib/http-parser/http_parser.h>
 #include "http_context.h"
 #include "http_private.h"
 #include "keypair.h"
@@ -22,6 +21,7 @@
 #include "cfg_file.h"
 #include "contrib/libottery/ottery.h"
 #include "contrib/http-parser/http_parser.h"
+#include "ssl_util.h"
 #include "rspamd.h"
 #include "libev_helper.h"
 
diff --git a/src/libserver/ssl_util.c b/src/libserver/ssl_util.c
index f4e55fbea..a094eaf45 100644
--- a/src/libserver/ssl_util.c
+++ b/src/libserver/ssl_util.c
@@ -19,11 +19,15 @@
 #include "libserver/logger.h"
 #include "ssl_util.h"
 #include "unix-std.h"
+#include "cryptobox.h"
+#include "contrib/libottery/ottery.h"
 
 #include <openssl/ssl.h>
 #include <openssl/err.h>
 #include <openssl/rand.h>
 #include <openssl/conf.h>
+#include <openssl/evp.h>
+#include <openssl/engine.h>
 #include <openssl/x509v3.h>
 
 enum rspamd_ssl_state {
@@ -970,4 +974,42 @@ gpointer rspamd_init_ssl_ctx_noverify (void)
 #endif
 
 	return ssl_ctx_noverify;
+}
+
+void
+rspamd_openssl_maybe_init (void)
+{
+	static gboolean openssl_initialized = FALSE;
+
+	if (!openssl_initialized) {
+		ERR_load_crypto_strings ();
+		SSL_load_error_strings ();
+
+		OpenSSL_add_all_algorithms ();
+		OpenSSL_add_all_digests ();
+		OpenSSL_add_all_ciphers ();
+
+#if OPENSSL_VERSION_NUMBER >= 0x1000104fL && !defined(LIBRESSL_VERSION_NUMBER)
+		ENGINE_load_builtin_engines ();
+#endif
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+		SSL_library_init ();
+#else
+		OPENSSL_init_ssl (0, NULL);
+#endif
+
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+		OPENSSL_config (NULL);
+#endif
+		if (RAND_status () == 0) {
+			guchar seed[128];
+
+			/* Try to use ottery to seed rand */
+			ottery_rand_bytes (seed, sizeof (seed));
+			RAND_seed (seed, sizeof (seed));
+			rspamd_explicit_memzero (seed, sizeof (seed));
+		}
+
+		openssl_initialized = TRUE;
+	}
 }
\ No newline at end of file
diff --git a/src/libserver/ssl_util.h b/src/libserver/ssl_util.h
index 708c07930..9118c3e8c 100644
--- a/src/libserver/ssl_util.h
+++ b/src/libserver/ssl_util.h
@@ -96,6 +96,7 @@ void rspamd_ssl_connection_free (struct rspamd_ssl_connection *conn);
 
 gpointer rspamd_init_ssl_ctx (void);
 gpointer rspamd_init_ssl_ctx_noverify (void);
+void rspamd_openssl_maybe_init (void);
 
 #ifdef  __cplusplus
 }


More information about the Commits mailing list