Skip to content
Snippets Groups Projects
Commit cf5025c7 authored by Stephan Bosch's avatar Stephan Bosch
Browse files

Properly set storage_r in plugin function to prevent double errors.

parent ff2b8ffd
No related branches found
No related tags found
No related merge requests found
...@@ -219,8 +219,11 @@ static bool act_store_start ...@@ -219,8 +219,11 @@ static bool act_store_start
if ( aenv->scriptenv->namespaces != NULL ) { if ( aenv->scriptenv->namespaces != NULL ) {
ns = mail_namespace_find(aenv->scriptenv->namespaces, &ctx->folder); ns = mail_namespace_find(aenv->scriptenv->namespaces, &ctx->folder);
if ( ns != NULL ) if ( ns != NULL ) {
box = act_store_mailbox_open(aenv, ns, ctx->folder); box = act_store_mailbox_open(aenv, ns, ctx->folder);
aenv->estatus->last_storage = ns->storage;
}
} }
/* Create transaction context */ /* Create transaction context */
......
...@@ -78,6 +78,7 @@ struct sieve_exec_status { ...@@ -78,6 +78,7 @@ struct sieve_exec_status {
bool message_saved; bool message_saved;
bool message_forwarded; bool message_forwarded;
bool tried_default_save; bool tried_default_save;
struct sieve_storage *last_storage;
}; };
/* /*
...@@ -85,9 +86,9 @@ struct sieve_exec_status { ...@@ -85,9 +86,9 @@ struct sieve_exec_status {
*/ */
enum sieve_execution_exitcode { enum sieve_execution_exitcode {
SIEVE_EXEC_OK = 1, SIEVE_EXEC_OK = 1,
SIEVE_EXEC_FAILURE = 0, SIEVE_EXEC_FAILURE = 0,
SIEVE_EXEC_BIN_CORRUPT = -1, SIEVE_EXEC_BIN_CORRUPT = -1,
SIEVE_EXEC_KEEP_FAILED = -2 SIEVE_EXEC_KEEP_FAILED = -2
}; };
......
...@@ -97,7 +97,8 @@ static const char *lda_sieve_get_path(void) ...@@ -97,7 +97,8 @@ static const char *lda_sieve_get_path(void)
static int lda_sieve_run static int lda_sieve_run
(struct mail_namespace *namespaces, struct mail *mail, const char *script_path, (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 ); bool debug = ( getenv("DEBUG") != NULL );
struct sieve_message_data msgdata; struct sieve_message_data msgdata;
...@@ -109,6 +110,8 @@ static int lda_sieve_run ...@@ -109,6 +110,8 @@ static int lda_sieve_run
bool exists = TRUE; bool exists = TRUE;
int ret = 0; int ret = 0;
*storage_r = NULL;
/* Create error handler */ /* Create error handler */
scriptlog = t_strconcat(script_path, ".log", NULL); scriptlog = t_strconcat(script_path, ".log", NULL);
ehandler = sieve_logfile_ehandler_create(scriptlog, LDA_SIEVE_MAX_ERRORS); ehandler = sieve_logfile_ehandler_create(scriptlog, LDA_SIEVE_MAX_ERRORS);
...@@ -170,6 +173,7 @@ static int lda_sieve_run ...@@ -170,6 +173,7 @@ static int lda_sieve_run
/* Record status */ /* Record status */
tried_default_save = estatus.tried_default_save; tried_default_save = estatus.tried_default_save;
*storage_r = estatus.last_storage;
/* Evaluate result */ /* Evaluate result */
...@@ -189,12 +193,11 @@ static int lda_sieve_run ...@@ -189,12 +193,11 @@ static int lda_sieve_run
sieve_error_handler_copy_masterlog(ehandler, FALSE); sieve_error_handler_copy_masterlog(ehandler, FALSE);
if ( (sbin=sieve_compile(script_path, ehandler)) == NULL ) { if ( (sbin=sieve_compile(script_path, ehandler)) == NULL ) {
sieve_sys_error("failed to compile script %s; " sieve_sys_error("failed to compile script %s; "
"log should be available as %s", script_path, scriptlog); "log should be available as %s", script_path, scriptlog);
sieve_error_handler_unref(&ehandler);
sieve_error_handler_unref(&ehandler); return -1;
return -1; }
}
sieve_error_handler_copy_masterlog(ehandler, TRUE); sieve_error_handler_copy_masterlog(ehandler, TRUE);
...@@ -205,6 +208,7 @@ static int lda_sieve_run ...@@ -205,6 +208,7 @@ static int lda_sieve_run
/* Record status */ /* Record status */
tried_default_save = estatus.tried_default_save; tried_default_save = estatus.tried_default_save;
*storage_r = estatus.last_storage;
/* Save new version */ /* Save new version */
...@@ -237,7 +241,7 @@ static int lda_sieve_run ...@@ -237,7 +241,7 @@ static int lda_sieve_run
} }
static int lda_sieve_deliver_mail 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) struct mail *mail, const char *destaddr, const char *mailbox)
{ {
const char *script_path; const char *script_path;
...@@ -255,8 +259,9 @@ static int lda_sieve_deliver_mail ...@@ -255,8 +259,9 @@ static int lda_sieve_deliver_mail
/* Run the script */ /* Run the script */
T_BEGIN { T_BEGIN {
ret = lda_sieve_run(namespaces, mail, script_path, destaddr, ret = lda_sieve_run
getenv("USER"), mailbox); (namespaces, mail, script_path, destaddr, getenv("USER"), mailbox,
storage_r);
} T_END; } T_END;
return ( ret >= 0 ? 1 : -1 ); return ( ret >= 0 ? 1 : -1 );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.