dovecot-2.2: imapc: If authentication fails, preserve the error ...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Mar 18 23:25:26 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/b28de884c470
changeset: 18370:b28de884c470
user: Timo Sirainen <tss at iki.fi>
date: Thu Mar 19 00:38:01 2015 +0200
description:
imapc: If authentication fails, preserve the error message as storage/list error.
This isn't very helpful yet, because the mailbox list creation itself fails.
diffstat:
src/lib-storage/index/imapc/imapc-list.c | 6 +++++
src/lib-storage/index/imapc/imapc-storage.c | 32 ++++++++++++++++++++++++++++-
src/lib-storage/index/imapc/imapc-storage.h | 2 +
3 files changed, 39 insertions(+), 1 deletions(-)
diffs (112 lines):
diff -r fca7232724dd -r b28de884c470 src/lib-storage/index/imapc/imapc-list.c
--- a/src/lib-storage/index/imapc/imapc-list.c Thu Mar 19 00:32:44 2015 +0200
+++ b/src/lib-storage/index/imapc/imapc-list.c Thu Mar 19 00:38:01 2015 +0200
@@ -140,6 +140,8 @@
imapc_list_copy_error_from_reply(ctx->client->_list,
MAIL_ERROR_PARAMS, reply);
ctx->ret = -1;
+ } else if (ctx->client->auth_failed) {
+ ctx->ret = -1;
} else {
mailbox_list_set_critical(&ctx->client->_list->list,
"imapc: Command failed: %s", reply->text_full);
@@ -270,6 +272,8 @@
imapc_list_sep_verify(list);
else if (reply->state == IMAPC_COMMAND_STATE_NO)
imapc_list_copy_error_from_reply(list, MAIL_ERROR_PARAMS, reply);
+ else if (list->client->auth_failed)
+ ;
else if (!list->list.ns->user->deinitializing) {
mailbox_list_set_critical(&list->list,
"imapc: Command failed: %s", reply->text_full);
@@ -293,6 +297,8 @@
int imapc_list_try_get_root_sep(struct imapc_mailbox_list *list, char *sep_r)
{
if (list->root_sep == '\0') {
+ if (list->client->auth_failed)
+ return -1;
imapc_list_send_hierarcy_sep_lookup(list);
while (list->root_sep_pending)
imapc_client_run(list->client->client);
diff -r fca7232724dd -r b28de884c470 src/lib-storage/index/imapc/imapc-storage.c
--- a/src/lib-storage/index/imapc/imapc-storage.c Thu Mar 19 00:32:44 2015 +0200
+++ b/src/lib-storage/index/imapc/imapc-storage.c Thu Mar 19 00:38:01 2015 +0200
@@ -110,6 +110,10 @@
void imapc_simple_run(struct imapc_simple_context *sctx)
{
+ if (sctx->client->auth_failed) {
+ imapc_client_disconnect(sctx->client->client);
+ sctx->ret = -1;
+ }
while (sctx->ret == -2)
imapc_client_run(sctx->client->client);
}
@@ -138,6 +142,8 @@
imapc_copy_error_from_reply(ctx->client->_storage,
MAIL_ERROR_PARAMS, reply);
ctx->ret = -1;
+ } else if (ctx->client->auth_failed) {
+ ctx->ret = -1;
} else {
mail_storage_set_critical(&ctx->client->_storage->storage,
"imapc: Command failed: %s", reply->text_full);
@@ -193,6 +199,28 @@
}
}
+static void
+imapc_storage_client_login(const struct imapc_command_reply *reply,
+ void *context)
+{
+ struct imapc_storage_client *client = context;
+
+ if (reply->state == IMAPC_COMMAND_STATE_OK)
+ return;
+
+ i_error("imapc: Authentication failed: %s", reply->text_full);
+ client->auth_failed = TRUE;
+
+ if (client->_storage != NULL) {
+ mail_storage_set_error(&client->_storage->storage,
+ MAIL_ERROR_PERM, reply->text_full);
+ }
+ if (client->_list != NULL) {
+ mailbox_list_set_error(&client->_list->list,
+ MAIL_ERROR_PERM, reply->text_full);
+ }
+}
+
int imapc_storage_client_create(struct mail_namespace *ns,
const struct imapc_settings *imapc_set,
const struct mail_storage_settings *mail_set,
@@ -257,7 +285,7 @@
imapc_client_register_untagged(client->client,
imapc_storage_client_untagged_cb, client);
/* start logging in immediately */
- imapc_client_login(client->client, NULL, NULL);
+ imapc_client_login(client->client, imapc_storage_client_login, client);
*client_r = client;
return 0;
@@ -449,6 +477,8 @@
imapc_copy_error_from_reply(ctx->mbox->storage,
MAIL_ERROR_NOTFOUND, reply);
ctx->ret = -1;
+ } else if (ctx->mbox->storage->client->auth_failed) {
+ ctx->ret = -1;
} else {
mail_storage_set_critical(ctx->mbox->box.storage,
"imapc: Opening mailbox '%s' failed: %s",
diff -r fca7232724dd -r b28de884c470 src/lib-storage/index/imapc/imapc-storage.h
--- a/src/lib-storage/index/imapc/imapc-storage.h Thu Mar 19 00:32:44 2015 +0200
+++ b/src/lib-storage/index/imapc/imapc-storage.h Thu Mar 19 00:38:01 2015 +0200
@@ -50,6 +50,8 @@
struct imapc_client *client;
ARRAY(struct imapc_storage_event_callback) untagged_callbacks;
+
+ unsigned int auth_failed:1;
};
struct imapc_storage {
More information about the dovecot-cvs
mailing list