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);
}
}
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 */
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) {
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);
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);
+ }
}
}
}
*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);
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);
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);
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;
}
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 =
{
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;
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;
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;
}
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);
+
}
}
}
}
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)) {