diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-06-20 12:47:12 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-06-20 12:47:12 +0100 |
commit | 742d8fab29b89ebcb711b44ab7abf3193ae548c5 (patch) | |
tree | 62f41a3448b912d2c1610c39e342b396d0ece90d /src/libserver/cfg_utils.c | |
parent | f39c98bff5e340fc70b49bde8de4fd1187b44e7c (diff) | |
download | rspamd-742d8fab29b89ebcb711b44ab7abf3193ae548c5.tar.gz rspamd-742d8fab29b89ebcb711b44ab7abf3193ae548c5.zip |
[Fix] Do not output meaningless errors
Diffstat (limited to 'src/libserver/cfg_utils.c')
-rw-r--r-- | src/libserver/cfg_utils.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index 9e80cbaa8..8f8fb551c 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -619,6 +619,7 @@ rspamd_config_post_load (struct rspamd_config *cfg, gboolean validate_cache) struct metric *def_metric; struct rspamd_config_post_load_script *sc; struct rspamd_config **pcfg; + gboolean ret = TRUE; #ifdef HAVE_CLOCK_GETTIME #ifdef HAVE_CLOCK_PROCESS_CPUTIME_ID @@ -657,19 +658,35 @@ rspamd_config_post_load (struct rspamd_config *cfg, gboolean validate_cache) rspamd_printf_gstring (fpath, "%s%c%s", RSPAMD_PLUGINSDIR, G_DIR_SEPARATOR, "effective_tld_names.dat"); - if (access (fpath->str, R_OK)) { - msg_info_config ("url_tld option is not specified but %s is available," + if (access (fpath->str, R_OK) != -1) { + msg_debug_config ("url_tld option is not specified but %s is available," " therefore this file is assumed as TLD file for URL" " extraction", fpath->str); cfg->tld_file = rspamd_mempool_strdup (cfg->cfg_pool, fpath->str); } else { - msg_err_config ("no url_tld option has been specified, URL's detection " - "will be awfully broken"); + if (validate_cache) { + msg_err_config ("no url_tld option has been specified"); + ret = FALSE; + } } g_string_free (fpath, TRUE); } + else { + if (access (cfg->tld_file, R_OK) == -1) { + if (validate_cache) { + ret = FALSE; + msg_err_config ("cannot access tld file %s: %s", cfg->tld_file, + strerror (errno)); + } + else { + msg_debug_config ("cannot access tld file %s: %s", cfg->tld_file, + strerror (errno)); + cfg->tld_file = NULL; + } + } + } init_dynamic_config (cfg); rspamd_url_init (cfg->tld_file); @@ -709,10 +726,10 @@ rspamd_config_post_load (struct rspamd_config *cfg, gboolean validate_cache) /* Validate cache */ if (validate_cache) { - return rspamd_symbols_cache_validate (cfg->cache, cfg, FALSE); + return rspamd_symbols_cache_validate (cfg->cache, cfg, FALSE) && ret; } - return TRUE; + return ret; } #if 0 |