]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fail if no namespaces have list=yes
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 24 Nov 2016 17:53:17 +0000 (19:53 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 25 Nov 2016 13:29:44 +0000 (15:29 +0200)
The previous check allowed all namespaces to have list=children. This
crashed later on in mail_namespaces_get_root_sep(), because it couldn't
find any list=yes namespaces.

src/lib-storage/mail-namespace.c

index 0455ef6d7211bb4868233dbf7b6e8307a18fe2f4..612ef61d57c2c64f7e60e7616580e471721764e4 100644 (file)
@@ -263,7 +263,7 @@ namespaces_check(struct mail_namespace *namespaces, const char **error_r)
 {
        struct mail_namespace *ns, *inbox_ns = NULL;
        unsigned int subscriptions_count = 0;
-       bool visible_namespaces = FALSE;
+       bool visible_namespaces = FALSE, have_list_yes = FALSE;
        char ns_sep, list_sep = '\0';
 
        for (ns = namespaces; ns != NULL; ns = ns->next) {
@@ -308,6 +308,8 @@ namespaces_check(struct mail_namespace *namespaces, const char **error_r)
                }
                if ((ns->flags & (NAMESPACE_FLAG_LIST_PREFIX |
                                  NAMESPACE_FLAG_LIST_CHILDREN)) != 0) {
+                       if ((ns->flags & NAMESPACE_FLAG_LIST_PREFIX) != 0)
+                               have_list_yes = TRUE;
                        if (list_sep == '\0')
                                list_sep = ns_sep;
                        else if (list_sep != ns_sep) {
@@ -324,7 +326,7 @@ namespaces_check(struct mail_namespace *namespaces, const char **error_r)
                *error_r = "inbox=yes namespace missing";
                return FALSE;
        }
-       if (list_sep == '\0') {
+       if (!have_list_yes) {
                *error_r = "list=yes namespace missing";
                return FALSE;
        }