aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2013-01-06 20:33:31 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2013-01-06 20:33:31 +0400
commit6af303bd3ab37702ad4a6d50b74e95d2a2808e85 (patch)
tree044acffcfe2dd8527f914cdeb3949d5e93e70cee /src/main.c
parent1d63fed447d8b74d81468a57af9773773f654210 (diff)
downloadrspamd-6af303bd3ab37702ad4a6d50b74e95d2a2808e85.tar.gz
rspamd-6af303bd3ab37702ad4a6d50b74e95d2a2808e85.zip
Add /maps and /getmap commands to webui.
Identify maps by id. Initialize secure random numbers using openssl. Add description to maps.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index f85fe7ade..94001298d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -34,6 +34,10 @@
#include "cfg_xml.h"
#include "symbols_cache.h"
#include "lua/lua_common.h"
+#ifdef HAVE_OPENSSL
+#include <openssl/rand.h>
+#include <openssl/err.h>
+#endif
/* 2 seconds to fork new process in place of dead one */
#define SOFT_FORK_TIME 2
@@ -861,6 +865,10 @@ main (gint argc, gchar **argv, gchar **env)
GList *l;
worker_t **pworker;
GQuark type;
+#ifdef HAVE_OPENSSL
+ gchar rand_bytes[sizeof (guint32)];
+ guint32 rand_seed;
+#endif
#ifdef HAVE_SA_SIGINFO
signals_info = g_queue_new ();
@@ -912,6 +920,18 @@ main (gint argc, gchar **argv, gchar **env)
setlocale (LC_TIME, "C");
#endif
+ /* Init random generator */
+#ifdef HAVE_OPENSSL
+ if (RAND_bytes (rand_bytes, sizeof (rand_bytes)) != 1) {
+ msg_err ("cannot seed random generator using openssl: %s, using time", ERR_error_string (ERR_get_error (), NULL));
+ g_random_set_seed (time (NULL));
+ }
+ else {
+ memcpy (&rand_seed, rand_bytes, sizeof (guint32));
+ g_random_set_seed (rand_seed);
+ }
+#endif
+
/* First set logger to console logger */
rspamd_set_logger (RSPAMD_LOG_CONSOLE, type, rspamd_main);
(void)open_log (rspamd_main->logger);