From: Josef 'Jeff' Sipek Date: Mon, 29 Jan 2018 14:55:51 +0000 (-0500) Subject: imap: Iterate over ns settings when deciding to add SPECIAL-USE capability X-Git-Tag: 2.2.35~103 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f3136858d146f552f6ba8551f9670e944359cf85;p=thirdparty%2Fdovecot%2Fcore.git imap: Iterate over ns settings when deciding to add SPECIAL-USE capability To determine whether we should add the SPECIAL-USE capability to the OK response to LOGIN, we have to iterate over namespace and mailbox *settings* since the namespaces haven't been set up yet. --- diff --git a/src/imap/imap-client.c b/src/imap/imap-client.c index ae4c616142..82f01e1aad 100644 --- a/src/imap/imap-client.c +++ b/src/imap/imap-client.c @@ -73,12 +73,32 @@ static void client_init_urlauth(struct client *client) static bool user_has_special_use_mailboxes(struct mail_user *user) { - struct mail_namespace *ns; + struct mail_namespace_settings *const *ns_set; - for (ns = user->namespaces; ns != NULL; ns = ns->next) { - if (ns->special_use_mailboxes) - return TRUE; + /* + * We have to iterate over namespace and mailbox *settings* since + * the namespaces haven't been set up yet. The namespaces haven't + * been set up so that we don't hold up the OK response to LOGIN + * when using slow lib-storage backends. + */ + + /* no namespaces => no special use flags */ + if (!array_is_created(&user->set->namespaces)) + return FALSE; + + array_foreach(&user->set->namespaces, ns_set) { + struct mailbox_settings *const *box_set; + + /* no mailboxes => no special use flags */ + if (!array_is_created(&(*ns_set)->mailboxes)) + continue; + + array_foreach(&(*ns_set)->mailboxes, box_set) { + if ((*box_set)->special_use != NULL) + return TRUE; + } } + return FALSE; }