]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
virtual: "*" wildcard matches now also autocreated shared namespaces.
authorTimo Sirainen <tss@iki.fi>
Tue, 21 Feb 2012 00:43:52 +0000 (02:43 +0200)
committerTimo Sirainen <tss@iki.fi>
Tue, 21 Feb 2012 00:43:52 +0000 (02:43 +0200)
Basically this makes "shared/*" work as intended for shared namespaces.

src/plugins/virtual/virtual-config.c

index 6f345683359dd1db2fe01a7ff6b3af8fe0763a48..cceccc895117e11e1f429526a82d9b926b964ea7 100644 (file)
@@ -245,6 +245,20 @@ static void virtual_config_copy_expanded(struct virtual_parse_context *ctx,
        array_append(&ctx->mbox->backend_boxes, &bbox, 1);
 }
 
+static bool virtual_ns_match(struct mail_namespace *config_ns,
+                            struct mail_namespace *iter_ns)
+{
+       /* we match only one namespace for each pattern, except with shared
+          namespaces match also autocreated children */
+       if (config_ns == iter_ns)
+               return TRUE;
+       if (config_ns->type == iter_ns->type &&
+           (config_ns->flags & NAMESPACE_FLAG_AUTOCREATED) == 0 &&
+           (iter_ns->flags & NAMESPACE_FLAG_AUTOCREATED) != 0)
+               return TRUE;
+       return FALSE;
+}
+
 static bool virtual_config_match(const struct mailbox_info *info,
                                 ARRAY_TYPE(virtual_backend_box) *boxes_arr,
                                 unsigned int *idx_r)
@@ -255,8 +269,7 @@ static bool virtual_config_match(const struct mailbox_info *info,
        boxes = array_get_modifiable(boxes_arr, &count);
        for (i = 0; i < count; i++) {
                if (boxes[i]->glob != NULL) {
-                       /* we match only one namespace for each pattern. */
-                       if (boxes[i]->ns == info->ns &&
+                       if (virtual_ns_match(boxes[i]->ns, info->ns) &&
                            imap_match(boxes[i]->glob,
                                       info->name) == IMAP_MATCH_YES) {
                                *idx_r = i;