}
static void
-append_raw_header (GHashTable *target, struct raw_header *rh)
+append_raw_header (struct rspamd_task *task,
+ GHashTable *target, struct raw_header *rh)
{
struct raw_header *lp;
else {
g_hash_table_insert (target, rh->name, rh);
}
- msg_debug ("add raw header %s: %s", rh->name, rh->value);
+ msg_debug_task ("add raw header %s: %s", rh->name, rh->value);
}
/* Convert raw headers to a list of struct raw_header * */
new->decoded = g_mime_utils_header_decode_text (new->value);
rspamd_mempool_add_destructor (task->task_pool,
(rspamd_mempool_destruct_t)g_free, new->decoded);
- append_raw_header (target, new);
+ append_raw_header (task, target, new);
state = 0;
break;
case 5:
/* Header has only name, no value */
new->value = "";
new->decoded = NULL;
- append_raw_header (target, new);
+ append_raw_header (task, target, new);
state = 0;
break;
case 99:
return part_content;
}
if (!charset_validate (task->task_pool, charset, &ocharset)) {
- msg_info (
+ msg_info_task (
"<%s>: has invalid charset",
task->message_id);
SET_PART_RAW (text_part);
return part_content;
}
else {
- msg_info (
+ msg_info_task (
"<%s>: contains invalid utf8 characters, assume it as raw",
task->message_id);
SET_PART_RAW (text_part);
&write_bytes,
&err);
if (res_str == NULL) {
- msg_warn ("<%s>: cannot convert from %s to utf8: %s",
+ msg_warn_task ("<%s>: cannot convert from %s to utf8: %s",
task->message_id,
ocharset,
err ? err->message : "unknown problem");
if (part->language && part->language[0] != '\0' && IS_PART_UTF (part)) {
stem = sb_stemmer_new (part->language, "UTF_8");
if (stem == NULL) {
- msg_info ("<%s> cannot create lemmatizer for %s language",
+ msg_info_task ("<%s> cannot create lemmatizer for %s language",
task->message_id, part->language);
}
}
#define MIN3(a, b, c) ((a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c)))
-static gint
-rspamd_words_levenshtein_distance (GArray *w1, GArray *w2)
+static guint
+rspamd_words_levenshtein_distance (struct rspamd_task *task,
+ GArray *w1, GArray *w2)
{
guint s1len, s2len, x, y, lastdiag, olddiag;
guint *column;
s2len = w2->len;
if (s1len > max_words) {
- msg_err ("cannot compare parts with more than %ud words: %ud",
+ msg_err_task ("cannot compare parts with more than %ud words: %ud",
max_words, s1len);
return 0;
}
rspamd_gtube_cb, NULL, &state, FALSE)) {
task->flags |= RSPAMD_TASK_FLAG_SKIP;
task->flags |= RSPAMD_TASK_FLAG_GTUBE;
- msg_info ("<%s>: gtube pattern has been found in part of length %ud",
+ msg_info_task ("<%s>: gtube pattern has been found in part of length %ud",
task->message_id, part->content->len);
return TRUE;
#endif
}
else {
- msg_err ("too deep mime recursion detected: %d", md->parser_recursion);
+ msg_err_task ("too deep mime recursion detected: %d", md->parser_recursion);
return;
}
#ifndef GMIME24
md);
}
else {
- msg_err ("endless recursion detected: %d", task->parser_recursion);
+ msg_err_task ("endless recursion detected: %d", task->parser_recursion);
return;
}
#endif
#endif
if (type == NULL) {
- msg_warn ("type of part is unknown, assume text/plain");
+ msg_warn_task ("type of part is unknown, assume text/plain");
type = g_mime_content_type_new ("text", "plain");
#ifdef GMIME24
rspamd_mempool_add_destructor (task->task_pool,
(part_content->len <= 0));
}
else {
- msg_warn ("write to stream failed: %d, %s", errno,
+ msg_warn_task ("write to stream failed: %d, %s", errno,
strerror (errno));
}
#ifndef GMIME24
#endif
}
else {
- msg_warn ("cannot get wrapper for mime part, type of part: %s/%s",
+ msg_warn_task ("cannot get wrapper for mime part, type of part: %s/%s",
type->type,
type->subtype);
}
{
GMimeMessage *msg = pointer;
- msg_debug ("freeing pointer %p", msg);
g_object_unref (msg);
}
message = g_mime_parser_construct_message (parser);
if (message == NULL) {
- msg_warn ("cannot construct mime from stream");
+ msg_warn_task ("cannot construct mime from stream");
g_set_error (&task->err, rspamd_message_quark(), RSPAMD_FILTER_ERROR,\
"cannot parse MIME in the message");
/* TODO: backport to 0.9 */
recv = g_ptr_array_index (task->received, 0);
if (recv->real_ip) {
if (!rspamd_parse_inet_address (&task->from_addr, recv->real_ip)) {
- msg_warn ("cannot get IP from received header: '%s'",
+ msg_warn_task ("cannot get IP from received header: '%s'",
recv->real_ip);
task->from_addr = NULL;
}
}
}
else if (rc != URI_ERRNO_OK) {
- msg_info ("extract of url '%s' failed: %s",
+ msg_info_task ("extract of url '%s' failed: %s",
url_str,
rspamd_url_strerror (rc));
}
tw = MAX (p1->normalized_words->len, p2->normalized_words->len);
if (tw > 0) {
- dw = rspamd_words_levenshtein_distance (p1->normalized_words,
+ dw = rspamd_words_levenshtein_distance (task,
+ p1->normalized_words,
p2->normalized_words);
diff = tw > 0 ? (100.0 * (gdouble)(tw - dw) / (gdouble)tw) : 100;
GString *re_flags;
if (line == NULL) {
- msg_err ("cannot parse NULL line");
+ msg_err_pool ("cannot parse NULL line");
return NULL;
}
line++;
}
if (*line == '\0') {
- msg_warn ("got empty regexp");
+ msg_warn_pool ("got empty regexp");
return NULL;
}
start = line;
}
else {
/* We got header name earlier but have not found // expression, so it is invalid regexp */
- msg_warn (
+ msg_warn_pool (
"got no header name (eg. header=) but without corresponding regexp, %s",
src);
return NULL;
end++;
}
if (end == begin || *end != '/') {
- msg_warn ("no trailing / in regexp %s", src);
+ msg_warn_pool ("no trailing / in regexp %s", src);
return NULL;
}
/* Parse flags */
g_string_free (re_flags, TRUE);
if (result->regexp == NULL || err != NULL) {
- msg_warn ("could not read regexp: %s while reading regexp %s",
+ msg_warn_pool ("could not read regexp: %s while reading regexp %s",
err ? err->message : "unknown error",
src);
return NULL;
}
if (G_UNLIKELY (re->is_test)) {
- msg_info (
+ msg_info_task (
"process %s test regexp %s returned %d",
rspamd_mime_regexp_type_to_string (re),
re->regexp_text,
{
struct url_regexp_param *param = data;
struct rspamd_url *url = value;
+ struct rspamd_task *task;
gint ret;
if (param->found && ! param->re->is_multiple) {
return;
}
+ task = param->task;
ret = rspamd_mime_regexp_element_process (param->task, param->re,
struri (url), 0, FALSE);
param->found = ret;
if (G_UNLIKELY (param->re->is_test)) {
- msg_info ("process test regexp %s for url %s returned FALSE",
+ msg_info_task ("process test regexp %s for url %s returned FALSE",
struri (url));
}
}
struct raw_header *rh;
if (re == NULL) {
- msg_info ("invalid regexp passed");
+ msg_info_task ("invalid regexp passed");
return 0;
}
switch (re->type) {
case REGEXP_NONE:
- msg_warn ("bad error detected: %s has invalid regexp type",
+ msg_warn_task ("bad error detected: %s has invalid regexp type",
re->regexp_text);
break;
case REGEXP_HEADER:
case REGEXP_RAW_HEADER:
/* Check header's name */
if (re->header == NULL) {
- msg_info ("header regexp without header name: '%s'",
+ msg_info_task ("header regexp without header name: '%s'",
re->regexp_text);
rspamd_task_re_cache_add (task, re->regexp_text, 0);
return 0;
if (headerlist == NULL) {
/* Header is not found */
if (G_UNLIKELY (re->is_test)) {
- msg_info (
+ msg_info_task (
"process test regexp %s for header %s returned FALSE: no header found",
re->regexp_text,
re->header);
ret = callback_param.found;
break;
default:
- msg_warn ("bad error detected: %p is not a valid regexp object", re);
+ msg_warn_task ("bad error detected: %p is not a valid regexp object", re);
return 0;
break;
}
rspamd_lua_task_push (L, task);
if (lua_pcall (L, 1, 1, 0) != 0) {
- msg_info ("lua call to global function '%s' for atom '%s' failed: %s",
+ msg_info_task ("lua call to global function '%s' for atom '%s' failed: %s",
mime_atom->d.lua_function,
mime_atom->str,
lua_tostring (L, -1));
ret = lua_tonumber (L, 1);
}
else {
- msg_err ("%s returned wrong return type: %s",
+ msg_err_task ("%s returned wrong return type: %s",
mime_atom->str, lua_typename (L, lua_type (L, -1)));
}
/* Remove result */
arg = &g_array_index (args, struct expression_argument, 0);
if (!arg || arg->type != EXPRESSION_ARGUMENT_NORMAL) {
- msg_warn ("invalid argument to function is passed");
+ msg_warn_task ("invalid argument to function is passed");
return FALSE;
}
arg = &g_array_index (args, struct expression_argument, 0);
if (!arg || arg->type != EXPRESSION_ARGUMENT_NORMAL) {
- msg_warn ("invalid argument to function is passed");
+ msg_warn_task ("invalid argument to function is passed");
return FALSE;
}
errno = 0;
arg = &g_array_index (args, struct expression_argument, 0);
if (!arg || arg->type != EXPRESSION_ARGUMENT_NORMAL) {
- msg_warn ("invalid argument to function is passed");
+ msg_warn_task ("invalid argument to function is passed");
return FALSE;
}
threshold = strtoul ((gchar *)arg->data, NULL, 10);
if (errno != 0) {
- msg_info ("bad numeric value for threshold \"%s\", assume it 100",
+ msg_info_task ("bad numeric value for threshold \"%s\", assume it 100",
(gchar *)arg->data);
threshold = 100;
}
if (args->len >= 2) {
arg = &g_array_index (args, struct expression_argument, 1);
if (!arg || arg->type != EXPRESSION_ARGUMENT_NORMAL) {
- msg_warn ("invalid argument to function is passed");
+ msg_warn_task ("invalid argument to function is passed");
return FALSE;
}
errno = 0;
threshold2 = strtoul ((gchar *)arg->data, NULL, 10);
if (errno != 0) {
- msg_info ("bad numeric value for threshold \"%s\", ignore it",
+ msg_info_task ("bad numeric value for threshold \"%s\", ignore it",
(gchar *)arg->data);
threshold2 = -1;
}
gint num, i, j, hits = 0, total = 0;
if (args == NULL) {
- msg_warn ("no parameters to function");
+ msg_warn_task ("no parameters to function");
return FALSE;
}
arg = &g_array_index (args, struct expression_argument, 0);
if (!arg || arg->type != EXPRESSION_ARGUMENT_NORMAL) {
- msg_warn ("invalid argument to function is passed");
+ msg_warn_task ("invalid argument to function is passed");
return FALSE;
}
threshold = strtod ((gchar *)arg->data, NULL);
if (errno != 0) {
- msg_warn ("invalid numeric value '%s': %s",
+ msg_warn_task ("invalid numeric value '%s': %s",
(gchar *)arg->data,
strerror (errno));
return FALSE;
struct expression_argument *arg;
if (args == NULL) {
- msg_warn ("no parameters to function");
+ msg_warn_task ("no parameters to function");
return FALSE;
}
arg = &g_array_index (args, struct expression_argument, 0);
if (!arg || arg->type != EXPRESSION_ARGUMENT_NORMAL) {
- msg_warn ("invalid argument to function is passed");
+ msg_warn_task ("invalid argument to function is passed");
return FALSE;
}
enc_req = g_mime_content_encoding_from_string (arg->data);
if (enc_req == GMIME_CONTENT_ENCODING_DEFAULT) {
#endif
- msg_warn ("bad encoding type: %s", (gchar *)arg->data);
+ msg_warn_task ("bad encoding type: %s", (gchar *)arg->data);
return FALSE;
}
gboolean res = FALSE;
if (args == NULL) {
- msg_warn ("no parameters to function");
+ msg_warn_task ("no parameters to function");
return FALSE;
}
arg = &g_array_index (args, struct expression_argument, 0);
if (!arg || arg->type != EXPRESSION_ARGUMENT_NORMAL) {
- msg_warn ("invalid argument to function is passed");
+ msg_warn_task ("invalid argument to function is passed");
return FALSE;
}
arg = &g_array_index (args, struct expression_argument, 0);
if (!arg || arg->type != EXPRESSION_ARGUMENT_NORMAL) {
- msg_warn ("invalid argument to function is passed");
+ msg_warn_task ("invalid argument to function is passed");
return FALSE;
}
/* This is a regexp */
re = arg->data;
if (re == NULL) {
- msg_warn ("cannot compile regexp for function");
+ msg_warn_task ("cannot compile regexp for function");
return FALSE;
}
gint i, ialen;
if (args == NULL) {
- msg_warn ("no parameters to function");
+ msg_warn_task ("no parameters to function");
return FALSE;
}
arg = &g_array_index (args, struct expression_argument, 0);
if (!arg || !arg->data || arg->type != EXPRESSION_ARGUMENT_NORMAL) {
- msg_warn ("no parameters to function");
+ msg_warn_task ("no parameters to function");
return FALSE;
}
else {
what = rspamd_task_get_sender (task);
}
else {
- msg_warn ("bad argument to function: %s", type);
+ msg_warn_task ("bad argument to function: %s", type);
return FALSE;
}
break;
what = task->helo;
}
else {
- msg_warn ("bad argument to function: %s", type);
+ msg_warn_task ("bad argument to function: %s", type);
return FALSE;
}
break;
what = task->user;
}
else {
- msg_warn ("bad argument to function: %s", type);
+ msg_warn_task ("bad argument to function: %s", type);
return FALSE;
}
break;
what = task->subject;
}
else {
- msg_warn ("bad argument to function: %s", type);
+ msg_warn_task ("bad argument to function: %s", type);
return FALSE;
}
break;
ia = task->rcpt_mime;
}
else {
- msg_warn ("bad argument to function: %s", type);
+ msg_warn_task ("bad argument to function: %s", type);
return FALSE;
}
break;
default:
- msg_warn ("bad argument to function: %s", type);
+ msg_warn_task ("bad argument to function: %s", type);
return FALSE;
}
}
struct mime_part *cur_part;
if (args == NULL || args->len < 2) {
- msg_warn ("no parameters to function");
+ msg_warn_task ("no parameters to function");
return FALSE;
}
struct mime_part *cur_part;
if (args == NULL || args->len < 1) {
- msg_warn ("no parameters to function");
+ msg_warn_task ("no parameters to function");
return FALSE;
}
struct mime_part *cur_part;
if (args == NULL || args->len < 1) {
- msg_warn ("no parameters to function");
+ msg_warn_task ("no parameters to function");
return FALSE;
}
gint r = 0;
if (subtype == NULL || ct == NULL) {
- msg_warn ("invalid parameters passed");
+ msg_warn_task ("invalid parameters passed");
return FALSE;
}
if (subtype->type == EXPRESSION_ARGUMENT_REGEXP) {
struct expression_argument *param_type = NULL, *param_subtype = NULL;
if (args == NULL) {
- msg_warn ("no parameters to function");
+ msg_warn_task ("no parameters to function");
return FALSE;
}
struct expression_argument *arg;
if (args == NULL) {
- msg_warn ("no parameters to function");
+ msg_warn_task ("no parameters to function");
return FALSE;
}
g_assert (arg->type == EXPRESSION_ARGUMENT_NORMAL);
if (errno != 0) {
- msg_warn ("invalid numeric value '%s': %s",
+ msg_warn_task ("invalid numeric value '%s': %s",
(gchar *)arg->data,
strerror (errno));
return FALSE;
max = strtoul (arg->data, NULL, 10);
if (errno != 0) {
- msg_warn ("invalid numeric value '%s': %s",
+ msg_warn_task ("invalid numeric value '%s': %s",
(gchar *)arg->data,
strerror (errno));
return FALSE;