From: Timo Sirainen Date: Fri, 19 Dec 2008 07:46:46 +0000 (+0200) Subject: login: Reset idle timeout only when input is actually read from client. X-Git-Tag: 1.2.beta1~166 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3557b4f31edaa9f9ae87f89e34b286cbc5c6992f;p=thirdparty%2Fdovecot%2Fcore.git login: Reset idle timeout only when input is actually read from client. This prevents client from just sending lots of failed authentication attempts and then doing nothing for hours. --HG-- branch : HEAD --- diff --git a/src/imap-login/client-authenticate.c b/src/imap-login/client-authenticate.c index 11f95ebb86..dbbd40d83e 100644 --- a/src/imap-login/client-authenticate.c +++ b/src/imap-login/client-authenticate.c @@ -115,7 +115,6 @@ static void client_auth_failed(struct imap_client *client, bool nodelay) AUTH_FAILURE_DELAY_INCREASE_MSECS; if (delay_msecs > CLIENT_LOGIN_IDLE_TIMEOUT_MSECS) delay_msecs = CLIENT_LOGIN_IDLE_TIMEOUT_MSECS - 1000; - timeout_reset(client->to_idle_disconnect); i_assert(client->to_authfail_delay == NULL); client->to_authfail_delay = diff --git a/src/imap-login/client.c b/src/imap-login/client.c index d1e2ae7700..eb6950586f 100644 --- a/src/imap-login/client.c +++ b/src/imap-login/client.c @@ -387,16 +387,18 @@ bool client_read(struct imap_client *client) /* disconnected */ client_destroy(client, "Disconnected"); return FALSE; + case 0: + /* nothing new read */ + return TRUE; default: /* something was read */ + timeout_reset(client->to_idle_disconnect); return TRUE; } } void client_input(struct imap_client *client) { - timeout_reset(client->to_idle_disconnect); - if (!client_read(client)) return; diff --git a/src/pop3-login/client-authenticate.c b/src/pop3-login/client-authenticate.c index 4f2e10efde..019182e2c0 100644 --- a/src/pop3-login/client-authenticate.c +++ b/src/pop3-login/client-authenticate.c @@ -115,7 +115,6 @@ static void client_auth_failed(struct pop3_client *client, bool nodelay) AUTH_FAILURE_DELAY_INCREASE_MSECS; if (delay_msecs > CLIENT_LOGIN_IDLE_TIMEOUT_MSECS) delay_msecs = CLIENT_LOGIN_IDLE_TIMEOUT_MSECS - 1000; - timeout_reset(client->to_idle_disconnect); i_assert(client->to_authfail_delay == NULL); client->to_authfail_delay = diff --git a/src/pop3-login/client.c b/src/pop3-login/client.c index 594b645183..efe23ae3fb 100644 --- a/src/pop3-login/client.c +++ b/src/pop3-login/client.c @@ -179,8 +179,12 @@ bool client_read(struct pop3_client *client) /* disconnected */ client_destroy(client, "Disconnected"); return FALSE; + case 0: + /* nothing new read */ + return TRUE; default: /* something was read */ + timeout_reset(client->to_idle_disconnect); return TRUE; } } @@ -191,7 +195,6 @@ void client_input(struct pop3_client *client) i_assert(!client->common.authenticating); - timeout_reset(client->to_idle_disconnect); if (!client_read(client)) return;