summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-02-15 17:28:06 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-02-15 17:28:06 +0000
commit153e64677902c1acc7a1e8ee21d5b634d8a65885 (patch)
treef6055a7c820e067218142be908165a7746d192f3 /src
parentdf75947ab9f8bdd9eb2b5c05384d49e247c8b41d (diff)
downloadrspamd-153e64677902c1acc7a1e8ee21d5b634d8a65885.tar.gz
rspamd-153e64677902c1acc7a1e8ee21d5b634d8a65885.zip
Fix logging for embedded maps
Diffstat (limited to 'src')
-rw-r--r--src/controller.c11
-rw-r--r--src/fuzzy_storage.c15
-rw-r--r--src/libutil/logger.c13
-rw-r--r--src/libutil/map.c6
-rw-r--r--src/libutil/util.c9
-rw-r--r--src/lua/lua_config.c14
-rw-r--r--src/plugins/dkim_check.c16
-rw-r--r--src/plugins/fuzzy_check.c17
-rw-r--r--src/plugins/spf.c18
-rw-r--r--src/plugins/surbl.c2
10 files changed, 85 insertions, 36 deletions
diff --git a/src/controller.c b/src/controller.c
index 8e230eb0f..7d39be8d4 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -2519,16 +2519,19 @@ start_controller_worker (struct rspamd_worker *worker)
secure_ip = cur->data;
/* Try map syntax */
- if (!rspamd_map_add (worker->srv->cfg, secure_ip,
- "Allow webui access from the specified IP",
- rspamd_radix_read, rspamd_radix_fin, (void **)&ctx->secure_map)) {
- /* Fallback to the plain IP */
+ if (!rspamd_map_is_map (secure_ip)) {
if (!radix_add_generic_iplist (secure_ip,
&ctx->secure_map)) {
msg_warn_ctx ("cannot load or parse ip list from '%s'",
secure_ip);
}
}
+ else {
+ rspamd_map_add (worker->srv->cfg, secure_ip,
+ "Allow webui access from the specified IP",
+ rspamd_radix_read, rspamd_radix_fin,
+ (void **)&ctx->secure_map);
+ }
cur = g_list_next (cur);
}
}
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index b852dbb85..158cdf187 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -1384,15 +1384,20 @@ start_fuzzy (struct rspamd_worker *worker)
rspamd_fuzzy_storage_stat, ctx);
/* Create radix tree */
if (ctx->update_map != NULL) {
- if (!rspamd_map_add (worker->srv->cfg, ctx->update_map,
- "Allow fuzzy updates from specified addresses",
- rspamd_radix_read, rspamd_radix_fin, (void **)&ctx->update_ips)) {
+ if (!rspamd_map_is_map (ctx->update_map)) {
if (!radix_add_generic_iplist (ctx->update_map,
- &ctx->update_ips)) {
+ &ctx->update_ips)) {
msg_warn ("cannot load or parse ip list from '%s'",
- ctx->update_map);
+ ctx->update_map);
}
}
+ else {
+ rspamd_map_add (worker->srv->cfg, ctx->update_map,
+ "Allow fuzzy updates from specified addresses",
+ rspamd_radix_read, rspamd_radix_fin,
+ (void **)&ctx->update_ips);
+
+ }
}
/* Maps events */
diff --git a/src/libutil/logger.c b/src/libutil/logger.c
index 53415a830..56f7822a5 100644
--- a/src/libutil/logger.c
+++ b/src/libutil/logger.c
@@ -351,13 +351,18 @@ rspamd_set_logger (struct rspamd_config *cfg,
if (rspamd->logger->debug_ip) {
radix_destroy_compressed (rspamd->logger->debug_ip);
}
+
rspamd->logger->debug_ip = radix_create_compressed ();
- if (!rspamd_map_add (rspamd->cfg, rspamd->cfg->debug_ip_map,
+
+ if (!rspamd_map_is_map (rspamd->cfg->debug_ip_map)) {
+ radix_add_generic_iplist (rspamd->cfg->debug_ip_map,
+ &rspamd->logger->debug_ip);
+ }
+ else {
+ rspamd_map_add (rspamd->cfg, rspamd->cfg->debug_ip_map,
"IP addresses for which debug logs are enabled",
rspamd_radix_read, rspamd_radix_fin,
- (void **) &rspamd->logger->debug_ip)) {
- radix_add_generic_iplist (rspamd->cfg->debug_ip_map,
- &rspamd->logger->debug_ip);
+ (void **) &rspamd->logger->debug_ip);
}
}
else if (rspamd->logger->debug_ip) {
diff --git a/src/libutil/map.c b/src/libutil/map.c
index 07558c296..33cfc0cd5 100644
--- a/src/libutil/map.c
+++ b/src/libutil/map.c
@@ -270,6 +270,12 @@ rspamd_map_check_file_sig (const char *fname,
return FALSE;
}
+ b32_key = rspamd_pubkey_print (pk,
+ RSPAMD_KEYPAIR_BASE32|RSPAMD_KEYPAIR_PUBKEY);
+ msg_info_pool ("verified signature in file %s using trusted key %v",
+ fpath, b32_key);
+ g_string_free (b32_key, TRUE);
+
rspamd_pubkey_unref (pk);
munmap (data, len);
diff --git a/src/libutil/util.c b/src/libutil/util.c
index 30665dfb8..0023a9ba1 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -2019,12 +2019,15 @@ rspamd_config_libs (struct rspamd_external_libs_ctx *ctx,
if (ctx != NULL) {
if (cfg->local_addrs) {
- if (!rspamd_map_add (cfg, cfg->local_addrs,
- "Local addresses", rspamd_radix_read, rspamd_radix_fin,
- (void **) ctx->local_addrs)) {
+ if (!rspamd_map_is_map (cfg->local_addrs)) {
radix_add_generic_iplist (cfg->local_addrs,
(radix_compressed_t **)ctx->local_addrs);
}
+ else {
+ rspamd_map_add (cfg, cfg->local_addrs,
+ "Local addresses", rspamd_radix_read, rspamd_radix_fin,
+ (void **) ctx->local_addrs);
+ }
}
}
}
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index 1ab7a746b..9cf18fa22 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -756,7 +756,7 @@ lua_config_add_radix_map (lua_State *L)
*r = radix_create_compressed ();
if (!rspamd_map_add (cfg, map_line, description, rspamd_radix_read,
- rspamd_radix_fin, (void **)r)) {
+ rspamd_radix_fin, (void **)r)) {
msg_warn_config ("invalid radix map %s", map_line);
radix_destroy_compressed (*r);
lua_pushnil (L);
@@ -827,8 +827,10 @@ lua_config_add_hash_map (lua_State *L)
r = rspamd_mempool_alloc (cfg->cfg_pool, sizeof (GHashTable *));
*r = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal);
- if (!rspamd_map_add (cfg, map_line, description, rspamd_hosts_read, rspamd_hosts_fin,
- (void **)r)) {
+ if (!rspamd_map_add (cfg, map_line, description,
+ rspamd_hosts_read,
+ rspamd_hosts_fin,
+ (void **)r)) {
msg_warn ("invalid hash map %s", map_line);
g_hash_table_destroy (*r);
lua_pushnil (L);
@@ -863,8 +865,10 @@ lua_config_add_kv_map (lua_State *L)
r = rspamd_mempool_alloc (cfg->cfg_pool, sizeof (GHashTable *));
*r = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal);
- if (!rspamd_map_add (cfg, map_line, description, rspamd_kv_list_read, rspamd_kv_list_fin,
- (void **)r)) {
+ if (!rspamd_map_add (cfg, map_line, description,
+ rspamd_kv_list_read,
+ rspamd_kv_list_fin,
+ (void **)r)) {
msg_warn_config ("invalid hash map %s", map_line);
g_hash_table_destroy (*r);
lua_pushnil (L);
diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c
index a30a52e6e..8147eb270 100644
--- a/src/plugins/dkim_check.c
+++ b/src/plugins/dkim_check.c
@@ -220,6 +220,7 @@ gint
dkim_module_config (struct rspamd_config *cfg)
{
const ucl_object_t *value;
+ const gchar *str;
gint res = TRUE, cb_id;
guint cache_size, cache_expire;
gboolean got_trusted = FALSE;
@@ -277,11 +278,16 @@ dkim_module_config (struct rspamd_config *cfg)
}
if ((value =
rspamd_config_get_module_opt (cfg, "dkim", "whitelist")) != NULL) {
- if (!rspamd_map_add (cfg, ucl_obj_tostring (value),
- "DKIM whitelist", rspamd_radix_read, rspamd_radix_fin,
- (void **)&dkim_module_ctx->whitelist_ip)) {
- radix_add_generic_iplist (ucl_obj_tostring (value),
- &dkim_module_ctx->whitelist_ip);
+ str = ucl_obj_tostring (value);
+ if (!rspamd_map_is_map (str)) {
+ radix_add_generic_iplist (str,
+ &dkim_module_ctx->whitelist_ip);
+ }
+ else {
+ rspamd_map_add (cfg, str,
+ "DKIM whitelist", rspamd_radix_read, rspamd_radix_fin,
+ (void **)&dkim_module_ctx->whitelist_ip);
+
}
}
if ((value =
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index 85c147a52..788601f1e 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -757,6 +757,7 @@ fuzzy_check_module_config (struct rspamd_config *cfg)
{
const ucl_object_t *value, *cur;
gint res = TRUE, cb_id, nrules = 0;
+ const gchar *str;
if (!rspamd_config_is_module_enabled (cfg, "fuzzy_check")) {
return TRUE;
@@ -824,12 +825,20 @@ fuzzy_check_module_config (struct rspamd_config *cfg)
rspamd_config_get_module_opt (cfg, "fuzzy_check",
"whitelist")) != NULL) {
fuzzy_module_ctx->whitelist = radix_create_compressed ();
- if (!rspamd_map_add (cfg, ucl_obj_tostring (value),
- "Fuzzy whitelist", rspamd_radix_read, rspamd_radix_fin,
- (void **)&fuzzy_module_ctx->whitelist)) {
- radix_add_generic_iplist (ucl_obj_tostring (value),
+ ucl_obj_tostring (value);
+
+ str = ucl_obj_tostring (value);
+
+ if (!rspamd_map_is_map (str)) {
+ radix_add_generic_iplist (str,
&fuzzy_module_ctx->whitelist);
}
+ else {
+ rspamd_map_add (cfg, str,
+ "Fuzzy whitelist", rspamd_radix_read, rspamd_radix_fin,
+ (void **)&fuzzy_module_ctx->whitelist);
+
+ }
}
else {
fuzzy_module_ctx->whitelist = NULL;
diff --git a/src/plugins/spf.c b/src/plugins/spf.c
index a02dcc002..edad4bfc9 100644
--- a/src/plugins/spf.c
+++ b/src/plugins/spf.c
@@ -173,6 +173,7 @@ spf_module_config (struct rspamd_config *cfg)
const ucl_object_t *value;
gint res = TRUE, cb_id;
guint cache_size, cache_expire;
+ const gchar *str;
if (!rspamd_config_is_module_enabled (cfg, "spf")) {
return TRUE;
@@ -225,11 +226,18 @@ spf_module_config (struct rspamd_config *cfg)
}
if ((value =
rspamd_config_get_module_opt (cfg, "spf", "whitelist")) != NULL) {
- if (!rspamd_map_add (cfg, ucl_obj_tostring (value),
- "SPF whitelist", rspamd_radix_read, rspamd_radix_fin,
- (void **)&spf_module_ctx->whitelist_ip)) {
- radix_add_generic_iplist (ucl_obj_tostring (value),
- &spf_module_ctx->whitelist_ip);
+
+ str = ucl_obj_tostring (value);
+
+ if (!rspamd_map_is_map (str)) {
+ radix_add_generic_iplist (str,
+ &spf_module_ctx->whitelist_ip);
+ }
+ else {
+ rspamd_map_add (cfg, str,
+ "SPF whitelist", rspamd_radix_read, rspamd_radix_fin,
+ (void **)&spf_module_ctx->whitelist_ip);
+
}
}
diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c
index cbd5f0f2b..b49ed8f3c 100644
--- a/src/plugins/surbl.c
+++ b/src/plugins/surbl.c
@@ -574,7 +574,7 @@ surbl_module_config (struct rspamd_config *cfg)
}
}
if ((value =
- rspamd_config_get_module_opt (cfg, "surbl", "whitelist")) != NULL) {
+ rspamd_config_get_module_opt (cfg, "surbl", "whitelist")) != NULL) {
if (rspamd_map_add (cfg, ucl_obj_tostring (value),
"SURBL whitelist", rspamd_hosts_read, rspamd_hosts_fin,
(void **)&surbl_module_ctx->whitelist)) {