struct dkim_check_result *next, *prev, *first;
};
-static struct dkim_ctx *dkim_module_ctx = NULL;
-
static void dkim_symbol_callback (struct rspamd_task *task, void *unused);
static void dkim_sign_callback (struct rspamd_task *task, void *unused);
(guint)-1,
};
+static inline struct dkim_ctx *
+dkim_get_context (struct rspamd_config *cfg)
+{
+ return (struct dkim_ctx *)g_ptr_array_index (cfg->c_modules,
+ dkim_module.ctx_offset);
+}
+
static void
dkim_module_key_dtor (gpointer k)
{
gint
dkim_module_init (struct rspamd_config *cfg, struct module_ctx **ctx)
{
- if (dkim_module_ctx == NULL) {
- dkim_module_ctx = g_malloc0 (sizeof (struct dkim_ctx));
+ struct dkim_ctx *dkim_module_ctx;
- dkim_module_ctx->sign_headers = default_sign_headers;
- dkim_module_ctx->sign_condition_ref = -1;
- dkim_module_ctx->max_sigs = DEFAULT_MAX_SIGS;
- }
+ dkim_module_ctx = rspamd_mempool_alloc0 (cfg->cfg_pool,
+ sizeof (*dkim_module_ctx));
+ dkim_module_ctx->sign_headers = default_sign_headers;
+ dkim_module_ctx->sign_condition_ref = -1;
+ dkim_module_ctx->max_sigs = DEFAULT_MAX_SIGS;
*ctx = (struct module_ctx *)dkim_module_ctx;
gint res = TRUE, cb_id = -1;
guint cache_size, sign_cache_size;
gboolean got_trusted = FALSE;
+ struct dkim_ctx *dkim_module_ctx = dkim_get_context (cfg);
/* Register global methods */
lua_getglobal (cfg->lua_state, "rspamd_plugins");
hex_hash[rspamd_cryptobox_HASHBYTES * 2 + 1];
rspamd_dkim_sign_key_t *ret;
GError *err = NULL;
+ struct dkim_ctx *dkim_module_ctx = dkim_get_context (task->cfg);
memset (hex_hash, 0, sizeof (hex_hash));
rspamd_cryptobox_hash (h, key, keylen, NULL, 0);
rspamd_dkim_sign_key_t *dkim_key;
gsize rawlen = 0, keylen = 0;
gboolean no_cache = FALSE, strict_pubkey_check = FALSE;
+ struct dkim_ctx *dkim_module_ctx;
luaL_argcheck (L, lua_type (L, 2) == LUA_TTABLE, 2, "'table' expected");
/*
return 1;
}
+ dkim_module_ctx = dkim_get_context (task->cfg);
+
if (headers == NULL) {
headers = dkim_module_ctx->sign_headers;
}
gint
dkim_module_reconfig (struct rspamd_config *cfg)
{
- struct module_ctx saved_ctx;
-
- saved_ctx = dkim_module_ctx->ctx;
-
- if (dkim_module_ctx->dkim_hash) {
- rspamd_lru_hash_destroy (dkim_module_ctx->dkim_hash);
- }
-
- if (dkim_module_ctx->dkim_sign_hash) {
- rspamd_lru_hash_destroy (dkim_module_ctx->dkim_sign_hash);
- }
-
- memset (dkim_module_ctx, 0, sizeof (*dkim_module_ctx));
- dkim_module_ctx->ctx = saved_ctx;
- dkim_module_ctx->sign_headers = default_sign_headers;
- dkim_module_ctx->sign_condition_ref = -1;
- dkim_module_ctx->max_sigs = DEFAULT_MAX_SIGS;
-
return dkim_module_config (cfg);
}
gboolean all_done = TRUE;
const gchar *strict_value;
struct dkim_check_result *first, *cur = NULL;
+ struct dkim_ctx *dkim_module_ctx = dkim_get_context (res->task->cfg);
first = res->first;
{
struct dkim_check_result *res = ud;
struct rspamd_task *task;
+ struct dkim_ctx *dkim_module_ctx;
task = res->task;
+ dkim_module_ctx = dkim_get_context (task->cfg);
if (key != NULL) {
/*
struct rspamd_mime_header *rh;
struct dkim_check_result *res = NULL, *cur;
guint checked = 0, i, *dmarc_checks;
+ struct dkim_ctx *dkim_module_ctx = dkim_get_context (task->cfg);
/* Allow dmarc */
dmarc_checks = rspamd_mempool_get_variable (task->task_pool,
enum rspamd_dkim_type sign_type = RSPAMD_DKIM_NORMAL;
guchar h[rspamd_cryptobox_HASHBYTES],
hex_hash[rspamd_cryptobox_HASHBYTES * 2 + 1];
+ struct dkim_ctx *dkim_module_ctx = dkim_get_context (task->cfg);
if (dkim_module_ctx->sign_condition_ref != -1) {
sign = FALSE;
struct rspamd_dkim_lua_verify_cbdata *cbd = ud;
struct rspamd_task *task;
gint ret;
+ struct dkim_ctx *dkim_module_ctx;
task = cbd->task;
+ dkim_module_ctx = dkim_get_context (task->cfg);
if (key != NULL) {
/*
GError *err = NULL;
const gchar *type_str = NULL;
enum rspamd_dkim_type type = RSPAMD_DKIM_NORMAL;
+ struct dkim_ctx *dkim_module_ctx;
if (task && sig && lua_isfunction (L, 3)) {
if (lua_isstring (L, 4)) {
}
}
+ dkim_module_ctx = dkim_get_context (task->cfg);
+
ctx = rspamd_create_dkim_context (sig,
task->task_pool,
dkim_module_ctx->time_jitter,