From: Stephan Bosch Date: Wed, 2 Oct 2019 22:43:07 +0000 (+0200) Subject: lib-storage: mail-storage - Merge mailbox_alloc_delivery() into mailbox_alloc_for_user(). X-Git-Tag: 2.3.9~112 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c24280d525f2d1b33797f418d71e3652b97d21ab;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: mail-storage - Merge mailbox_alloc_delivery() into mailbox_alloc_for_user(). Uses the MAILBOX_FLAG_POST_SESSION flag. --- diff --git a/src/lib-lda/mail-deliver.c b/src/lib-lda/mail-deliver.c index d1d3d499aa..c4761aed50 100644 --- a/src/lib-lda/mail-deliver.c +++ b/src/lib-lda/mail-deliver.c @@ -227,7 +227,7 @@ int mail_deliver_save_open(struct mail_deliver_save_open_context *ctx, enum mail_error *error_r, const char **error_str_r) { struct mailbox *box; - enum mailbox_flags flags = 0; + enum mailbox_flags flags = MAILBOX_FLAG_POST_SESSION; *box_r = NULL; *error_r = MAIL_ERROR_NONE; @@ -243,7 +243,7 @@ int mail_deliver_save_open(struct mail_deliver_save_open_context *ctx, flags |= MAILBOX_FLAG_AUTO_CREATE; if (ctx->lda_mailbox_autosubscribe) flags |= MAILBOX_FLAG_AUTO_SUBSCRIBE; - *box_r = box = mailbox_alloc_delivery(ctx->user, name, flags); + *box_r = box = mailbox_alloc_for_user(ctx->user, name, flags); if (mailbox_open(box) == 0) return 0; diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index faddf57b09..7ebfbc2d83 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -919,33 +919,25 @@ mailbox_alloc_for_user(struct mail_user *user, const char *vname, ns = mail_namespace_find(user->namespaces, vname); - return mailbox_alloc(ns->list, vname, flags); -} - -struct mailbox *mailbox_alloc_delivery(struct mail_user *user, - const char *name, enum mailbox_flags flags) -{ - struct mail_namespace *ns; - - flags |= MAILBOX_FLAG_SAVEONLY | - MAILBOX_FLAG_POST_SESSION; + if (HAS_ALL_BITS(flags, MAILBOX_FLAG_POST_SESSION)) { + flags |= MAILBOX_FLAG_SAVEONLY; - ns = mail_namespace_find(user->namespaces, name); - if (strcmp(name, ns->prefix) == 0 && - (ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) { - /* delivering to a namespace prefix means we actually want to - deliver to the INBOX instead */ - name = "INBOX"; - ns = mail_namespace_find_inbox(user->namespaces); - } + if (strcmp(vname, ns->prefix) == 0 && + (ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) { + /* delivering to a namespace prefix means we actually + want to deliver to the INBOX instead */ + vname = "INBOX"; + ns = mail_namespace_find_inbox(user->namespaces); + } - if (strcasecmp(name, "INBOX") == 0) { - /* deliveries to INBOX must always succeed, - regardless of ACLs */ - flags |= MAILBOX_FLAG_IGNORE_ACLS; + if (strcasecmp(vname, "INBOX") == 0) { + /* deliveries to INBOX must always succeed, + regardless of ACLs */ + flags |= MAILBOX_FLAG_IGNORE_ACLS; + } } - return mailbox_alloc(ns->list, name, flags); + return mailbox_alloc(ns->list, vname, flags); } void mailbox_set_reason(struct mailbox *box, const char *reason) diff --git a/src/lib-storage/mail-storage.h b/src/lib-storage/mail-storage.h index 81535311a0..0bff34621a 100644 --- a/src/lib-storage/mail-storage.h +++ b/src/lib-storage/mail-storage.h @@ -527,10 +527,7 @@ struct mailbox *mailbox_alloc_guid(struct mailbox_list *list, struct mailbox * mailbox_alloc_for_user(struct mail_user *user, const char *vname, enum mailbox_flags flags); -/* Initialize mailbox for delivery without actually opening any files or - verifying that it exists. */ -struct mailbox *mailbox_alloc_delivery(struct mail_user *user, - const char *name, enum mailbox_flags flags); + /* Set a human-readable reason for why this mailbox is being accessed. This is used for logging purposes. */ void mailbox_set_reason(struct mailbox *box, const char *reason);