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

Fixed logging of folder namespace prefix in store action.

parent 59c13056
No related branches found
No related tags found
No related merge requests found
...@@ -186,8 +186,8 @@ static void act_store_get_storage_error ...@@ -186,8 +186,8 @@ static void act_store_get_storage_error
} }
static struct mailbox *act_store_mailbox_open static struct mailbox *act_store_mailbox_open
(const struct sieve_action_exec_env *aenv, struct mail_namespace *ns, (const struct sieve_action_exec_env *aenv, const char *folder,
const char *folder, const char **error_r) struct mail_namespace **ns_r)
{ {
struct mail_storage **storage = &(aenv->exec_status->last_storage); struct mail_storage **storage = &(aenv->exec_status->last_storage);
enum mailbox_flags flags = enum mailbox_flags flags =
...@@ -196,15 +196,26 @@ static struct mailbox *act_store_mailbox_open ...@@ -196,15 +196,26 @@ static struct mailbox *act_store_mailbox_open
struct mailbox *box; struct mailbox *box;
enum mail_error error; enum mail_error error;
*error_r = NULL;
if (strcasecmp(folder, "INBOX") == 0) { if (strcasecmp(folder, "INBOX") == 0) {
/* Deliveries to INBOX must always succeed, regardless of ACLs */ /* Deliveries to INBOX must always succeed, regardless of ACLs */
flags |= MAILBOX_FLAG_IGNORE_ACLS; flags |= MAILBOX_FLAG_IGNORE_ACLS;
} }
*ns_r = mail_namespace_find(aenv->scriptenv->namespaces, &folder);
if ( *ns_r == NULL) {
*storage = NULL;
return NULL;
}
if ( *folder == '\0' ) {
/* delivering to a namespace prefix means we actually want to
* deliver to the INBOX instead
*/
folder = "INBOX";
}
/* First attempt at opening the box */ /* First attempt at opening the box */
box = mailbox_alloc(ns->list, folder, NULL, flags); box = mailbox_alloc((*ns_r)->list, folder, NULL, flags);
if ( mailbox_open(box) == 0 ) { if ( mailbox_open(box) == 0 ) {
/* Success */ /* Success */
return box; return box;
...@@ -213,7 +224,7 @@ static struct mailbox *act_store_mailbox_open ...@@ -213,7 +224,7 @@ static struct mailbox *act_store_mailbox_open
/* Failed */ /* Failed */
*storage = mailbox_get_storage(box); *storage = mailbox_get_storage(box);
*error_r = mail_storage_get_last_error(*storage, &error); (void)mail_storage_get_last_error(*storage, &error);
/* Only continue when the mailbox is missing and when we are allowed to /* Only continue when the mailbox is missing and when we are allowed to
* create it. * create it.
...@@ -225,20 +236,19 @@ static struct mailbox *act_store_mailbox_open ...@@ -225,20 +236,19 @@ static struct mailbox *act_store_mailbox_open
/* Try creating it. */ /* Try creating it. */
if ( mailbox_create(box, NULL, FALSE) < 0 ) { if ( mailbox_create(box, NULL, FALSE) < 0 ) {
*error_r = mail_storage_get_last_error(*storage, &error); (void)mail_storage_get_last_error(*storage, &error);
mailbox_close(&box); mailbox_close(&box);
return NULL; return NULL;
} }
/* Subscribe to it if required */ /* Subscribe to it if required */
if ( aenv->scriptenv->mailbox_autosubscribe ) { if ( aenv->scriptenv->mailbox_autosubscribe ) {
(void)mailbox_list_set_subscribed(ns->list, folder, TRUE); (void)mailbox_list_set_subscribed((*ns_r)->list, folder, TRUE);
} }
/* Try opening again */ /* Try opening again */
if ( mailbox_open(box) < 0 || mailbox_sync(box, 0, 0, NULL) < 0 ) { if ( mailbox_open(box) < 0 || mailbox_sync(box, 0, 0, NULL) < 0 ) {
/* Failed definitively */ /* Failed definitively */
*error_r = mail_storage_get_last_error(*storage, &error);
mailbox_close(&box); mailbox_close(&box);
return NULL; return NULL;
} }
...@@ -255,7 +265,6 @@ static bool act_store_start ...@@ -255,7 +265,6 @@ static bool act_store_start
struct mail_namespace *ns = NULL; struct mail_namespace *ns = NULL;
struct mailbox *box = NULL; struct mailbox *box = NULL;
pool_t pool = sieve_result_pool(aenv->result); pool_t pool = sieve_result_pool(aenv->result);
const char *open_error = NULL;
/* If context is NULL, the store action is the result of (implicit) keep */ /* If context is NULL, the store action is the result of (implicit) keep */
if ( ctx == NULL ) { if ( ctx == NULL ) {
...@@ -269,11 +278,7 @@ static bool act_store_start ...@@ -269,11 +278,7 @@ static bool act_store_start
* to NULL. This implementation will then skip actually storing the message. * to NULL. This implementation will then skip actually storing the message.
*/ */
if ( aenv->scriptenv->namespaces != NULL ) { if ( aenv->scriptenv->namespaces != NULL ) {
ns = mail_namespace_find(aenv->scriptenv->namespaces, &ctx->folder); box = act_store_mailbox_open(aenv, ctx->folder, &ns);
if ( ns != NULL ) {
box = act_store_mailbox_open(aenv, ns, ctx->folder, &open_error);
}
} }
/* Create transaction context */ /* Create transaction context */
...@@ -282,7 +287,6 @@ static bool act_store_start ...@@ -282,7 +287,6 @@ static bool act_store_start
trans->namespace = ns; trans->namespace = ns;
trans->box = box; trans->box = box;
trans->flags = 0; trans->flags = 0;
trans->error = open_error;
*tr_context = (void *)trans; *tr_context = (void *)trans;
......
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.