From 002ca3959c25278ff4eccc3b3caf77ed73188e79 Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan@rename-it.nl> Date: Sat, 11 Oct 2014 01:33:15 +0200 Subject: [PATCH] LDA Sieve plugin: Fixed handling of temporary SMTP errors. These caused a BUG error to be reported during delivery. Solved by signalling the occurrence of storage errors as a separate execution status flag, rather than querying the last storage itself for errors, which won't work. --- src/lib-sieve/sieve-actions.c | 15 ++++++++++++--- src/lib-sieve/sieve-result.c | 2 +- src/lib-sieve/sieve-types.h | 10 ++++++---- src/plugins/lda-sieve/lda-sieve-plugin.c | 3 ++- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/lib-sieve/sieve-actions.c b/src/lib-sieve/sieve-actions.c index 33f7aaf20..07da005f1 100644 --- a/src/lib-sieve/sieve-actions.c +++ b/src/lib-sieve/sieve-actions.c @@ -409,7 +409,8 @@ static int act_store_start * to NULL. This implementation will then skip actually storing the message. */ if ( senv->user != NULL ) { - if ( !act_store_mailbox_open(aenv, ctx->mailbox, &box, &error_code, &error) ) { + if ( !act_store_mailbox_open + (aenv, ctx->mailbox, &box, &error_code, &error) ) { open_failed = TRUE; } } else { @@ -697,6 +698,8 @@ static int act_store_commit /* Note the fact that the message was stored at least once */ if ( status ) aenv->exec_status->message_saved = TRUE; + else + aenv->exec_status->store_failed = TRUE; /* Log our status */ act_store_log_status(trans, aenv, FALSE, status); @@ -722,6 +725,13 @@ static void act_store_rollback struct act_store_transaction *trans = (struct act_store_transaction *) tr_context; + i_assert( trans->box != NULL ); + + if (!success) { + aenv->exec_status->last_storage = mailbox_get_storage(trans->box); + aenv->exec_status->store_failed = TRUE; + } + /* Log status */ act_store_log_status(trans, aenv, TRUE, success); @@ -734,8 +744,7 @@ static void act_store_rollback mailbox_transaction_rollback(&trans->mail_trans); /* Close the mailbox */ - if ( trans->box != NULL ) - mailbox_free(&trans->box); + mailbox_free(&trans->box); } /* diff --git a/src/lib-sieve/sieve-result.c b/src/lib-sieve/sieve-result.c index 97359ccc1..42cde221f 100644 --- a/src/lib-sieve/sieve-result.c +++ b/src/lib-sieve/sieve-result.c @@ -1143,7 +1143,6 @@ int sieve_result_execute act->def->execute != NULL ) { status = act->def->execute (act, &result->action_env, rac->tr_context); - rac->success = ( status == SIEVE_EXEC_OK ); } /* Execute post-execute event of side effects */ @@ -1156,6 +1155,7 @@ int sieve_result_execute rsef = rsef->next; } + rac->success = ( status == SIEVE_EXEC_OK ); rac = rac->next; } diff --git a/src/lib-sieve/sieve-types.h b/src/lib-sieve/sieve-types.h index e6a61baae..293e29888 100644 --- a/src/lib-sieve/sieve-types.h +++ b/src/lib-sieve/sieve-types.h @@ -227,11 +227,13 @@ struct sieve_script_env { */ struct sieve_exec_status { - bool message_saved; - bool message_forwarded; - bool tried_default_save; - bool keep_original; struct mail_storage *last_storage; + + unsigned int message_saved:1; + unsigned int message_forwarded:1; + unsigned int tried_default_save:1; + unsigned int keep_original:1; + unsigned int store_failed:1; }; /* diff --git a/src/plugins/lda-sieve/lda-sieve-plugin.c b/src/plugins/lda-sieve/lda-sieve-plugin.c index 19d5fdda7..406070b73 100644 --- a/src/plugins/lda-sieve/lda-sieve-plugin.c +++ b/src/plugins/lda-sieve/lda-sieve-plugin.c @@ -381,7 +381,8 @@ static int lda_sieve_handle_exec_status error_func = user_error_func = sieve_sys_error; - if ( estatus != NULL && estatus->last_storage != NULL ) { + if ( estatus != NULL && estatus->last_storage != NULL && + estatus->store_failed) { mail_storage_get_last_error(estatus->last_storage, &mail_error); /* Don't bother administrator too much with benign errors */ -- GitLab