dovecot-2.2: login: If session timeouts after authentication, lo...

dovecot at dovecot.org dovecot at dovecot.org
Sun May 20 03:26:23 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/855856a9f139
changeset: 14247:855856a9f139
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Mar 02 12:23:00 2012 +0200
description:
login: If session timeouts after authentication, log a better error about it.

diffstat:

 src/login-common/client-common.c |  33 ++++++++++++++++++++++++++++++---
 src/login-common/client-common.h |   2 +-
 src/login-common/sasl-server.c   |   1 +
 3 files changed, 32 insertions(+), 4 deletions(-)

diffs (66 lines):

diff -r 99cde8ce9991 -r 855856a9f139 src/login-common/client-common.c
--- 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)
diff -r 99cde8ce9991 -r 855856a9f139 src/login-common/client-common.h
--- 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;
diff -r 99cde8ce9991 -r 855856a9f139 src/login-common/sasl-server.c
--- 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);


More information about the dovecot-cvs mailing list