]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Add SPF method in spf return result
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 19 Aug 2016 09:27:43 +0000 (10:27 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 19 Aug 2016 09:27:43 +0000 (10:27 +0100)
Issue: #831
Reported by: @moisseev

src/plugins/spf.c

index 4af4d15bbea16567192b407719cf6cd5274ad767..6e466a11f0b218e3cd22bfbbd0cc4ed2de9d12ad 100644 (file)
@@ -338,12 +338,14 @@ spf_check_element (struct spf_resolved *rec, struct spf_addr *addr,
        }
 
        if (res) {
-               spf_result = rspamd_mempool_strdup (task->task_pool, addr->spf_string);
+               spf_result = rspamd_mempool_alloc (task->task_pool,
+                               strlen (addr->spf_string) + 2);
                opts = g_list_prepend (opts, spf_result);
 
                switch (addr->mech) {
                case SPF_FAIL:
                        spf_symbol = spf_module_ctx->symbol_fail;
+                       spf_result[0] = '-';
                        spf_message = "(SPF): spf fail";
                        if (addr->flags & RSPAMD_SPF_FLAG_ANY) {
                                if (rec->failed) {
@@ -357,6 +359,7 @@ spf_check_element (struct spf_resolved *rec, struct spf_addr *addr,
                case SPF_SOFT_FAIL:
                        spf_symbol = spf_module_ctx->symbol_softfail;
                        spf_message = "(SPF): spf softfail";
+                       spf_result[0] = '~';
 
                        if (addr->flags & RSPAMD_SPF_FLAG_ANY) {
                                if (rec->failed) {
@@ -370,13 +373,18 @@ spf_check_element (struct spf_resolved *rec, struct spf_addr *addr,
                case SPF_NEUTRAL:
                        spf_symbol = spf_module_ctx->symbol_neutral;
                        spf_message = "(SPF): spf neutral";
+                       spf_result[0] = '?';
                        break;
                default:
                        spf_symbol = spf_module_ctx->symbol_allow;
                        spf_message = "(SPF): spf allow";
+                       spf_result[0] = '+';
                        break;
                }
 
+               rspamd_strlcpy (spf_result + 1, addr->spf_string,
+                               strlen (addr->spf_string) + 1);
+
                rspamd_task_insert_result (task,
                                spf_symbol,
                                1,