aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-08-15 18:41:25 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-08-15 18:41:25 +0100
commit98144000841b33d84e571f04fd56d385e8ad0a98 (patch)
treefeb7fd59686186bfeb7dc450f5e7ef2f35caa704
parente33ea5e4782b4a6e3f706634d85058d1a4f42d6b (diff)
downloadrspamd-98144000841b33d84e571f04fd56d385e8ad0a98.tar.gz
rspamd-98144000841b33d84e571f04fd56d385e8ad0a98.zip
[Feature] Allow to print message digest in logs
-rw-r--r--src/libserver/cfg_file.h3
-rw-r--r--src/libserver/cfg_utils.c4
-rw-r--r--src/libserver/task.c7
3 files changed, 12 insertions, 2 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index 005c3c984..f0e09f0b2 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -211,7 +211,8 @@ enum rspamd_log_format_type {
RSPAMD_LOG_MIME_RCPTS,
RSPAMD_LOG_TIME_REAL,
RSPAMD_LOG_TIME_VIRTUAL,
- RSPAMD_LOG_LUA
+ RSPAMD_LOG_LUA,
+ RSPAMD_LOG_DIGEST,
};
enum rspamd_log_format_flags {
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index d3bcfc03a..bb8acc33d 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -393,6 +393,10 @@ rspamd_config_process_var (struct rspamd_config *cfg, const rspamd_ftok_t *var,
else if (rspamd_ftok_cstr_equal (&tok, "lua", TRUE)) {
type = RSPAMD_LOG_LUA;
}
+ else if (rspamd_ftok_cstr_equal (&tok, "digest", TRUE) ||
+ rspamd_ftok_cstr_equal (&tok, "checksum", TRUE)) {
+ type = RSPAMD_LOG_DIGEST;
+ }
else {
msg_err_config ("unknown log variable: %T", &tok);
return FALSE;
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 47e9aa1c5..70566b6b0 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -1123,7 +1123,7 @@ rspamd_task_log_variable (struct rspamd_task *task,
{
rspamd_fstring_t *res = logbuf;
rspamd_ftok_t var = {.begin = NULL, .len = 0};
- static gchar numbuf[32];
+ static gchar numbuf[64];
switch (lf->type) {
/* String vars */
@@ -1226,6 +1226,11 @@ rspamd_task_log_variable (struct rspamd_task *task,
logbuf);
}
break;
+ case RSPAMD_LOG_DIGEST:
+ var.len = rspamd_snprintf (numbuf, sizeof (numbuf), "%*xs",
+ (gint)sizeof (task->digest), task->digest);
+ var.begin = numbuf;
+ break;
default:
var = rspamd_task_log_metric_res (task, lf);
break;