dovecot-2.2: imap: If mailbox list is unusable at startup, retur...

dovecot at dovecot.org dovecot at dovecot.org
Wed Mar 18 23:25:27 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/cbdfca7d24a6
changeset: 18372:cbdfca7d24a6
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Mar 19 01:20:38 2015 +0200
description:
imap: If mailbox list is unusable at startup, return failure immediately.
This is currently used only by imapc when login fails.

diffstat:

 src/imap/main.c |  19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diffs (38 lines):

diff -r b900b50085fc -r cbdfca7d24a6 src/imap/main.c
--- a/src/imap/main.c	Thu Mar 19 00:41:19 2015 +0200
+++ b/src/imap/main.c	Thu Mar 19 01:20:38 2015 +0200
@@ -209,15 +209,34 @@
 {
 	struct mail_storage_service_user *user;
 	struct mail_user *mail_user;
+	struct mail_namespace *ns;
 	struct client *client;
 	struct imap_settings *set;
 	enum mail_auth_request_flags flags;
+	const char *errstr;
+	enum mail_error mail_error;
 
 	if (mail_storage_service_lookup_next(storage_service, input,
 					     &user, &mail_user, error_r) <= 0)
 		return -1;
 	restrict_access_allow_coredumps(TRUE);
 
+	/* this is mainly for imapc: make sure we can do at least minimal
+	   access to the mailbox list or fail immediately. otherwise the IMAP
+	   client could be trying a lot of commands and we'd return failures
+	   for all of them. FIXME: There should be a bit less kludgy way to
+	   check this, but I'm not sure if it's worth the trouble just for
+	   imapc. */
+	ns = mail_namespace_find_inbox(mail_user->namespaces);
+	(void)mailbox_list_get_hierarchy_sep(ns->list);
+	errstr = mailbox_list_get_last_error(ns->list, &mail_error);
+	if (mail_error != MAIL_ERROR_NONE) {
+		*error_r = t_strdup(errstr);
+		mail_user_unref(&mail_user);
+		mail_storage_service_user_free(&user);
+		return -1;
+	}
+
 	set = mail_storage_service_user_get_set(user)[1];
 	if (set->verbose_proctitle)
 		verbose_proctitle = TRUE;


More information about the dovecot-cvs mailing list