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 ();
#ifdef HAVE_OPENSSL
ERR_load_crypto_strings ();
- /* Init random generator */
- 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);
- }
-
OpenSSL_add_all_algorithms ();
OpenSSL_add_all_digests ();
OpenSSL_add_all_ciphers ();
#endif
+ rspamd_prng_seed ();
+
/* First set logger to console logger */
rspamd_set_logger (RSPAMD_LOG_CONSOLE, type, rspamd_main);
(void)open_log (rspamd_main->logger);
#include "filter.h"
#include "message.h"
+#ifdef HAVE_OPENSSL
+#include <openssl/rand.h>
+#include <openssl/err.h>
+#endif
+
/* Check log messages intensity once per minute */
#define CHECK_TIME 60
/* More than 2 log messages per second */
return p - buf;
#endif
}
+
+void
+rspamd_prng_seed (void)
+{
+ guint32 rand_seed = 0;
+#ifdef HAVE_OPENSSL
+ gchar rand_bytes[sizeof (guint32)];
+
+ /* Init random generator */
+ 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));
+ rand_seed = time (NULL);
+ }
+ else {
+ memcpy (&rand_seed, rand_bytes, sizeof (guint32));
+ }
+#else
+ rand_seed = time (NULL);
+#endif
+
+ g_random_set_seed (rand_seed);
+}
+
/*
* vi:ts=4
*/
gint rspamd_read_passphrase (gchar *buf, gint size, gint rwflag, gpointer key);
/**
- * Expand path that may contain configuration variables:
- * $CONFDIR - configuration directory
- * $RUNDIR - local states directory
- * $DBDIR - databases dir
- * $LOGDIR - logs dir
- * $PLUGINSDIR - plugins dir
- * $PREFIX - installation prefix
- * $VERSION - rspamd version
- * @param pool to use
- * @param path path to expand
+ * Seed glib prng using openssl if possible
*/
+void rspamd_prng_seed (void);
#endif