Mercurial > dovecot > core-2.2
changeset 21909:57ce096eab4b
*-login: Minor logging cleanup if client is disconnected before sending banner.
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.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Wed, 05 Apr 2017 15:59:51 +0300 |
parents | 750319f27ef2 |
children | 0bcfd58922bd |
files | src/imap-login/imap-login-client.c src/login-common/client-common.c src/login-common/client-common.h src/pop3-login/client.c |
diffstat | 4 files changed, 13 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap-login/imap-login-client.c Thu Apr 06 20:43:20 2017 +0300 +++ b/src/imap-login/imap-login-client.c Wed Apr 05 15:59:51 2017 +0300 @@ -619,6 +619,8 @@ str_append(greet, "\r\n"); client_send_raw(client, str_c(greet)); + + client->banner_sent = TRUE; } static void imap_client_starttls(struct client *client)
--- a/src/login-common/client-common.c Thu Apr 06 20:43:20 2017 +0300 +++ b/src/login-common/client-common.c Wed Apr 05 15:59:51 2017 +0300 @@ -230,8 +230,10 @@ 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); @@ -781,6 +783,10 @@ (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)); }
--- a/src/login-common/client-common.h Thu Apr 06 20:43:20 2017 +0300 +++ b/src/login-common/client-common.h Wed Apr 05 15:59:51 2017 +0300 @@ -177,6 +177,7 @@ unsigned int secured:1; unsigned int trusted:1; unsigned int ssl_servername_settings_read:1; + unsigned int banner_sent:1; unsigned int authenticating:1; unsigned int auth_tried_disabled_plaintext:1; unsigned int auth_tried_unsupported_mech:1;
--- a/src/pop3-login/client.c Thu Apr 06 20:43:20 2017 +0300 +++ b/src/pop3-login/client.c Wed Apr 05 15:59:51 2017 +0300 @@ -222,6 +222,8 @@ 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