]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Do not output meaningless errors
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 20 Jun 2016 11:47:12 +0000 (12:47 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 20 Jun 2016 11:47:12 +0000 (12:47 +0100)
src/libserver/cfg_utils.c
src/libserver/url.c
src/libutil/util.c

index 9e80cbaa83145ad3fb4918eac162a1fabcc2fb1e..8f8fb551c8aea3fdaad0f2af19811c7037c201ae 100644 (file)
@@ -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
index 92f2c95a55780e29052c0ff58fd25e08e54903e2..469830bd54cebaf051a6e55aee1355ee371dc6a1 100644 (file)
@@ -448,10 +448,6 @@ rspamd_url_init (const gchar *tld_file)
                if (tld_file != NULL) {
                        rspamd_url_parse_tld_file (tld_file, url_scanner);
                }
-               else {
-                       msg_info (
-                                       "tld extension file is not specified, url matching is limited");
-               }
 
                if (!rspamd_multipattern_compile (url_scanner->search_trie, &err)) {
                        msg_err ("cannot compile tld patterns, url matching will be "
@@ -459,7 +455,7 @@ rspamd_url_init (const gchar *tld_file)
                        g_error_free (err);
                }
 
-               msg_info ("initialized trie of %ud elements",
+               msg_debug ("initialized trie of %ud elements",
                                url_scanner->matchers->len);
        }
 }
index 20da1a37122fba9476137536287c4dd65eec55c7..0edbb7c6189a56a166556d758f529675e744c242 100644 (file)
@@ -2097,7 +2097,7 @@ rspamd_config_libs (struct rspamd_external_libs_ctx *ctx,
                        }
                }
                else {
-                       msg_warn_config ("ssl_ca_path is not set, using default CA path");
+                       msg_debug_config ("ssl_ca_path is not set, using default CA path");
                        SSL_CTX_set_default_verify_paths (ctx->ssl_ctx);
                }