changeset 16279:309abf35676e

lib-storage: mailbox_list_index=yes wasn't working with ACLs.
author Timo Sirainen <tss@iki.fi>
date Thu, 11 Apr 2013 16:54:53 +0300
parents 17b037da123b
children 81a111f1c420
files src/lib-storage/list/mailbox-list-index.c
diffstat 1 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/list/mailbox-list-index.c	Thu Apr 11 16:19:35 2013 +0300
+++ b/src/lib-storage/list/mailbox-list-index.c	Thu Apr 11 16:54:53 2013 +0300
@@ -536,7 +536,7 @@
 	return 0;
 }
 
-static void mailbox_list_index_created(struct mailbox_list *list)
+static void mailbox_list_index_created_last(struct mailbox_list *list)
 {
 	struct mailbox_list_index *ilist;
 	bool has_backing_store;
@@ -643,6 +643,24 @@
 	mailbox_list_index_backend_init_mailbox(box);
 }
 
+static struct mail_storage_hooks mailbox_list_index_hooks_last = {
+	.mailbox_list_created = mailbox_list_index_created_last
+};
+static bool mailbox_list_index_hooks_last_added = FALSE;
+
+static void mailbox_list_index_created(struct mailbox_list *list ATTR_UNUSED)
+{
+	/* We want our mailbox list index hooks to be called just before the
+	   backend methods are called. Most importantly the ACL plugin's hooks
+	   must be called before us, otherwise we'll end up skipping them and
+	   showing all the mailboxes. So we do this dual-registration where
+	   this second one gets us into the correct position. */
+	if (!mailbox_list_index_hooks_last_added) {
+		mailbox_list_index_hooks_last_added = TRUE;
+		mail_storage_hooks_add_internal(&mailbox_list_index_hooks_last);
+	}
+}
+
 static struct mail_storage_hooks mailbox_list_index_hooks = {
 	.mailbox_list_created = mailbox_list_index_created,
 	.mail_namespaces_added = mailbox_list_index_namespaces_added,