From 3bc9d91f987261e989aa653fd412b0e8095e4810 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Fri, 10 Jan 2014 13:00:39 -0500 Subject: [PATCH] imap proxy: Avoid duplicate CAPABILITY reply when backend is Dovecot. This happened if the client sent a CAPABILITY command to the proxy. --- src/imap-login/imap-proxy.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/imap-login/imap-proxy.c b/src/imap-login/imap-proxy.c index 741615ff69..db299c485f 100644 --- a/src/imap-login/imap-proxy.c +++ b/src/imap-login/imap-proxy.c @@ -63,7 +63,14 @@ static int proxy_write_login(struct imap_client *client, string_t *str) unsigned int len; const char *mech_name, *error; - if (client->proxy_backend_capability == NULL) { + /* Send CAPABILITY command if we don't know the capabilities yet. + Also as kind of a Dovecot-backend workaround if the client insisted + on sending CAPABILITY command (even though our banner already sent + it), send the (unnecessary) CAPABILITY command to backend as well + to avoid sending the CAPABILITY reply twice (untagged and OK resp + code). */ + if (client->proxy_backend_capability == NULL || + client->client_ignores_capability_resp_code) { str_append(str, "C CAPABILITY\r\n"); if (client->common.proxy_nopipelining) { /* authenticate only after receiving C OK reply. */ -- 2.47.3