aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-01-29 10:14:02 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-01-29 10:14:02 +0000
commitab9ccf06ea9e3122c1fe43c3cc162c36d14ccc7d (patch)
tree594a75a74b561395cc4b121ed23e968be532e55b
parent609caa681b8d0cf9e58cb2824323d5fe04af6934 (diff)
downloadrspamd-ab9ccf06ea9e3122c1fe43c3cc162c36d14ccc7d.tar.gz
rspamd-ab9ccf06ea9e3122c1fe43c3cc162c36d14ccc7d.zip
Use cryptobox rdrand detection for ottery
-rw-r--r--src/libutil/util.c15
-rw-r--r--src/rspamd.h1
2 files changed, 14 insertions, 2 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c
index 7f8272c0e..68366927f 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -1938,10 +1938,21 @@ rspamd_init_libs (void)
{
struct rlimit rlim;
struct rspamd_external_libs_ctx *ctx;
+ struct ottery_config *ottery_cfg;
ctx = g_slice_alloc0 (sizeof (*ctx));
ctx->crypto_ctx = rspamd_cryptobox_init ();
- ottery_init (NULL);
+ ottery_cfg = g_malloc0 (ottery_get_sizeof_config ());
+ ottery_config_init (ottery_cfg);
+ ctx->ottery_cfg = ottery_cfg;
+
+ /* Check if we have rdrand */
+ if ((ctx->crypto_ctx->cpu_config & CPUID_RDRAND) == 0) {
+ ottery_config_disable_entropy_sources (ottery_cfg,
+ OTTERY_ENTROPY_SRC_RDRAND);
+ }
+
+ ottery_init (ottery_cfg);
#ifdef HAVE_LOCALE_H
if (getenv ("LANG") == NULL) {
@@ -2012,8 +2023,8 @@ rspamd_deinit_libs (struct rspamd_external_libs_ctx *ctx)
magic_close (ctx->libmagic);
}
+ g_free (ctx->ottery_cfg);
g_slice_free1 (sizeof (*ctx), ctx);
-
g_mime_shutdown ();
#ifdef HAVE_OPENSSL
diff --git a/src/rspamd.h b/src/rspamd.h
index 304075c53..df5239357 100644
--- a/src/rspamd.h
+++ b/src/rspamd.h
@@ -194,6 +194,7 @@ struct rspamd_external_libs_ctx {
magic_t libmagic;
void **local_addrs;
struct rspamd_cryptobox_library_ctx *crypto_ctx;
+ struct ottery_config *ottery_cfg;
ref_entry_t ref;
};