dovecot-2.1: virtual: "*" wildcard matches now also autocreated ...

dovecot at dovecot.org dovecot at dovecot.org
Tue Feb 21 02:44:12 EET 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/10994a5b64e1
changeset: 14174:10994a5b64e1
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Feb 21 02:43:52 2012 +0200
description:
virtual: "*" wildcard matches now also autocreated shared namespaces.
Basically this makes "shared/*" work as intended for shared namespaces.

diffstat:

 src/plugins/virtual/virtual-config.c |  17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diffs (34 lines):

diff -r c854f19f10e3 -r 10994a5b64e1 src/plugins/virtual/virtual-config.c
--- a/src/plugins/virtual/virtual-config.c	Tue Feb 21 00:13:36 2012 +0000
+++ b/src/plugins/virtual/virtual-config.c	Tue Feb 21 02:43:52 2012 +0200
@@ -245,6 +245,20 @@
 	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 @@
 	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;


More information about the dovecot-cvs mailing list