aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-08-28 17:06:48 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-08-28 17:06:48 +0100
commitac2d3dfba0a971bd0f73724f99a318fc1f371b5c (patch)
treeb69bca6e627ea5e73c10aa9ea7e77df812f03ef4 /src/libserver
parent3e6a976f8a2aa5afa3cc76f98d4d7eeff1474ed1 (diff)
downloadrspamd-ac2d3dfba0a971bd0f73724f99a318fc1f371b5c.tar.gz
rspamd-ac2d3dfba0a971bd0f73724f99a318fc1f371b5c.zip
Use config checksum for unique tag.
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/cfg_file.h8
-rw-r--r--src/libserver/cfg_rcl.c7
-rw-r--r--src/libserver/symbols_cache.c20
-rw-r--r--src/libserver/symbols_cache.h5
4 files changed, 23 insertions, 17 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index a889987fa..3a1e01bfb 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -449,19 +449,19 @@ gboolean rspamd_config_is_module_enabled (struct rspamd_config *cfg,
const gchar *module_name);
#define msg_err_config(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \
- cfg->cfg_pool->tag.tagname, cfg->cfg_pool->tag.uid, \
+ cfg->cfg_pool->tag.tagname, cfg->checksum, \
G_STRFUNC, \
__VA_ARGS__)
#define msg_warn_config(...) rspamd_default_log_function (G_LOG_LEVEL_WARNING, \
- cfg->cfg_pool->tag.tagname, cfg->cfg_pool->tag.uid, \
+ cfg->cfg_pool->tag.tagname, cfg->checksum, \
G_STRFUNC, \
__VA_ARGS__)
#define msg_info_config(...) rspamd_default_log_function (G_LOG_LEVEL_INFO, \
- cfg->cfg_pool->tag.tagname, cfg->cfg_pool->tag.uid, \
+ cfg->cfg_pool->tag.tagname, cfg->checksum, \
G_STRFUNC, \
__VA_ARGS__)
#define msg_debug_config(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \
- cfg->cfg_pool->tag.tagname, cfg->cfg_pool->tag.uid, \
+ cfg->cfg_pool->tag.tagname, cfg->checksum, \
G_STRFUNC, \
__VA_ARGS__)
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index be0243dc2..cddf044a9 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -21,6 +21,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <blake2.h>
#include "cfg_rcl.h"
#include "main.h"
#include "uthash_strcase.h"
@@ -2386,6 +2387,7 @@ rspamd_config_read (struct rspamd_config *cfg, const gchar *filename,
GError *err = NULL;
struct rspamd_rcl_section *top, *logger;
struct ucl_parser *parser;
+ unsigned char cksumbuf[BLAKE2B_OUTBYTES];
if (stat (filename, &st) == -1) {
msg_err_config ("cannot stat %s: %s", filename, strerror (errno));
@@ -2405,15 +2407,20 @@ rspamd_config_read (struct rspamd_config *cfg, const gchar *filename,
}
close (fd);
+ blake2b (cksumbuf, data, NULL, sizeof (cksumbuf), st.st_size, 0);
+ cfg->checksum = rspamd_encode_base32 (cksumbuf, sizeof (cksumbuf));
+
parser = ucl_parser_new (0);
rspamd_ucl_add_conf_variables (parser, vars);
rspamd_ucl_add_conf_macros (parser, cfg);
+
if (!ucl_parser_add_chunk (parser, data, st.st_size)) {
msg_err_config ("ucl parser error: %s", ucl_parser_get_error (parser));
ucl_parser_free (parser);
munmap (data, st.st_size);
return FALSE;
}
+
munmap (data, st.st_size);
cfg->rcl_obj = ucl_parser_get_object (parser);
ucl_parser_free (parser);
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index aef6b9cd0..5cfa4cff3 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -31,19 +31,19 @@
#include "lua/lua_common.h"
#define msg_err_cache(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \
- cache->static_pool->tag.tagname, cache->static_pool->tag.uid, \
+ cache->static_pool->tag.tagname, cache->cfg->checksum, \
G_STRFUNC, \
__VA_ARGS__)
#define msg_warn_cache(...) rspamd_default_log_function (G_LOG_LEVEL_WARNING, \
- cache->static_pool->tag.tagname, cache->static_pool->tag.uid, \
+ cache->static_pool->tag.tagname, cache->cfg->checksum, \
G_STRFUNC, \
__VA_ARGS__)
#define msg_info_cache(...) rspamd_default_log_function (G_LOG_LEVEL_INFO, \
- cache->static_pool->tag.tagname, cache->static_pool->tag.uid, \
+ cache->static_pool->tag.tagname, cache->cfg->checksum, \
G_STRFUNC, \
__VA_ARGS__)
#define msg_debug_cache(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \
- cache->static_pool->tag.tagname, cache->static_pool->tag.uid, \
+ cache->static_pool->tag.tagname, cache->cfg->checksum, \
G_STRFUNC, \
__VA_ARGS__)
@@ -605,7 +605,7 @@ rspamd_symbols_cache_destroy (struct symbols_cache *cache)
}
struct symbols_cache*
-rspamd_symbols_cache_new (void)
+rspamd_symbols_cache_new (struct rspamd_config *cfg)
{
struct symbols_cache *cache;
@@ -620,27 +620,27 @@ rspamd_symbols_cache_new (void)
cache->reload_time = CACHE_RELOAD_TIME;
cache->total_freq = 1;
cache->max_weight = 1.0;
+ cache->cfg = cfg;
return cache;
}
gboolean
-rspamd_symbols_cache_init (struct symbols_cache* cache,
- struct rspamd_config *cfg)
+rspamd_symbols_cache_init (struct symbols_cache* cache)
{
gboolean res;
g_assert (cache != NULL);
- cache->cfg = cfg;
+
/* Just in-memory cache */
- if (cfg->cache_filename == NULL) {
+ if (cache->cfg->cache_filename == NULL) {
post_cache_init (cache);
return TRUE;
}
/* Copy saved cache entries */
- res = rspamd_symbols_cache_load_items (cache, cfg->cache_filename);
+ res = rspamd_symbols_cache_load_items (cache, cache->cfg->cache_filename);
return res;
}
diff --git a/src/libserver/symbols_cache.h b/src/libserver/symbols_cache.h
index 2f4e28657..64d1f911f 100644
--- a/src/libserver/symbols_cache.h
+++ b/src/libserver/symbols_cache.h
@@ -50,7 +50,7 @@ enum rspamd_symbol_type {
* Creates new cache structure
* @return
*/
-struct symbols_cache* rspamd_symbols_cache_new (void);
+struct symbols_cache* rspamd_symbols_cache_new (struct rspamd_config *cfg);
/**
* Remove the cache structure syncing data if needed
@@ -61,8 +61,7 @@ void rspamd_symbols_cache_destroy (struct symbols_cache *cache);
/**
* Load symbols cache from file, must be called _after_ init_symbols_cache
*/
-gboolean rspamd_symbols_cache_init (struct symbols_cache* cache,
- struct rspamd_config *cfg);
+gboolean rspamd_symbols_cache_init (struct symbols_cache* cache);
/**
* Generic function to register a symbol