Mercurial > dovecot > core-2.2
changeset 14247:855856a9f139
login: If session timeouts after authentication, log a better error about it.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 02 Mar 2012 12:23:00 +0200 |
parents | 99cde8ce9991 |
children | 1a33e3651c6d |
files | src/login-common/client-common.c src/login-common/client-common.h src/login-common/sasl-server.c |
diffstat | 3 files changed, 32 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/login-common/client-common.c Wed Feb 29 13:04:24 2012 +0200 +++ b/src/login-common/client-common.c Fri Mar 02 12:23:00 2012 +0200 @@ -26,9 +26,36 @@ static void client_idle_disconnect_timeout(struct client *client) { - client_send_line(client, CLIENT_CMD_REPLY_BYE, - "Disconnected for inactivity."); - client_destroy(client, "Disconnected: Inactivity"); + const char *user_reason, *destroy_reason; + unsigned int secs; + + if (client->master_tag != 0) { + secs = ioloop_time - client->auth_finished; + user_reason = "Timeout while finishing login."; + destroy_reason = t_strdup_printf( + "Timeout while finishing login (waited %u secs)", secs); + client_log_err(client, destroy_reason); + } else if (client->auth_request != NULL) { + user_reason = + "Disconnected for inactivity during authentication."; + destroy_reason = + "Disconnected: Inactivity during authentication"; + } else if (client->login_proxy != NULL) { + secs = ioloop_time - client->created; + user_reason = "Timeout while finishing login."; + destroy_reason = t_strdup_printf( + "proxy: Logging in to %s:%u timed out " + "(state=%u, duration=%us)", + login_proxy_get_host(client->login_proxy), + login_proxy_get_port(client->login_proxy), + client->proxy_state, secs); + client_log_err(client, destroy_reason); + } else { + user_reason = "Disconnected for inactivity."; + destroy_reason = "Disconnected: Inactivity"; + } + client_send_line(client, CLIENT_CMD_REPLY_BYE, user_reason); + client_destroy(client, destroy_reason); } static void client_open_streams(struct client *client)
--- a/src/login-common/client-common.h Wed Feb 29 13:04:24 2012 +0200 +++ b/src/login-common/client-common.h Fri Mar 02 12:23:00 2012 +0200 @@ -107,7 +107,7 @@ char *auth_mech_name; struct auth_client_request *auth_request; string_t *auth_response; - time_t auth_first_started; + time_t auth_first_started, auth_finished; const char *sasl_final_resp; unsigned int master_auth_id;
--- a/src/login-common/sasl-server.c Wed Feb 29 13:04:24 2012 +0200 +++ b/src/login-common/sasl-server.c Fri Mar 02 12:23:00 2012 +0200 @@ -144,6 +144,7 @@ buffer_append(buf, data, size); req.data_size = buf->used; + client->auth_finished = ioloop_time; client->master_auth_id = req.auth_id; master_auth_request(master_auth, client->fd, &req, buf->data, master_auth_callback, client, &client->master_tag);