static void dkim_module_check (struct rspamd_task *task, rspamd_dkim_context_t *ctx, rspamd_dkim_key_t *key) { gint res, score_allow = 1, score_deny = 1; const gchar *strict_value; msg_debug ("check dkim signature for %s domain from %s", ctx->domain, ctx->dns_key); res = rspamd_dkim_check (ctx, key, task); if (dkim_module_ctx->dkim_domains != NULL) { /* Perform strict check */ if ((strict_value = g_hash_table_lookup (dkim_module_ctx->dkim_domains, ctx->domain)) != NULL) { if (!dkim_module_parse_strict (strict_value, &score_allow, &score_deny)) { score_allow = dkim_module_ctx->strict_multiplier; score_deny = dkim_module_ctx->strict_multiplier; msg_debug ( "no specific score found for %s domain, using %d for it", ctx->domain, score_deny); } else { msg_debug ( "specific score found for %s domain: using %d for deny and %d for allow", ctx->dns_key, score_deny, score_allow); } } } if (res == DKIM_REJECT) { rspamd_task_insert_result (task, dkim_module_ctx->symbol_reject, score_deny, NULL); } else if (res == DKIM_TRYAGAIN) { rspamd_task_insert_result (task, dkim_module_ctx->symbol_tempfail, 1, NULL); } else if (res == DKIM_CONTINUE) { rspamd_task_insert_result (task, dkim_module_ctx->symbol_allow, score_allow, NULL); } }
static void dkim_module_check (struct dkim_check_result *res) { gboolean all_done = TRUE, got_allow = FALSE; const gchar *strict_value; struct dkim_check_result *first, *cur, *sel = NULL; first = res->first; DL_FOREACH (first, cur) { if (cur->ctx == NULL) { continue; } if (cur->key != NULL && cur->res == -1) { cur->res = rspamd_dkim_check (cur->ctx, cur->key, cur->task); if (dkim_module_ctx->dkim_domains != NULL) { /* Perform strict check */ if ((strict_value = g_hash_table_lookup (dkim_module_ctx->dkim_domains, rspamd_dkim_get_domain (cur->ctx))) != NULL) { if (!dkim_module_parse_strict (strict_value, &cur->mult_allow, &cur->mult_deny)) { cur->mult_allow = dkim_module_ctx->strict_multiplier; cur->mult_deny = dkim_module_ctx->strict_multiplier; } } } } if (cur->res == -1 || cur->key == NULL) { /* Still need a key */ all_done = FALSE; } } if (all_done) { DL_FOREACH (first, cur) { if (cur->ctx == NULL) { continue; } if (cur->res == DKIM_CONTINUE) { rspamd_task_insert_result (cur->task, dkim_module_ctx->symbol_allow, cur->mult_allow * 1.0, g_list_prepend (NULL, rspamd_mempool_strdup (cur->task->task_pool, rspamd_dkim_get_domain (cur->ctx)))); got_allow = TRUE; sel = NULL; } else if (!got_allow) { if (sel == NULL) { sel = cur; } else if (sel->res == DKIM_TRYAGAIN && cur->res != DKIM_TRYAGAIN) { sel = cur; } } } } if (sel != NULL) { if (sel->res == DKIM_REJECT) { rspamd_task_insert_result (sel->task, dkim_module_ctx->symbol_reject, sel->mult_deny * 1.0, g_list_prepend (NULL, rspamd_mempool_strdup (sel->task->task_pool, rspamd_dkim_get_domain (sel->ctx)))); } else { rspamd_task_insert_result (sel->task, dkim_module_ctx->symbol_tempfail, 1.0, g_list_prepend (NULL, rspamd_mempool_strdup (sel->task->task_pool, rspamd_dkim_get_domain (sel->ctx)))); } } if (all_done) { rspamd_session_watcher_pop (res->task->s, res->w); } }
static void dkim_module_check (struct dkim_check_result *res) { gboolean all_done = TRUE; const gchar *strict_value; struct dkim_check_result *first, *cur = NULL; first = res->first; DL_FOREACH (first, cur) { if (cur->ctx == NULL) { continue; } if (cur->key != NULL && cur->res == -1) { cur->res = rspamd_dkim_check (cur->ctx, cur->key, cur->task); if (dkim_module_ctx->dkim_domains != NULL) { /* Perform strict check */ if ((strict_value = g_hash_table_lookup (dkim_module_ctx->dkim_domains, rspamd_dkim_get_domain (cur->ctx))) != NULL) { if (!dkim_module_parse_strict (strict_value, &cur->mult_allow, &cur->mult_deny)) { cur->mult_allow = dkim_module_ctx->strict_multiplier; cur->mult_deny = dkim_module_ctx->strict_multiplier; } } } } } DL_FOREACH (first, cur) { if (cur->ctx == NULL) { continue; } if (cur->res == -1) { /* Still need a key */ all_done = FALSE; } } if (all_done) { DL_FOREACH (first, cur) { const gchar *symbol = NULL; int symbol_weight = 1; if (cur->ctx == NULL) { continue; } if (cur->res == DKIM_REJECT) { symbol = dkim_module_ctx->symbol_reject; symbol_weight = cur->mult_deny * 1.0; } else if (cur->res == DKIM_CONTINUE) { symbol = dkim_module_ctx->symbol_allow; symbol_weight = cur->mult_allow * 1.0; } else if (cur->res == DKIM_PERM_ERROR) { symbol = dkim_module_ctx->symbol_permfail; } else if (cur->res == DKIM_TRYAGAIN) { symbol = dkim_module_ctx->symbol_tempfail; } if (symbol != NULL) { rspamd_task_insert_result (cur->task, symbol, symbol_weight, rspamd_dkim_get_domain (cur->ctx)); } } rspamd_session_watcher_pop (res->task->s, res->w); } }