aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2010-04-26 17:50:13 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2010-04-26 17:50:13 +0400
commit971bad45c44cf430bde13faede56699ba0381e83 (patch)
treed82e66c29b32430ea39729bc3fa8e478ddd14e50 /src
parent5b9251914c25fa6559e5680f03d7efddad9af736 (diff)
downloadrspamd-971bad45c44cf430bde13faede56699ba0381e83.tar.gz
rspamd-971bad45c44cf430bde13faede56699ba0381e83.zip
* Add ability to pass all filters by using flag -p in case of rspamc or adding header Pass: all in rspamc protocol
Diffstat (limited to 'src')
-rw-r--r--src/filter.c8
-rw-r--r--src/main.h1
-rw-r--r--src/protocol.c35
3 files changed, 30 insertions, 14 deletions
diff --git a/src/filter.c b/src/filter.c
index a300820da..e2d6d80b8 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -286,7 +286,9 @@ continue_process_filters (struct worker_task *task)
return 0;
}
else if (check_metric_is_spam (task, metric)) {
- break;
+ if (!task->pass_all_filters) {
+ break;
+ }
}
}
cur = g_list_next (cur);
@@ -337,7 +339,9 @@ process_filters (struct worker_task *task)
return 0;
}
else if (check_metric_is_spam (task, metric)) {
- break;
+ if (!task->pass_all_filters) {
+ break;
+ }
}
}
cur = g_list_next (cur);
diff --git a/src/main.h b/src/main.h
index 028954c71..04b45b8d5 100644
--- a/src/main.h
+++ b/src/main.h
@@ -213,6 +213,7 @@ struct worker_task {
struct timespec ts; /**< time of connection */
struct rspamd_view *view; /**< matching view */
gboolean view_checked;
+ gboolean pass_all_filters; /**< pass task throught every rule */
uint32_t parser_recursion; /**< for avoiding recursion stack overflow */
};
diff --git a/src/protocol.c b/src/protocol.c
index 8da0f174d..e7dc86e9a 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -84,6 +84,7 @@
#define QUEUE_ID_HEADER "Queue-ID"
#define ERROR_HEADER "Error"
#define USER_HEADER "User"
+#define PASS_HEADER "Pass"
#define DELIVER_TO_HEADER "Deliver-To"
static GList *custom_commands = NULL;
@@ -200,7 +201,7 @@ parse_command (struct worker_task *task, f_str_t * line)
break;
}
- if (strncasecmp (line->begin, RSPAMC_GREETING, sizeof (RSPAMC_GREETING) - 1) == 0) {
+ if (g_ascii_strncasecmp (line->begin, RSPAMC_GREETING, sizeof (RSPAMC_GREETING) - 1) == 0) {
task->proto = RSPAMC_PROTO;
task->proto_ver = RSPAMC_PROTO_1_0;
if (*(line->begin + sizeof (RSPAMC_GREETING) - 1) == '/') {
@@ -211,7 +212,7 @@ parse_command (struct worker_task *task, f_str_t * line)
}
}
}
- else if (strncasecmp (line->begin, SPAMC_GREETING, sizeof (SPAMC_GREETING) - 1) == 0) {
+ else if (g_ascii_strncasecmp (line->begin, SPAMC_GREETING, sizeof (SPAMC_GREETING) - 1) == 0) {
task->proto = SPAMC_PROTO;
}
else {
@@ -262,7 +263,7 @@ parse_header (struct worker_task *task, f_str_t * line)
case 'c':
case 'C':
/* content-length */
- if (strncasecmp (headern, CONTENT_LENGTH_HEADER, sizeof (CONTENT_LENGTH_HEADER) - 1) == 0) {
+ if (g_ascii_strncasecmp (headern, CONTENT_LENGTH_HEADER, sizeof (CONTENT_LENGTH_HEADER) - 1) == 0) {
if (task->content_length == 0) {
tmp = memory_pool_fstrdup (task->task_pool, line);
task->content_length = strtoul (tmp, &err, 10);
@@ -277,7 +278,7 @@ parse_header (struct worker_task *task, f_str_t * line)
case 'd':
case 'D':
/* Deliver-To */
- if (strncasecmp (headern, DELIVER_TO_HEADER, sizeof (DELIVER_TO_HEADER) - 1) == 0) {
+ if (g_ascii_strncasecmp (headern, DELIVER_TO_HEADER, sizeof (DELIVER_TO_HEADER) - 1) == 0) {
task->deliver_to = memory_pool_fstrdup (task->task_pool, line);
debug_task ("read deliver-to header, value: %s", task->deliver_to);
}
@@ -289,7 +290,7 @@ parse_header (struct worker_task *task, f_str_t * line)
case 'h':
case 'H':
/* helo */
- if (strncasecmp (headern, HELO_HEADER, sizeof (HELO_HEADER) - 1) == 0) {
+ if (g_ascii_strncasecmp (headern, HELO_HEADER, sizeof (HELO_HEADER) - 1) == 0) {
task->helo = memory_pool_fstrdup (task->task_pool, line);
debug_task ("read helo header, value: %s", task->helo);
}
@@ -301,7 +302,7 @@ parse_header (struct worker_task *task, f_str_t * line)
case 'f':
case 'F':
/* from */
- if (strncasecmp (headern, FROM_HEADER, sizeof (FROM_HEADER) - 1) == 0) {
+ if (g_ascii_strncasecmp (headern, FROM_HEADER, sizeof (FROM_HEADER) - 1) == 0) {
task->from = memory_pool_fstrdup (task->task_pool, line);
debug_task ("read from header, value: %s", task->from);
}
@@ -313,7 +314,7 @@ parse_header (struct worker_task *task, f_str_t * line)
case 'q':
case 'Q':
/* Queue id */
- if (strncasecmp (headern, QUEUE_ID_HEADER, sizeof (QUEUE_ID_HEADER) - 1) == 0) {
+ if (g_ascii_strncasecmp (headern, QUEUE_ID_HEADER, sizeof (QUEUE_ID_HEADER) - 1) == 0) {
task->queue_id = memory_pool_fstrdup (task->task_pool, line);
debug_task ("read queue_id header, value: %s", task->queue_id);
}
@@ -325,12 +326,12 @@ parse_header (struct worker_task *task, f_str_t * line)
case 'r':
case 'R':
/* rcpt */
- if (strncasecmp (headern, RCPT_HEADER, sizeof (RCPT_HEADER) - 1) == 0) {
+ if (g_ascii_strncasecmp (headern, RCPT_HEADER, sizeof (RCPT_HEADER) - 1) == 0) {
tmp = memory_pool_fstrdup (task->task_pool, line);
task->rcpt = g_list_prepend (task->rcpt, tmp);
debug_task ("read rcpt header, value: %s", tmp);
}
- else if (strncasecmp (headern, NRCPT_HEADER, sizeof (NRCPT_HEADER) - 1) == 0) {
+ else if (g_ascii_strncasecmp (headern, NRCPT_HEADER, sizeof (NRCPT_HEADER) - 1) == 0) {
tmp = memory_pool_fstrdup (task->task_pool, line);
task->nrcpt = strtoul (tmp, &err, 10);
debug_task ("read rcpt header, value: %d", (int)task->nrcpt);
@@ -343,7 +344,7 @@ parse_header (struct worker_task *task, f_str_t * line)
case 'i':
case 'I':
/* ip_addr */
- if (strncasecmp (headern, IP_ADDR_HEADER, sizeof (IP_ADDR_HEADER) - 1) == 0) {
+ if (g_ascii_strncasecmp (headern, IP_ADDR_HEADER, sizeof (IP_ADDR_HEADER) - 1) == 0) {
tmp = memory_pool_fstrdup (task->task_pool, line);
if (!inet_aton (tmp, &task->from_addr)) {
msg_info ("bad ip header: '%s'", tmp);
@@ -356,9 +357,19 @@ parse_header (struct worker_task *task, f_str_t * line)
return -1;
}
break;
+ case 'p':
+ case 'P':
+ /* Pass header */
+ if (g_ascii_strncasecmp (headern, PASS_HEADER, sizeof (PASS_HEADER) - 1) == 0) {
+ if (line->len == sizeof ("all") - 1 && g_ascii_strncasecmp (line->begin, "all", sizeof ("all") - 1) == 0) {
+ task->pass_all_filters = TRUE;
+ msg_info ("pass all filters");
+ }
+ }
+ break;
case 's':
case 'S':
- if (strncasecmp (headern, SUBJECT_HEADER, sizeof (SUBJECT_HEADER) - 1) == 0) {
+ if (g_ascii_strncasecmp (headern, SUBJECT_HEADER, sizeof (SUBJECT_HEADER) - 1) == 0) {
task->subject = memory_pool_fstrdup (task->task_pool, line);
}
else {
@@ -367,7 +378,7 @@ parse_header (struct worker_task *task, f_str_t * line)
break;
case 'u':
case 'U':
- if (strncasecmp (headern, USER_HEADER, sizeof (USER_HEADER) - 1) == 0) {
+ if (g_ascii_strncasecmp (headern, USER_HEADER, sizeof (USER_HEADER) - 1) == 0) {
/* XXX: use this header somehow */
task->user = memory_pool_fstrdup (task->task_pool, line);
}