From cf5025c7a00e92a40484626b5ced5fa594f1bc49 Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan@rename-it.nl> Date: Tue, 21 Oct 2008 21:49:14 +0200 Subject: [PATCH] Properly set storage_r in plugin function to prevent double errors. --- src/lib-sieve/sieve-actions.c | 5 ++++- src/lib-sieve/sieve-types.h | 7 ++++--- src/plugins/lda-sieve/lda-sieve-plugin.c | 25 ++++++++++++++---------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/lib-sieve/sieve-actions.c b/src/lib-sieve/sieve-actions.c index 2ffc967d0..17e3fc5aa 100644 --- a/src/lib-sieve/sieve-actions.c +++ b/src/lib-sieve/sieve-actions.c @@ -219,8 +219,11 @@ static bool act_store_start if ( aenv->scriptenv->namespaces != NULL ) { ns = mail_namespace_find(aenv->scriptenv->namespaces, &ctx->folder); - if ( ns != NULL ) + if ( ns != NULL ) { box = act_store_mailbox_open(aenv, ns, ctx->folder); + + aenv->estatus->last_storage = ns->storage; + } } /* Create transaction context */ diff --git a/src/lib-sieve/sieve-types.h b/src/lib-sieve/sieve-types.h index b44a81f39..9c49e6a76 100644 --- a/src/lib-sieve/sieve-types.h +++ b/src/lib-sieve/sieve-types.h @@ -78,6 +78,7 @@ struct sieve_exec_status { bool message_saved; bool message_forwarded; bool tried_default_save; + struct sieve_storage *last_storage; }; /* @@ -85,9 +86,9 @@ struct sieve_exec_status { */ enum sieve_execution_exitcode { - SIEVE_EXEC_OK = 1, - SIEVE_EXEC_FAILURE = 0, - SIEVE_EXEC_BIN_CORRUPT = -1, + SIEVE_EXEC_OK = 1, + SIEVE_EXEC_FAILURE = 0, + SIEVE_EXEC_BIN_CORRUPT = -1, SIEVE_EXEC_KEEP_FAILED = -2 }; diff --git a/src/plugins/lda-sieve/lda-sieve-plugin.c b/src/plugins/lda-sieve/lda-sieve-plugin.c index 5d6fd4209..364cd3fdc 100644 --- a/src/plugins/lda-sieve/lda-sieve-plugin.c +++ b/src/plugins/lda-sieve/lda-sieve-plugin.c @@ -97,7 +97,8 @@ static const char *lda_sieve_get_path(void) static int lda_sieve_run (struct mail_namespace *namespaces, struct mail *mail, const char *script_path, - const char *destaddr, const char *username, const char *mailbox) + const char *destaddr, const char *username, const char *mailbox, + struct mail_storage **storage_r) { bool debug = ( getenv("DEBUG") != NULL ); struct sieve_message_data msgdata; @@ -109,6 +110,8 @@ static int lda_sieve_run bool exists = TRUE; int ret = 0; + *storage_r = NULL; + /* Create error handler */ scriptlog = t_strconcat(script_path, ".log", NULL); ehandler = sieve_logfile_ehandler_create(scriptlog, LDA_SIEVE_MAX_ERRORS); @@ -170,6 +173,7 @@ static int lda_sieve_run /* Record status */ tried_default_save = estatus.tried_default_save; + *storage_r = estatus.last_storage; /* Evaluate result */ @@ -189,12 +193,11 @@ static int lda_sieve_run sieve_error_handler_copy_masterlog(ehandler, FALSE); if ( (sbin=sieve_compile(script_path, ehandler)) == NULL ) { - sieve_sys_error("failed to compile script %s; " - "log should be available as %s", script_path, scriptlog); - - sieve_error_handler_unref(&ehandler); - return -1; - } + sieve_sys_error("failed to compile script %s; " + "log should be available as %s", script_path, scriptlog); + sieve_error_handler_unref(&ehandler); + return -1; + } sieve_error_handler_copy_masterlog(ehandler, TRUE); @@ -205,6 +208,7 @@ static int lda_sieve_run /* Record status */ tried_default_save = estatus.tried_default_save; + *storage_r = estatus.last_storage; /* Save new version */ @@ -237,7 +241,7 @@ static int lda_sieve_run } static int lda_sieve_deliver_mail -(struct mail_namespace *namespaces, struct mail_storage **storage_r ATTR_UNUSED, +(struct mail_namespace *namespaces, struct mail_storage **storage_r, struct mail *mail, const char *destaddr, const char *mailbox) { const char *script_path; @@ -255,8 +259,9 @@ static int lda_sieve_deliver_mail /* Run the script */ T_BEGIN { - ret = lda_sieve_run(namespaces, mail, script_path, destaddr, - getenv("USER"), mailbox); + ret = lda_sieve_run + (namespaces, mail, script_path, destaddr, getenv("USER"), mailbox, + storage_r); } T_END; return ( ret >= 0 ? 1 : -1 ); -- GitLab