Mercurial > dovecot > core-2.2
changeset 22801:2fdbdfee4d71
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.
author | Josef 'Jeff' Sipek <jeff.sipek@dovecot.fi> |
---|---|
date | Mon, 29 Jan 2018 09:55:51 -0500 |
parents | 58f41eb48676 |
children | b034cb09fbb6 |
files | src/imap/imap-client.c |
diffstat | 1 files changed, 24 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/imap-client.c Tue Dec 05 17:05:27 2017 +0200 +++ b/src/imap/imap-client.c Mon Jan 29 09:55:51 2018 -0500 @@ -73,12 +73,32 @@ static bool user_has_special_use_mailboxes(struct mail_user *user) { - struct mail_namespace *ns; + struct mail_namespace_settings *const *ns_set; + + /* + * 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; - for (ns = user->namespaces; ns != NULL; ns = ns->next) { - if (ns->special_use_mailboxes) - return TRUE; + 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; }