]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: If alias_for references inbox=yes namespace, copy the inbox=yes to the...
authorTimo Sirainen <tss@iki.fi>
Tue, 14 Aug 2012 00:01:07 +0000 (03:01 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 14 Aug 2012 00:01:07 +0000 (03:01 +0300)
So even though this still doesn't allow giving multiple inbox=yes settings
in configuration file, it's now possible for multiple namespaces to have
them. They just need to point to the exact same INBOX.

src/lib-storage/mail-namespace.c
src/lib-storage/mail-namespace.h

index f2319887064b222d683bf0d971052aef7cbb68f7..b15ff5b69c624b85a1c4d65a89cba8e24c0d1d41 100644 (file)
@@ -178,6 +178,11 @@ namespace_set_alias_for(struct mail_namespace *ns,
                if (!namespace_is_valid_alias_storage(ns, error_r))
                        return -1;
 
+               if ((ns->alias_for->flags & NAMESPACE_FLAG_INBOX_USER) != 0) {
+                       /* copy inbox=yes */
+                       ns->flags |= NAMESPACE_FLAG_INBOX_USER;
+               }
+
                ns->alias_chain_next = ns->alias_for->alias_chain_next;
                ns->alias_for->alias_chain_next = ns;
        }
@@ -200,10 +205,9 @@ namespaces_check(struct mail_namespace *namespaces, const char **error_r)
                                ns->prefix);
                        return FALSE;
                }
-               if (namespace_set_alias_for(ns, namespaces, error_r) < 0)
-                       return FALSE;
                if ((ns->flags & NAMESPACE_FLAG_HIDDEN) == 0)
                        visible_namespaces = TRUE;
+               /* check the inbox=yes status before alias_for changes it */
                if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) {
                        if (inbox_ns != NULL) {
                                *error_r = "There can be only one namespace with "
@@ -212,6 +216,9 @@ namespaces_check(struct mail_namespace *namespaces, const char **error_r)
                        }
                        inbox_ns = ns;
                }
+               if (namespace_set_alias_for(ns, namespaces, error_r) < 0)
+                       return FALSE;
+
                if (*ns->prefix != '\0' &&
                    (ns->flags & (NAMESPACE_FLAG_LIST_PREFIX |
                                  NAMESPACE_FLAG_LIST_CHILDREN)) != 0 &&
index 1184fe8338f48af3224b5c3b1af1320f4bb0c153..4807cc589880876e1bd13d0691a092946b2c4721 100644 (file)
@@ -12,8 +12,9 @@ enum namespace_type {
 };
 
 enum namespace_flags {
-       /* Namespace contains the user's INBOX mailbox (there can be only
-          one) */
+       /* Namespace contains the user's INBOX mailbox. Normally only a single
+          namespace has this flag set, but when using alias_for for the INBOX
+          namespace the flag gets copied to the alias namespace as well */
        NAMESPACE_FLAG_INBOX_USER       = 0x01,
        /* Namespace contains someone's INBOX. This is set for both user's
           INBOX namespace and also for any other users' shared namespaces. */