]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Created mailbox_alloc_delivery(), which initializes a mailbox for messag...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Wed, 13 Sep 2017 23:56:38 +0000 (01:56 +0200)
committerTimo Sirainen <tss@dovecot.fi>
Wed, 4 Oct 2017 22:07:46 +0000 (01:07 +0300)
src/lib-storage/mail-storage.c
src/lib-storage/mail-storage.h

index e472b3efc983f176fba01af93018c9a604bc35ed..4faf4e8c8aa10f494bf7bd0f5569e591f68424b4 100644 (file)
@@ -869,6 +869,32 @@ struct mailbox *mailbox_alloc_guid(struct mailbox_list *list,
        return box;
 }
 
+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;
+
+       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 (strcasecmp(name, "INBOX") == 0) {
+               /* deliveries to INBOX must always succeed,
+                  regardless of ACLs */
+               flags |= MAILBOX_FLAG_IGNORE_ACLS;
+       }
+
+       return mailbox_alloc(ns->list, name, flags);
+}
+
 void mailbox_set_reason(struct mailbox *box, const char *reason)
 {
        i_assert(reason != NULL);
index 9b9a967185ff0127418f3c0d6fea5c1b225c9b37..179aa5e347a363d5ce09dd62f2c20ba8b408d1c4 100644 (file)
@@ -510,6 +510,10 @@ struct mailbox *mailbox_alloc(struct mailbox_list *list, const char *vname,
 struct mailbox *mailbox_alloc_guid(struct mailbox_list *list,
                                   const guid_128_t guid,
                                   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);