]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap-login: proxy - Some code paths were missing client_proxy_failed() calls
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 29 Apr 2020 10:51:03 +0000 (13:51 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 25 May 2020 08:38:55 +0000 (08:38 +0000)
Move client_proxy_failed() calls right next to the error logging so it's
clearer where they are needed.

src/imap-login/imap-proxy.c

index fc9e3062c580e1730247e5001200e22e284384ec..18f7b95cd5aa7e6b90a2c880ea0f4bea9b221982 100644 (file)
@@ -82,6 +82,7 @@ static int proxy_write_starttls(struct imap_client *client, string_t *str)
                    !str_array_icase_find(t_strsplit(client->proxy_backend_capability, " "), "STARTTLS")) {
                        e_error(login_proxy_get_event(client->common.login_proxy),
                                "Remote doesn't support STARTTLS");
+                       client_proxy_failed(&client->common, TRUE);
                        return -1;
                }
                str_append(str, "S STARTTLS\r\n");
@@ -122,6 +123,7 @@ static int proxy_write_login(struct imap_client *client, string_t *str)
                    login_proxy_get_ssl_flags(client->common.login_proxy) == 0) {
                        e_error(login_proxy_get_event(client->common.login_proxy),
                                "Remote advertised LOGINDISABLED and SSL/TLS not enabled");
+                       client_proxy_failed(&client->common, TRUE);
                        return -1;
                }
                str_append(str, "L LOGIN ");
@@ -153,6 +155,7 @@ static int proxy_write_login(struct imap_client *client, string_t *str)
                        e_error(login_proxy_get_event(client->common.login_proxy),
                                "SASL mechanism %s init failed: %s",
                                mech_name, error);
+                       client_proxy_failed(&client->common, TRUE);
                        return -1;
                }
                str_append_c(str, ' ');
@@ -178,6 +181,7 @@ static int proxy_input_banner(struct imap_client *client,
                e_error(login_proxy_get_event(client->common.login_proxy),
                        "Remote returned invalid banner: %s",
                        str_sanitize(line, 160));
+               client_proxy_failed(&client->common, TRUE);
                return -1;
        }
 
@@ -266,10 +270,8 @@ int imap_proxy_parse_line(struct client *client, const char *line)
                /* this is a banner */
                imap_client->proxy_rcvd_state = IMAP_PROXY_RCVD_STATE_BANNER;
                imap_client->proxy_seen_banner = TRUE;
-               if (proxy_input_banner(imap_client, output, line) < 0) {
-                       client_proxy_failed(client, TRUE);
+               if (proxy_input_banner(imap_client, output, line) < 0)
                        return -1;
-               }
                return 0;
        } else if (*line == '+') {
                /* AUTHENTICATE started. finish it. */
@@ -330,10 +332,8 @@ int imap_proxy_parse_line(struct client *client, const char *line)
                /* i/ostreams changed. */
                output = login_proxy_get_ostream(client->login_proxy);
                str = t_str_new(128);
-               if (proxy_write_login(imap_client, str) < 0) {
-                       client_proxy_failed(client, TRUE);
+               if (proxy_write_login(imap_client, str) < 0)
                        return -1;
-               }
                o_stream_nsend(output, str_data(str), str_len(str));
                return 1;
        } else if (str_begins(line, "L OK ")) {