]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Fix namespace deduplication when mailboxes don't have paths.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 24 Apr 2017 14:58:53 +0000 (17:58 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 25 Apr 2017 09:17:45 +0000 (12:17 +0300)
Nothing requires a mailbox path for quota backends, especially imapc.
Still do namespace deduplication based on alias_for settings.

src/plugins/quota/quota.c

index 3810c132f981a209133c7928492ecc9a7ceb8c06..b8b7b71e56eb33db37536fd10e152ee6547368e0 100644 (file)
@@ -531,11 +531,19 @@ quota_is_duplicate_namespace(struct quota *quota, struct mail_namespace *ns)
 
        if (!mailbox_list_get_root_path(ns->list,
                                        MAILBOX_LIST_PATH_TYPE_MAILBOX, &path))
-               return TRUE;
+               path = NULL;
 
        namespaces = array_get(&quota->namespaces, &count);
        for (i = 0; i < count; i++) {
-               if (mailbox_list_get_root_path(namespaces[i]->list,
+               /* count namespace aliases only once. don't rely only on
+                  alias_for != NULL, because the alias might have been
+                  explicitly added as the wanted quota namespace. */
+               if (ns->alias_for == namespaces[i] ||
+                   namespaces[i]->alias_for == ns)
+                       continue;
+
+               if (path != NULL &&
+                   mailbox_list_get_root_path(namespaces[i]->list,
                                MAILBOX_LIST_PATH_TYPE_MAILBOX, &path2) &&
                    strcmp(path, path2) == 0) {
                        /* duplicate path */