]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
*-login: Minor logging cleanup if client is disconnected before sending banner.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 5 Apr 2017 12:59:51 +0000 (15:59 +0300)
committerGitLab <gitlab@git.dovecot.net>
Thu, 6 Apr 2017 20:32:02 +0000 (23:32 +0300)
Avoid unnecessarily adding "(no auth attempts in 0 secs)" when the reason
string already makes it clear that the user didn't even have a chance to
authenticate.

This kind of disconnection currently happens only with some plugins.

src/imap-login/imap-login-client.c
src/login-common/client-common.c
src/login-common/client-common.h
src/pop3-login/client.c

index f1f09a7c106f037cea1e3313186b330d5809b0ef..224bf61c191fb0d9d4148cec5bfc76f0b7a2628a 100644 (file)
@@ -637,6 +637,8 @@ static void imap_client_notify_auth_ready(struct client *client)
        str_append(greet, "\r\n");
 
        client_send_raw(client, str_c(greet));
+
+       client->banner_sent = TRUE;
 }
 
 static void imap_client_starttls(struct client *client)
index 2b6fa76c60bf758238222a2768ddf2d2e40c4b5c..546d49ff4ef397dadef2525387568e922361cce9 100644 (file)
@@ -228,8 +228,10 @@ void client_destroy(struct client *client, const char *reason)
                pool_unref(&client->preproxy_pool);
 
        if (!client->login_success && reason != NULL) {
-               reason = t_strconcat(reason, " ",
-                       client_get_extra_disconnect_reason(client), NULL);
+               const char *extra_reason =
+                       client_get_extra_disconnect_reason(client);
+               if (extra_reason[0] != '\0')
+                       reason = t_strconcat(reason, " ", extra_reason, NULL);
        }
        if (reason != NULL)
                client_log(client, reason);
@@ -791,6 +793,10 @@ const char *client_get_extra_disconnect_reason(struct client *client)
                        (unsigned int)(ioloop_time - client->created));
 
        if (client->auth_attempts == 0) {
+               if (!client->banner_sent) {
+                       /* disconnected by a plugin */
+                       return "";
+               }
                return t_strdup_printf("(no auth attempts in %u secs)",
                        (unsigned int)(ioloop_time - client->created));
        }
index f3d188e7a40ae4b3d785a0a9873255c9df06a28c..f93b2e5f3efd0a96560957bdd3c00bb4c0a68184 100644 (file)
@@ -195,6 +195,7 @@ struct client {
        bool secured:1;
        bool trusted:1;
        bool ssl_servername_settings_read:1;
+       bool banner_sent:1;
        bool authenticating:1;
        bool auth_try_aborted:1;
        bool auth_initializing:1;
index 41efd2fe934b4f9a85934dbd6e763982eb22e29e..10a855d10123233ebdb9ed5dcbaaa41ca6bf4860 100644 (file)
@@ -222,6 +222,8 @@ static void pop3_client_notify_auth_ready(struct client *client)
        if (pop3_client->apop_challenge != NULL)
                str_printfa(str, " %s", pop3_client->apop_challenge);
        client_send_reply(client, POP3_CMD_REPLY_OK, str_c(str));
+
+       client->banner_sent = TRUE;
 }
 
 static void