]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Use cryptobox rdrand detection for ottery
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 29 Jan 2016 10:14:02 +0000 (10:14 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 29 Jan 2016 10:14:02 +0000 (10:14 +0000)
src/libutil/util.c
src/rspamd.h

index 7f8272c0eff2c695ca65807d7dc91b4f7e54315f..68366927ff69fd30c61be19df310ecd29d5b45cf 100644 (file)
@@ -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
index 304075c5319dde3ba842c1af4c45448e95a0a326..df52393578cd89719fd37a2fdfbd26e1ac65c214 100644 (file)
@@ -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;
 };