# HG changeset patch # User Timo Sirainen # Date 1523445546 -10800 # Node ID 8b32d37472a0ff45fe2b556b064719cdf9cb1eff # Parent 8fc3c7215f294545c9c1cb0591fd2b9acc8788b2 imapc: If SELECT INBOX fails with NO, treat it as temporary failure If it's treated as "mailbox doesn't exist", the INBOX autocreation code will attempt to CREATE INBOX. This is very unlikely to work. diff -r 8fc3c7215f29 -r 8b32d37472a0 src/lib-storage/index/imapc/imapc-storage.c --- a/src/lib-storage/index/imapc/imapc-storage.c Tue Feb 27 12:26:09 2018 +0200 +++ b/src/lib-storage/index/imapc/imapc-storage.c Wed Apr 11 14:19:06 2018 +0300 @@ -647,8 +647,22 @@ ctx->ret = 0; } } else if (reply->state == IMAPC_COMMAND_STATE_NO) { + /* Unless the remote IMAP server supports sending + resp-text-code, we don't know if the NO reply is because + the mailbox doesn't exist or because of some internal error. + We'll default to assuming it doesn't exist, so e.g. + mailbox { auto=create } will auto-create missing mailboxes. + However, INBOX is a special mailbox, which is always + autocreated if it doesn't exist. This is true in both the + local Dovecot and the remote IMAP server. This means that + there's no point in trying to send CREATE INBOX to the + remote server. We'll avoid that by defaulting to temporary + failure with INBOX. */ + enum mail_error default_error = + ctx->mbox->box.inbox_any ? + MAIL_ERROR_TEMP : MAIL_ERROR_NOTFOUND; imapc_copy_error_from_reply(ctx->mbox->storage, - MAIL_ERROR_NOTFOUND, reply); + default_error, reply); ctx->ret = -1; } else if (imapc_storage_client_handle_auth_failure(ctx->mbox->storage->client)) { ctx->ret = -1;