Explorar el Código

[Fix] Fix DKIM check rule if DNS is unavailable

tags/1.7.8
Vsevolod Stakhov hace 6 años
padre
commit
6716825ffd
Se han modificado 2 ficheros con 33 adiciones y 21 borrados
  1. 4
    1
      lualib/lua_squeeze_rules.lua
  2. 29
    20
      src/plugins/dkim_check.c

+ 4
- 1
lualib/lua_squeeze_rules.lua Ver fichero

return {data[1](task)} return {data[1](task)}
end end


-- Too expensive to call :(
--logger.debugm(SN, task, 'call for: %s', data[2])
local status, ret = pcall(real_call) local status, ret = pcall(real_call)


if not status then if not status then
-- and create squeezed rules -- and create squeezed rules
for k,v in pairs(squeezed_symbols) do for k,v in pairs(squeezed_symbols) do
local parent_symbol = get_ordered_symbol_name(v.order) local parent_symbol = get_ordered_symbol_name(v.order)
logger.debugm(SN, rspamd_config, 'added squeezed rule: %s (%s)', k, parent_symbol)
logger.debugm(SN, rspamd_config, 'added squeezed rule: %s (%s): %s',
k, parent_symbol, v)
rspamd_config:register_symbol{ rspamd_config:register_symbol{
type = 'virtual', type = 'virtual',
name = k, name = k,

+ 29
- 20
src/plugins/dkim_check.c Ver fichero

rspamd_dkim_key_t *key; rspamd_dkim_key_t *key;
struct rspamd_task *task; struct rspamd_task *task;
gint res; gint res;
gint mult_allow, mult_deny;
gdouble mult_allow;
gdouble mult_deny;
struct rspamd_async_watcher *w; struct rspamd_async_watcher *w;
struct dkim_check_result *next, *prev, *first; struct dkim_check_result *next, *prev, *first;
}; };
* Parse strict value for domain in format: 'reject_multiplier:deny_multiplier' * Parse strict value for domain in format: 'reject_multiplier:deny_multiplier'
*/ */
static gboolean static gboolean
dkim_module_parse_strict (const gchar *value, gint *allow, gint *deny)
dkim_module_parse_strict (const gchar *value, gdouble *allow, gdouble *deny)
{ {
const gchar *colon; const gchar *colon;
gulong val;
gchar *err = NULL;
gdouble val;
gchar numbuf[64];


colon = strchr (value, ':'); colon = strchr (value, ':');
if (colon) { if (colon) {
if (rspamd_strtoul (value, colon - value, &val)) {
rspamd_strlcpy (numbuf, value,
MIN (sizeof (numbuf), (colon - value) + 1));
val = strtod (numbuf, &err);

if (err == NULL || *err == '\0') {
*deny = val; *deny = val;
colon++; colon++;
if (rspamd_strtoul (colon, strlen (colon), &val)) {
rspamd_strlcpy (numbuf, colon, sizeof (numbuf));
err = NULL;
val = strtod (numbuf, &err);

if (err == NULL || *err == '\0') {
*allow = val; *allow = val;
return TRUE; return TRUE;
} }
if (all_done) { if (all_done) {
DL_FOREACH (first, cur) { DL_FOREACH (first, cur) {
const gchar *symbol = NULL, *trace = NULL; const gchar *symbol = NULL, *trace = NULL;
int symbol_weight = 1;
gdouble symbol_weight = 1.0;


if (cur->ctx == NULL) { if (cur->ctx == NULL) {
continue; continue;
continue; continue;
} }


if (res == NULL) {
res = rspamd_mempool_alloc0 (task->task_pool, sizeof (*res));
res->prev = res;
res->w = rspamd_session_get_watcher (task->s);
cur = res;
}
else {
cur = rspamd_mempool_alloc0 (task->task_pool, sizeof (*res));
}

cur = rspamd_mempool_alloc0 (task->task_pool, sizeof (*cur));
cur->first = res; cur->first = res;
cur->res = -1; cur->res = -1;
cur->w = res->w;
cur->task = task; cur->task = task;
cur->mult_allow = 1.0; cur->mult_allow = 1.0;
cur->mult_deny = 1.0; cur->mult_deny = 1.0;
dkim_module_key_dtor, cur->key); dkim_module_key_dtor, cur->key);
} }
else { else {
rspamd_get_dkim_key (ctx,
if (!rspamd_get_dkim_key (ctx,
task, task,
dkim_module_key_handler, dkim_module_key_handler,
cur);
cur)) {
continue;
}
} }
} }


if (res != cur) {
if (res == NULL) {
res = cur;
res->prev = res;
res->w = rspamd_session_get_watcher (task->s);
}
else {
cur->w = res->w;
DL_APPEND (res, cur); DL_APPEND (res, cur);
} }



Cargando…
Cancelar
Guardar