diff --git a/src/lib-sieve/cmd-redirect.c b/src/lib-sieve/cmd-redirect.c index 790be62a8c942215f380407a0f6bc5b34022e17d..4ac6daa7799b1a83ebacffb59c4cbc56b9f5e9c4 100644 --- a/src/lib-sieve/cmd-redirect.c +++ b/src/lib-sieve/cmd-redirect.c @@ -307,15 +307,13 @@ act_redirect_send(const struct sieve_action_exec_env *aenv, struct mail *mail, /* Just to be sure */ if (!sieve_smtp_available(senv)) { - sieve_result_global_warning( - aenv, "redirect action: no means to send mail"); + sieve_result_global_warning(aenv, "no means to send mail"); return SIEVE_EXEC_FAILURE; } if (mail_get_stream(mail, NULL, NULL, &input) < 0) { - return sieve_result_mail_error( - aenv, mail, "redirect action: " - "failed to read input message"); + return sieve_result_mail_error(aenv, mail, + "failed to read input message"); } /* Determine which sender to use @@ -387,12 +385,10 @@ act_redirect_send(const struct sieve_action_exec_env *aenv, struct mail *mail, o_stream_nsend_istream(output, input); if (input->stream_errno != 0) { - sieve_result_critical( - aenv, "redirect action: " - "failed to read input message", - "redirect action: read(%s) failed: %s", - i_stream_get_name(input), - i_stream_get_error(input)); + sieve_result_critical(aenv, "failed to read input message", + "read(%s) failed: %s", + i_stream_get_name(input), + i_stream_get_error(input)); i_stream_unref(&input); sieve_smtp_abort(sctx); return SIEVE_EXEC_TEMP_FAILURE; @@ -403,8 +399,7 @@ act_redirect_send(const struct sieve_action_exec_env *aenv, struct mail *mail, if ((ret = sieve_smtp_finish(sctx, &error)) <= 0) { if (ret < 0) { sieve_result_global_error( - aenv, "redirect action: " - "failed to redirect message to <%s>: %s " + aenv, "failed to redirect message to <%s>: %s " "(temporary failure)", smtp_address_encode(ctx->to_address), str_sanitize(error, 512)); @@ -412,8 +407,7 @@ act_redirect_send(const struct sieve_action_exec_env *aenv, struct mail *mail, } sieve_result_global_log_error( - aenv, "redirect action: " - "failed to redirect message to <%s>: %s " + aenv, "failed to redirect message to <%s>: %s " "(permanent failure)", smtp_address_encode(ctx->to_address), str_sanitize(error, 512)); @@ -438,18 +432,18 @@ act_redirect_get_duplicate_id(struct act_redirect_context *ctx, /* Read identifying headers */ if (mail_get_first_header(mail, "resent-message-id", &resent_id) < 0) { return sieve_result_mail_error( - aenv, mail, "redirect action: " + aenv, mail, "failed to read header field `resent-message-id'"); } if (resent_id == NULL && mail_get_first_header(mail, "resent-from", &resent_id) < 0) { return sieve_result_mail_error( - aenv, mail, "redirect action: " + aenv, mail, "failed to read header field `resent-from'"); } if (mail_get_first_header(mail, "list-id", &list_id) < 0) { return sieve_result_mail_error( - aenv, mail, "redirect action: " + aenv, mail, "failed to read header field `list-id'"); } @@ -491,8 +485,7 @@ act_redirect_check_loop_header(const struct sieve_action_exec_env *aenv, ret = mail_get_headers(mail, "x-sieve-redirected-from", &headers); if (ret < 0) { return sieve_result_mail_error( - aenv, mail, "redirect action: " - "failed to read header field " + aenv, mail, "failed to read header field " "`x-sieve-redirected-from'"); } @@ -561,8 +554,7 @@ act_redirect_commit(const struct sieve_action_exec_env *aenv, /* Check whether we've seen this message before */ if (sieve_action_duplicate_check(senv, dupeid, strlen(dupeid))) { sieve_result_global_log( - aenv, "redirect action: " - "discarded duplicate forward to <%s>", + aenv, "discarded duplicate forward to <%s>", smtp_address_encode(ctx->to_address)); *keep = FALSE; return SIEVE_EXEC_OK; @@ -575,8 +567,7 @@ act_redirect_commit(const struct sieve_action_exec_env *aenv, return ret; if (loop_detected) { sieve_result_global_log( - aenv, "redirect action: " - "not forwarding message to <%s>: " + aenv, "not forwarding message to <%s>: " "the `x-sieve-redirected-from' header indicates a mail loop", smtp_address_encode(ctx->to_address)); return SIEVE_EXEC_OK; @@ -595,7 +586,7 @@ act_redirect_commit(const struct sieve_action_exec_env *aenv, eenv->exec_status->significant_action_executed = TRUE; sieve_result_global_log( - aenv, "redirect action: forwarded to <%s>", + aenv, "forwarded to <%s>", smtp_address_encode(ctx->to_address)); /* Indicate that message was successfully forwarded */ diff --git a/src/lib-sieve/plugins/enotify/cmd-notify.c b/src/lib-sieve/plugins/enotify/cmd-notify.c index 88f749217be7f6c5b00640a09d749f8a0f6f0c39..39b7ed4ba0f020e9b924ab3d70fc1af9b081cb99 100644 --- a/src/lib-sieve/plugins/enotify/cmd-notify.c +++ b/src/lib-sieve/plugins/enotify/cmd-notify.c @@ -609,14 +609,11 @@ act_notify_commit(const struct sieve_action_exec_env *aenv, nenv.msgdata = eenv->msgdata; nenv.msgctx = aenv->msgctx; - nenv.ehandler = sieve_prefix_ehandler_create( - aenv->ehandler, NULL, "notify action"); + nenv.ehandler = aenv->ehandler; ret = method->def->action_execute(&nenv, act); if (ret >= 0) eenv->exec_status->significant_action_executed = TRUE; - - sieve_error_handler_unref(&nenv.ehandler); } return (ret >= 0 ? SIEVE_EXEC_OK : SIEVE_EXEC_TEMP_FAILURE); diff --git a/src/lib-sieve/plugins/notify/cmd-notify.c b/src/lib-sieve/plugins/notify/cmd-notify.c index ca666f805cace00ccfc893980163251d19540318..dc95a4af3b673ea8bdc7805aaf115213b71f24fd 100644 --- a/src/lib-sieve/plugins/notify/cmd-notify.c +++ b/src/lib-sieve/plugins/notify/cmd-notify.c @@ -857,7 +857,7 @@ act_notify_commit(const struct sieve_action_exec_env *aenv, /* Is the message an automatic reply ? */ if ((ret = mail_get_headers(mail, "auto-submitted", &hdsp)) < 0) { return sieve_result_mail_error( - aenv, mail, "notify action: " + aenv, mail, "failed to read `auto-submitted' header field"); } diff --git a/src/lib-sieve/plugins/vacation/cmd-vacation.c b/src/lib-sieve/plugins/vacation/cmd-vacation.c index 6673a7c276a8bb02a508dcc0c4872fa99de7718e..aa796b27cb460ab131e46cd71fc618ca3493834f 100644 --- a/src/lib-sieve/plugins/vacation/cmd-vacation.c +++ b/src/lib-sieve/plugins/vacation/cmd-vacation.c @@ -951,7 +951,7 @@ _get_full_reply_recipient(const struct sieve_action_exec_env *aenv, if ((ret = mail_get_first_header(msgdata->mail, *hdsp, &header)) < 0) { return sieve_result_mail_error( - aenv, msgdata->mail, "vacation action: " + aenv, msgdata->mail, "failed to read header field `%s'", *hdsp); } if (ret > 0 && header != NULL) { @@ -1021,7 +1021,7 @@ act_vacation_get_default_subject(const struct sieve_action_exec_env *aenv, if ((ret = mail_get_first_header_utf8(msgdata->mail, "subject", &header)) < 0) { return sieve_result_mail_error( - aenv, msgdata->mail, "vacation action: " + aenv, msgdata->mail, "failed to read header field `subject'"); } if (ret == 0) @@ -1130,7 +1130,7 @@ act_vacation_send(const struct sieve_action_exec_env *aenv, &header)) < 0) { sieve_smtp_abort(sctx); return sieve_result_mail_error( - aenv, msgdata->mail, "vacation action: " + aenv, msgdata->mail, "failed to read header field `references'"); } @@ -1302,7 +1302,7 @@ act_vacation_commit(const struct sieve_action_exec_env *aenv, while (*hdsp != NULL) { if ((ret = mail_get_headers(mail, *hdsp, &headers)) < 0) { return sieve_result_mail_error( - aenv, mail, "vacation action: " + aenv, mail, "failed to read header field `%s'", *hdsp); } @@ -1320,7 +1320,7 @@ act_vacation_commit(const struct sieve_action_exec_env *aenv, /* Is the message that we are replying to an automatic reply ? */ if ((ret = mail_get_headers(mail, "auto-submitted", &headers)) < 0) { return sieve_result_mail_error( - aenv, mail, "vacation action: " + aenv, mail, "failed to read header field `auto-submitted'"); } /* Theoretically multiple headers could exist, so lets make sure */ @@ -1341,8 +1341,7 @@ act_vacation_commit(const struct sieve_action_exec_env *aenv, /* Check for the (non-standard) precedence header */ if ((ret = mail_get_headers(mail, "precedence", &headers)) < 0) { return sieve_result_mail_error( - aenv, mail, "vacation action: " - "failed to read header field `precedence'"); + aenv, mail, "failed to read header field `precedence'"); } /* Theoretically multiple headers could exist, so lets make sure */ if (ret > 0) { @@ -1365,7 +1364,7 @@ act_vacation_commit(const struct sieve_action_exec_env *aenv, if ((ret = mail_get_headers(mail, "x-auto-response-suppress", &headers)) < 0) { return sieve_result_mail_error( - aenv, mail, "vacation action: " + aenv, mail, "failed to read header field `x-auto-response-suppress'"); } /* Theoretically multiple headers could exist, so lets make sure */ @@ -1413,8 +1412,8 @@ act_vacation_commit(const struct sieve_action_exec_env *aenv, while (*hdsp != NULL) { if ((ret = mail_get_headers(mail, *hdsp, &headers)) < 0) { return sieve_result_mail_error( - aenv, mail, "vacation action: " - "failed to read header field `%s'", *hdsp); + aenv, mail, "failed to read header field `%s'", + *hdsp); } if (ret > 0 && headers[0] != NULL) { /* Final recipient directly listed in headers? */ diff --git a/src/lib-sieve/plugins/vnd.dovecot/report/cmd-report.c b/src/lib-sieve/plugins/vnd.dovecot/report/cmd-report.c index 64f924bbe69e29cc7c4da807631dc4952a240c48..bb930c150a766e78825b63bc0dcc73dc82f20558 100644 --- a/src/lib-sieve/plugins/vnd.dovecot/report/cmd-report.c +++ b/src/lib-sieve/plugins/vnd.dovecot/report/cmd-report.c @@ -477,7 +477,7 @@ act_report_send(const struct sieve_action_exec_env *aenv, if ((ret = mail_get_headers_utf8(msgdata->mail, "subject", &headers)) < 0) { return sieve_result_mail_error( - aenv, msgdata->mail, "report action: " + aenv, msgdata->mail, "failed to read header field `subject'"); } if (ret > 0 && headers[0] != NULL) @@ -609,19 +609,18 @@ act_report_send(const struct sieve_action_exec_env *aenv, } if (ret < 0) { sieve_smtp_abort(sctx); - return sieve_result_mail_error( - aenv, msgdata->mail, "report action: " - "failed to read input message"); + return sieve_result_mail_error(aenv, msgdata->mail, + "failed to read input message"); } o_stream_nsend_istream(output, input); if (input->stream_errno != 0) { /* Error; clean up */ - sieve_result_critical( - aenv, "report action: failed to read input message", - "report action: read(%s) failed: %s", - i_stream_get_name(input), i_stream_get_error(input)); + sieve_result_critical(aenv, "failed to read input message", + "read(%s) failed: %s", + i_stream_get_name(input), + i_stream_get_error(input)); i_stream_unref(&input); sieve_smtp_abort(sctx); return SIEVE_EXEC_OK; diff --git a/src/lib-sieve/sieve-result.c b/src/lib-sieve/sieve-result.c index f23833ee71df218ee9c1ef745a7ac58d4c6f4f61..0bd27e30cb2ab6449ce3dfd8d94c5d7ae93c252b 100644 --- a/src/lib-sieve/sieve-result.c +++ b/src/lib-sieve/sieve-result.c @@ -248,14 +248,19 @@ sieve_result_extension_get_context(struct sieve_result *result, static void sieve_result_init_action_event(struct sieve_result *result, - struct sieve_action *action) + struct sieve_action *action, bool add_prefix) { + const char *name = sieve_action_name(action); + if (action->event != NULL) return; action->event = event_create(result->event); - event_add_str(action->event, "sieve_action_name", - sieve_action_name(action)); + if (add_prefix && name != NULL) { + event_set_append_log_prefix( + action->event, t_strconcat(name, " action: ", NULL)); + } + event_add_str(action->event, "sieve_action_name", name); event_add_str(action->event, "sieve_action_script_location", action->location); } @@ -640,7 +645,7 @@ _sieve_result_add_action(const struct sieve_runtime_env *renv, raction->action.mail = NULL; } - sieve_result_init_action_event(result, &raction->action); + sieve_result_init_action_event(result, &raction->action, !keep); return 0; } @@ -982,7 +987,7 @@ _sieve_result_implicit_keep(struct sieve_result *result, bool rollback) } /* Initialize keep action event */ - sieve_result_init_action_event(result, &act_keep); + sieve_result_init_action_event(result, &act_keep, FALSE); /* Start keep action */ if (act_keep.def->start != NULL) { diff --git a/src/plugins/sieve-extprograms/cmd-pipe.c b/src/plugins/sieve-extprograms/cmd-pipe.c index 3bee2d8b9d6c1d39f1bc95bc8ed928062739be1f..1590680af8436cc733299510bfcf92a0c72665a3 100644 --- a/src/plugins/sieve-extprograms/cmd-pipe.c +++ b/src/plugins/sieve-extprograms/cmd-pipe.c @@ -350,8 +350,7 @@ act_pipe_commit(const struct sieve_action_exec_env *aenv, if (sieve_extprogram_set_input_mail(sprog, mail) < 0) { sieve_extprogram_destroy(&sprog); return sieve_result_mail_error( - aenv, mail, "pipe action: " - "failed to read input message"); + aenv, mail, "failed to read input message"); } ret = sieve_extprogram_run(sprog); } else { @@ -361,8 +360,7 @@ act_pipe_commit(const struct sieve_action_exec_env *aenv, sieve_extprogram_destroy(&sprog); if (ret > 0) { - sieve_result_global_log(aenv, "pipe action: " - "piped message to program `%s'", + sieve_result_global_log(aenv, "piped message to program `%s'", str_sanitize(act->program_name, 128)); /* Indicate that message was successfully 'forwarded' */ @@ -371,19 +369,19 @@ act_pipe_commit(const struct sieve_action_exec_env *aenv, if (ret < 0) { if (error == SIEVE_ERROR_NOT_FOUND) { sieve_result_error( - aenv, "pipe action: " + aenv, "failed to pipe message to program: " "program `%s' not found", str_sanitize(act->program_name, 80)); } else { sieve_extprogram_exec_error( - aenv->ehandler, NULL, "pipe action: " + aenv->ehandler, NULL, "failed to pipe message to program `%s'", str_sanitize(act->program_name, 80)); } } else { sieve_extprogram_exec_error( - aenv->ehandler, NULL, "pipe action: " + aenv->ehandler, NULL, "failed to execute to program `%s'", str_sanitize(act->program_name, 80)); }