name="rspamd"
rcvar=`set_rcvar`
procname="@CMAKE_INSTALL_PREFIX@/bin/rspamd"
+restart_precmd="rspamd_checkconfig"
+reload_precmd="rspamd_checkconfig"
+configtest_cmd="rspamd_checkconfig"
load_rc_config $name
stop_postcmd="rm -f $rspamd_pidfile"
-extra_commands="reload"
+rspamd_checkconfig()
+{
+ echo "Performing sanity check on rspamd configuration:"
+ eval ${command} -t
+}
+
+extra_commands="reload configtest"
sig_reload="USR1"
command="$procname"
BLAH_SYMBOL = "${to_blah} & !(${from_blah} | ${subject_blah})";
};
+# If enables threat each regexp as raw regex and do not try to convert
+# each text part to utf8 encoding. Save a lot of resources but less
+# portable.
+# Default: no
+raw_mode = yes;
+
url_filters = "surbl";
header_filters = "regexp";
gboolean no_fork; /**< if 1 do not call daemon() */
gboolean config_test; /**< if TRUE do only config file test */
+ gboolean raw_mode; /**< work in raw mode instead of utf one */
unsigned int workers_number; /**< number of workers */
unsigned int lmtp_workers_number; /**< number of lmtp workers */
control return CONTROL;
password return PASSWORD;
lmtp return LMTP;
+raw_mode return RAW_MODE;
enabled return ENABLED;
delivery return DELIVERY;
agent return AGENT;
%token LOGGING LOG_TYPE LOG_TYPE_CONSOLE LOG_TYPE_SYSLOG LOG_TYPE_FILE
%token LOG_LEVEL LOG_LEVEL_DEBUG LOG_LEVEL_INFO LOG_LEVEL_WARNING LOG_LEVEL_ERROR LOG_FACILITY LOG_FILENAME
%token STATFILE ALIAS PATTERN WEIGHT STATFILE_POOL_SIZE SIZE TOKENIZER CLASSIFIER
-%token DELIVERY LMTP ENABLED AGENT SECTION LUACODE
+%token DELIVERY LMTP ENABLED AGENT SECTION LUACODE RAW_MODE
%type <string> STRING
%type <string> VARIABLE
| lmtp
| delivery
| luacode
+ | raw_mode
;
tempdir :
LUACODE
;
+raw_mode:
+ RAW_MODE EQSIGN FLAG {
+ cfg->raw_mode = $3;
+ }
+ ;
+
%%
/*
* vi:ts=4
* Rspamd regexp utility functions
*/
struct rspamd_regexp*
-parse_regexp (memory_pool_t *pool, char *line)
+parse_regexp (memory_pool_t *pool, char *line, gboolean raw_mode)
{
char *begin, *end, *p, *src;
struct rspamd_regexp *result, *check;
*end = '\0';
+ if (raw_mode) {
+ regexp_flags |= G_REGEX_RAW;
+ }
+
/* Avoid multiply regexp structures for similar regexps */
if ((check = (struct rspamd_regexp *)re_cache_check (begin)) != NULL) {
/* Additional check for headers */
if (*param_pattern == '/') {
/* This is regexp, so compile and create g_regexp object */
if ((re = re_cache_check (param_pattern)) == NULL) {
- re = parse_regexp (task->cfg->cfg_pool, param_pattern);
+ re = parse_regexp (task->cfg->cfg_pool, param_pattern, task->cfg->raw_mode);
if (re == NULL) {
msg_warn ("rspamd_content_type_compare_param: cannot compile regexp for function");
return FALSE;
if (*param_pattern == '/') {
/* This is regexp, so compile and create g_regexp object */
if ((re = re_cache_check (param_pattern)) == NULL) {
- re = parse_regexp (task->cfg->cfg_pool, param_pattern);
+ re = parse_regexp (task->cfg->cfg_pool, param_pattern, task->cfg->raw_mode);
if (re == NULL) {
msg_warn ("rspamd_content_type_compare_param: cannot compile regexp for function");
return FALSE;
if (*param_pattern == '/') {
/* This is regexp, so compile and create g_regexp object */
if ((re = re_cache_check (param_pattern)) == NULL) {
- re = parse_regexp (task->cfg->cfg_pool, param_pattern);
+ re = parse_regexp (task->cfg->cfg_pool, param_pattern, task->cfg->raw_mode);
if (re == NULL) {
msg_warn ("rspamd_content_type_compare_param: cannot compile regexp for function");
return FALSE;
if (*subtype == '/') {
/* This is regexp, so compile and create g_regexp object */
if ((re = re_cache_check (subtype)) == NULL) {
- re = parse_regexp (task->cfg->cfg_pool, subtype);
+ re = parse_regexp (task->cfg->cfg_pool, subtype, task->cfg->raw_mode);
if (re == NULL) {
msg_warn ("compare_subtype: cannot compile regexp for function");
return FALSE;
if (*param_type == '/') {
/* This is regexp, so compile and create g_regexp object */
if ((re = re_cache_check (param_type)) == NULL) {
- re = parse_regexp (task->cfg->cfg_pool, param_type);
+ re = parse_regexp (task->cfg->cfg_pool, param_type, task->cfg->raw_mode);
if (re == NULL) {
msg_warn ("rspamd_has_content_part: cannot compile regexp for function");
cur = g_list_next (cur);
* @param line incoming line
* @return regexp structure or NULL in case of error
*/
-struct rspamd_regexp* parse_regexp (memory_pool_t *pool, char *line);
+struct rspamd_regexp* parse_regexp (memory_pool_t *pool, char *line, gboolean raw_mode);
/**
* Parse composites line to composites structure (eg. "SYMBOL1&SYMBOL2|!SYMBOL3")
gchar *res_str;
GByteArray *result_array;
+ if (task->cfg->raw_mode) {
+ text_part->is_raw = TRUE;
+ return part_content;
+ }
+
if ((charset = g_mime_content_type_get_parameter (type, "charset")) == NULL) {
text_part->is_raw = TRUE;
return part_content;
}
static gboolean
-read_regexp_expression (memory_pool_t *pool, struct regexp_module_item *chain, char *symbol, char *line)
+read_regexp_expression (memory_pool_t *pool, struct regexp_module_item *chain, char *symbol, char *line, struct config_file *cfg)
{
struct expression *e, *cur;
cur = e;
while (cur) {
if (cur->type == EXPR_REGEXP) {
- cur->content.operand = parse_regexp (pool, cur->content.operand);
+ cur->content.operand = parse_regexp (pool, cur->content.operand, cfg->raw_mode);
if (cur->content.operand == NULL) {
msg_warn ("read_regexp_expression: cannot parse regexp, skip expression %s = \"%s\"", symbol, line);
return FALSE;
}
cur_item = memory_pool_alloc0 (regexp_module_ctx->regexp_pool, sizeof (struct regexp_module_item));
cur_item->symbol = cur->param;
- if (!read_regexp_expression (regexp_module_ctx->regexp_pool, cur_item, cur->param, cur->value)) {
+ if (!read_regexp_expression (regexp_module_ctx->regexp_pool, cur_item, cur->param, cur->value, cfg)) {
res = FALSE;
}
regexp_module_ctx->items = g_list_prepend (regexp_module_ctx->items, cur_item);
}
/* This is regexp, so compile and create g_regexp object */
if ((re = re_cache_check (param_pattern)) == NULL) {
- re = parse_regexp (task->task_pool, param_pattern);
+ re = parse_regexp (task->task_pool, param_pattern, task->cfg->raw_mode);
if (re == NULL) {
msg_warn ("rspamd_regexp_match_number: cannot compile regexp for function");
return FALSE;