From 7fd51f7b0b4d990ec3cfef4e60ee685bf9fb32de Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 14 Aug 2012 03:01:07 +0300 Subject: [PATCH] lib-storage: If alias_for references inbox=yes namespace, copy the inbox=yes to the alias ns. 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 | 11 +++++++++-- src/lib-storage/mail-namespace.h | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/lib-storage/mail-namespace.c b/src/lib-storage/mail-namespace.c index f231988706..b15ff5b69c 100644 --- a/src/lib-storage/mail-namespace.c +++ b/src/lib-storage/mail-namespace.c @@ -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 && diff --git a/src/lib-storage/mail-namespace.h b/src/lib-storage/mail-namespace.h index 1184fe8338..4807cc5898 100644 --- a/src/lib-storage/mail-namespace.h +++ b/src/lib-storage/mail-namespace.h @@ -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. */ -- 2.47.3