]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
acl: If a user's namespace has no mailboxes visible to us, remove the namespace immed...
authorTimo Sirainen <tss@iki.fi>
Wed, 19 Nov 2008 16:46:25 +0000 (18:46 +0200)
committerTimo Sirainen <tss@iki.fi>
Wed, 19 Nov 2008 16:46:25 +0000 (18:46 +0200)
--HG--
branch : HEAD

src/plugins/acl/acl-shared-storage.c

index 27e2321cbb3229adfa94bd6f5ca795eb6eafd632..c5b6081a5c7ee847070f01ece34d9aa6879cb76f 100644 (file)
@@ -25,6 +25,8 @@ acl_shared_namespace_add(struct mail_user *user,
        };
        struct var_expand_table *tab;
        struct mail_namespace *ns;
+       struct mailbox_list_iterate_context *iter;
+       const struct mailbox_info *info;
        const char *p, *mailbox;
        string_t *str;
 
@@ -45,6 +47,18 @@ acl_shared_namespace_add(struct mail_user *user,
        var_expand(str, sstorage->ns_prefix_pattern, tab);
        mailbox = str_c(str);
        shared_storage_get_namespace(&sstorage->storage, &mailbox, &ns);
+
+       /* check if there are any mailboxes really visible to us */
+       iter = mailbox_list_iter_init(ns->list, "*",
+                                     MAILBOX_LIST_ITER_RETURN_NO_FLAGS);
+       while ((info = mailbox_list_iter_next(iter)) != NULL)
+               break;
+       (void)mailbox_list_iter_deinit(&iter);
+
+       if (info == NULL) {
+               /* no visible mailboxes, remove the namespace */
+               mail_namespace_destroy(ns);
+       }
 }
 
 int acl_shared_namespaces_add(struct mail_namespace *ns)