}
else {
/* No type specified */
- msg_warn (
+ msg_warn_config (
"logging type is not specified correctly, log output to the console");
}
}
}
else {
- msg_warn ("redefining symbol '%s' in metric '%s'", key, metric->name);
+ msg_warn_config ("redefining symbol '%s' in metric '%s'", key, metric->name);
}
if (!rspamd_rcl_section_parse_defaults (section, pool, obj,
lua_src,
lua_tostring (L, -1));
if (chdir (cur_dir) == -1) {
- msg_err ("cannot chdir to %s: %s", cur_dir,
+ msg_err_config ("cannot chdir to %s: %s", cur_dir,
strerror (errno));
}
g_free (cur_dir);
lua_src,
lua_tostring (L, -1));
if (chdir (cur_dir) == -1) {
- msg_err ("cannot chdir to %s: %s", cur_dir,
+ msg_err_config ("cannot chdir to %s: %s", cur_dir,
strerror (errno));
}
g_free (cur_dir);
g_set_error (err, CFG_RCL_ERROR, ENOENT, "cannot chdir to %s: %s",
lua_src, strerror (errno));
if (chdir (cur_dir) == -1) {
- msg_err ("cannot chdir to %s: %s", cur_dir, strerror (errno));
+ msg_err_config ("cannot chdir to %s: %s", cur_dir, strerror (errno));
}
g_free (cur_dir);
g_free (tmp1);
}
if (chdir (cur_dir) == -1) {
- msg_err ("cannot chdir to %s: %s", cur_dir, strerror (errno));
+ msg_err_config ("cannot chdir to %s: %s", cur_dir, strerror (errno));
}
g_free (cur_dir);
g_free (tmp1);
val = ucl_object_find_key (obj, "spam");
if (val == NULL) {
- msg_info (
+ msg_info_config (
"statfile %s has no explicit 'spam' setting, trying to guess by symbol",
st->symbol);
if (rspamd_strncasestr (st->symbol, "spam",
st->symbol);
return FALSE;
}
- msg_info ("guessed that statfile with symbol %s is %s",
+ msg_info_config ("guessed that statfile with symbol %s is %s",
st->symbol,
st->is_spam ?
"spam" : "ham");
}
}
else {
- msg_err ("fatal configuration error, cannot parse statfile definition");
+ msg_err_config ("fatal configuration error, cannot parse statfile definition");
}
if (tkcf == NULL) {
composite_name = key;
if (g_hash_table_lookup (cfg->composite_symbols, composite_name) != NULL) {
- msg_warn ("composite %s is redefined", composite_name);
+ msg_warn_config ("composite %s is redefined", composite_name);
new = FALSE;
}
if (!rspamd_parse_expression (composite_expression, 0, &composite_expr_subr,
NULL, cfg->cfg_pool, err, &expr)) {
if (err && *err) {
- msg_err ("cannot parse composite expression for %s: %e",
+ msg_err_config ("cannot parse composite expression for %s: %e",
composite_name, *err);
}
else {
- msg_err ("cannot parse composite expression for %s: unknown error",
+ msg_err_config ("cannot parse composite expression for %s: unknown error",
composite_name);
}
HASH_FIND_STR (nparser->parsers, name, nhandler);
if (nhandler != NULL) {
- msg_warn (
+ msg_warn_config (
"handler for parameter %s is already registered for worker type %s",
name,
g_quark_to_string (type));
struct ucl_parser *parser;
if (stat (filename, &st) == -1) {
- msg_err ("cannot stat %s: %s", filename, strerror (errno));
+ msg_err_config ("cannot stat %s: %s", filename, strerror (errno));
return FALSE;
}
if ((fd = open (filename, O_RDONLY)) == -1) {
- msg_err ("cannot open %s: %s", filename, strerror (errno));
+ msg_err_config ("cannot open %s: %s", filename, strerror (errno));
return FALSE;
}
/* Now mmap this file to simplify reading process */
if ((data =
mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) {
- msg_err ("cannot mmap %s: %s", filename, strerror (errno));
+ msg_err_config ("cannot mmap %s: %s", filename, strerror (errno));
close (fd);
return FALSE;
}
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 ("ucl parser error: %s", ucl_parser_get_error (parser));
+ msg_err_config ("ucl parser error: %s", ucl_parser_get_error (parser));
ucl_parser_free (parser);
munmap (data, st.st_size);
return FALSE;
}
if (!rspamd_rcl_parse (top, cfg, cfg->cfg_pool, cfg->rcl_obj, &err)) {
- msg_err ("rcl parse error: %e", err);
+ msg_err_config ("rcl parse error: %e", err);
g_error_free (err);
return FALSE;
}
LL_PREPEND (cf->bind_conf, cnf);
}
else {
- msg_err ("cannot parse bind line: %s", str);
+ msg_err_config ("cannot parse bind line: %s", str);
ret = FALSE;
}
}
else {
if (!rspamd_parse_host_port_priority_strv (tokens, &cnf->addrs,
NULL, &cnf->name, DEFAULT_BIND_PORT, cfg->cfg_pool)) {
- msg_err ("cannot parse bind line: %s", str);
+ msg_err_config ("cannot parse bind line: %s", str);
ret = FALSE;
}
else {
return res;
}
-guint64
-rspamd_config_parse_limit (const gchar *limit, guint len)
-{
- guint64 result = 0;
- const gchar *err_str;
-
- if (!limit || *limit == '\0' || len == 0) {
- return 0;
- }
-
- errno = 0;
- result = strtoull (limit, (gchar **)&err_str, 10);
-
- if (*err_str != '\0') {
- /* Megabytes */
- if (*err_str == 'm' || *err_str == 'M') {
- result *= 1048576L;
- }
- /* Kilobytes */
- else if (*err_str == 'k' || *err_str == 'K') {
- result *= 1024;
- }
- /* Gigabytes */
- else if (*err_str == 'g' || *err_str == 'G') {
- result *= 1073741824L;
- }
- else if (len > 0 && err_str - limit != (gint)len) {
- msg_warn ("invalid limit value '%s' at position '%s'",
- limit,
- err_str);
- result = 0;
- }
- }
-
- return result;
-}
-
gchar
rspamd_config_parse_flag (const gchar *str, guint len)
{
/* Compute checksum for config file that should be used by xml dumper */
if ((fd = open (cfg->cfg_name, O_RDONLY)) == -1) {
- msg_err (
+ msg_err_config (
"config file %s is no longer available, cannot calculate checksum");
return FALSE;
}
if (stat (cfg->cfg_name, &st) == -1) {
- msg_err ("cannot stat %s: %s", cfg->cfg_name, strerror (errno));
+ msg_err_config ("cannot stat %s: %s", cfg->cfg_name, strerror (errno));
close (fd);
return FALSE;
}
/* Now mmap this file to simplify reading process */
if ((map =
mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) {
- msg_err ("cannot mmap %s: %s", cfg->cfg_name, strerror (errno));
+ msg_err_config ("cannot mmap %s: %s", cfg->cfg_name, strerror (errno));
close (fd);
return FALSE;
}
G_DIR_SEPARATOR, "effective_tld_names.dat");
if (access (fpath->str, R_OK)) {
- msg_warn ("url_tld option is not specified but %s is available,"
+ msg_warn_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 ("no url_tld option has been specified, URL's detection "
+ msg_err_config ("no url_tld option has been specified, URL's detection "
"will be awfully broken");
}
guint32 checksum;
ucl_object_iter_t it = NULL;
const ucl_object_t *cur;
+ struct rspamd_config *cfg = data->map->cfg;
if (prev != NULL) {
if (prev->buf != NULL) {
}
if (cbdata == NULL) {
- msg_err ("map fin error: new data is NULL");
+ msg_err_config ("map fin error: new data is NULL");
return;
}
parser = ucl_parser_new (0);
if (!ucl_parser_add_chunk (parser, cbdata->buf->str,
cbdata->buf->len)) {
- msg_err ("cannot parse map %s: %s",
+ msg_err_config ("cannot parse map %s: %s",
data->map->uri,
ucl_parser_get_error (parser));
ucl_parser_free (parser);
}
}
else {
- msg_info ("do not reload map %s, checksum is the same: %d",
+ msg_info_config ("do not reload map %s, checksum is the same: %d",
data->map->uri,
checksum);
}
if (reconfig) {
(void)mod->module_reconfig_func (cfg);
- msg_debug ("reconfig of %s", mod->name);
+ msg_debug_config ("reconfig of %s", mod->name);
}
else {
(void)mod->module_config_func (cfg);
}
if (mod_ctx == NULL) {
- msg_warn ("requested unknown module %s", cur->data);
+ msg_warn_config ("requested unknown module %s", cur->data);
}
cur = g_list_next (cur);
void
rspamd_init_cfg (struct rspamd_config *cfg, gboolean init_lua)
{
- cfg->cfg_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), "config");
+ cfg->cfg_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), "cfg");
rspamd_config_defaults (cfg);
if (init_lua) {
metric = g_hash_table_lookup (cfg->metrics, metric_name);
if (metric == NULL) {
- msg_err ("metric %s has not been found", metric_name);
+ msg_err_config ("metric %s has not been found", metric_name);
return FALSE;
}
if (g_hash_table_lookup (cfg->metrics_symbols, symbol) != NULL &&
!rewrite_existing) {
- msg_debug ("symbol %s has been already registered, do not override");
+ msg_debug_config ("symbol %s has been already registered, do not override");
return FALSE;
}
sym_def->description = rspamd_mempool_strdup (cfg->cfg_pool, description);
}
- msg_debug ("registered symbol %s with weight %.2f in metric %s and group %s",
+ msg_debug_config ("registered symbol %s with weight %.2f in metric %s and group %s",
sym_def->name, score, metric->name, group);
g_hash_table_insert (metric->symbols, sym_def->name, sym_def);
}
if (!found) {
- msg_info ("internal module %s is disable in `filters` line",
+ msg_info_config ("internal module %s is disable in `filters` line",
module_name);
return FALSE;
conf = ucl_object_find_key (cfg->rcl_obj, module_name);
if (conf == NULL) {
- msg_info ("%s module %s is enabled but has not been configured",
+ msg_info_config ("%s module %s is enabled but has not been configured",
is_c ? "internal" : "lua", module_name);
if (!is_c) {
- msg_info ("%s disabling unconfigured lua module", module_name);
+ msg_info_config ("%s disabling unconfigured lua module", module_name);
return FALSE;
}
}
if (enabled && ucl_object_type (enabled) == UCL_BOOLEAN) {
if (!ucl_object_toboolean (enabled)) {
- msg_info ("%s module %s is disabled in the configuration",
+ msg_info_config ("%s module %s is disabled in the configuration",
is_c ? "internal" : "lua", module_name);
return FALSE;
}
if (gr) {
if (gr->disabled) {
- msg_info ("%s module %s is disabled in the configuration as "
+ msg_info_config ("%s module %s is disabled in the configuration as "
"its group has been disabled",
is_c ? "internal" : "lua", module_name);
return FALSE;