]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap-login: imap-proxy - Handle ID command failures
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sat, 31 Jan 2026 15:55:30 +0000 (17:55 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 6 Feb 2026 07:58:43 +0000 (07:58 +0000)
If it fails with SERVERBUG, abort the login. This is used now by Dovecot
to indicate that the settings reload failed, and the client will be
disconnected next anyway. By aborting earlier, we can log the failure
better.

If the ID command fails in other ways, log it as a debug message.

src/imap-login/imap-proxy.c

index 677d7b5845a58d13f7b8aad8d238344c5b441f2e..34ed1b24e8313701bbff13c2389636a41986f0ed 100644 (file)
@@ -483,13 +483,25 @@ int imap_proxy_parse_line(struct client *client, const char *line)
                        return 1;
                }
                return 0;
-       } else if (str_begins_icase_with(line, "I ")) {
+       } else if (str_begins_icase(line, "I ", &line)) {
                /* Reply to ID command we sent, ignore it unless
                   pipelining is disabled, in which case send
                   either STARTTLS or login */
                imap_client->proxy_sent_state &= ENUM_NEGATE(IMAP_PROXY_SENT_STATE_ID);
                imap_client->proxy_rcvd_state = IMAP_PROXY_RCVD_STATE_ID;
 
+               if (str_begins_icase(line, "NO ["IMAP_RESP_CODE_SERVERBUG"] ", &line)) {
+                       login_proxy_failed(client->login_proxy,
+                               login_proxy_get_event(client->login_proxy),
+                               LOGIN_PROXY_FAILURE_TYPE_REMOTE_CONFIG,
+                               t_strdup_printf("ID command failed: %s", line));
+                       return -1;
+               } else if (!str_begins_icase(line, "OK", &line)) {
+                       e_debug(login_proxy_get_event(client->login_proxy),
+                               "ID command failed, ignoring: %s",
+                               str_sanitize(line, 160));
+               }
+
                if (client->proxy_nopipelining) {
                        str = t_str_new(128);
                        if ((ret = proxy_write_starttls(imap_client, str)) < 0) {