dovecot-2.0: login: Tell auth process to free aborted auth reque...
dovecot at dovecot.org
dovecot at dovecot.org
Thu May 20 14:17:33 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/f70433791464
changeset: 11354:f70433791464
user: Timo Sirainen <tss at iki.fi>
date: Thu May 20 13:17:30 2010 +0200
description:
login: Tell auth process to free aborted auth requests.
diffstat:
src/auth/auth-client-connection.c | 19 +++++++++++++++++++
src/auth/auth-request-handler.c | 10 ++++++++++
src/auth/auth-request-handler.h | 2 ++
src/lib-auth/auth-client-request.c | 12 ++++++++++++
src/lib-auth/auth-client.h | 3 +++
src/login-common/sasl-server.c | 10 ++++++++++
6 files changed, 56 insertions(+), 0 deletions(-)
diffs (135 lines):
diff -r 1bc3d5589c5a -r f70433791464 src/auth/auth-client-connection.c
--- a/src/auth/auth-client-connection.c Thu May 20 12:37:15 2010 +0200
+++ b/src/auth/auth-client-connection.c Thu May 20 13:17:30 2010 +0200
@@ -166,6 +166,20 @@
}
static bool
+auth_client_cancel(struct auth_client_connection *conn, const char *line)
+{
+ unsigned int client_id;
+
+ if (str_to_uint(line, &client_id) < 0) {
+ i_error("BUG: Authentication client sent broken CANCEL");
+ return FALSE;
+ }
+
+ auth_request_handler_cancel_request(conn->request_handler, client_id);
+ return TRUE;
+}
+
+static bool
auth_client_handle_line(struct auth_client_connection *conn, const char *line)
{
if (strncmp(line, "AUTH\t", 5) == 0) {
@@ -186,6 +200,11 @@
return auth_request_handler_auth_continue(conn->request_handler,
line + 5);
}
+ if (strncmp(line, "CANCEL\t", 7) == 0) {
+ if (conn->auth->set->debug)
+ i_debug("client in: %s", line);
+ return auth_client_cancel(conn, line + 7);
+ }
i_error("BUG: Authentication client sent unknown command: %s",
str_sanitize(line, 80));
diff -r 1bc3d5589c5a -r f70433791464 src/auth/auth-request-handler.c
--- a/src/auth/auth-request-handler.c Thu May 20 12:37:15 2010 +0200
+++ b/src/auth/auth-request-handler.c Thu May 20 13:17:30 2010 +0200
@@ -587,6 +587,16 @@
return TRUE;
}
+void auth_request_handler_cancel_request(struct auth_request_handler *handler,
+ unsigned int client_id)
+{
+ struct auth_request *request;
+
+ request = hash_table_lookup(handler->requests, POINTER_CAST(client_id));
+ if (request != NULL)
+ auth_request_handler_remove(handler, request);
+}
+
void auth_request_handler_flush_failures(bool flush_all)
{
struct auth_request **auth_requests, *auth_request;
diff -r 1bc3d5589c5a -r f70433791464 src/auth/auth-request-handler.h
--- a/src/auth/auth-request-handler.h Thu May 20 12:37:15 2010 +0200
+++ b/src/auth/auth-request-handler.h Thu May 20 13:17:30 2010 +0200
@@ -37,6 +37,8 @@
struct auth_master_connection *master,
unsigned int id,
unsigned int client_id);
+void auth_request_handler_cancel_request(struct auth_request_handler *handler,
+ unsigned int client_id);
void auth_request_handler_flush_failures(bool flush_all);
diff -r 1bc3d5589c5a -r f70433791464 src/lib-auth/auth-client-request.c
--- a/src/lib-auth/auth-client-request.c Thu May 20 12:37:15 2010 +0200
+++ b/src/lib-auth/auth-client-request.c Thu May 20 13:17:30 2010 +0200
@@ -115,9 +115,13 @@
void auth_client_request_abort(struct auth_client_request **_request)
{
struct auth_client_request *request = *_request;
+ const char *str = t_strdup_printf("CANCEL\t%u\n", request->id);
*_request = NULL;
+ if (o_stream_send_str(request->conn->output, str) < 0)
+ i_error("Error sending request to auth server: %m");
+
request->callback(request, AUTH_REQUEST_STATUS_FAIL, NULL, NULL,
request->context);
request->callback = NULL;
@@ -176,3 +180,11 @@
if (status != AUTH_REQUEST_STATUS_CONTINUE)
pool_unref(&request->pool);
}
+
+void auth_client_send_cancel(struct auth_client *client, unsigned int id)
+{
+ const char *str = t_strdup_printf("CANCEL\t%u\n", id);
+
+ if (o_stream_send_str(client->conn->output, str) < 0)
+ i_error("Error sending request to auth server: %m");
+}
diff -r 1bc3d5589c5a -r f70433791464 src/lib-auth/auth-client.h
--- a/src/lib-auth/auth-client.h Thu May 20 12:37:15 2010 +0200
+++ b/src/lib-auth/auth-client.h Thu May 20 13:17:30 2010 +0200
@@ -91,4 +91,7 @@
/* Return cookie of the server that handled this request. */
const char *auth_client_request_get_cookie(struct auth_client_request *request);
+/* Tell auth process to drop specified request from memory */
+void auth_client_send_cancel(struct auth_client *client, unsigned int id);
+
#endif
diff -r 1bc3d5589c5a -r f70433791464 src/login-common/sasl-server.c
--- a/src/login-common/sasl-server.c Thu May 20 12:37:15 2010 +0200
+++ b/src/login-common/sasl-server.c Thu May 20 13:17:30 2010 +0200
@@ -139,6 +139,15 @@
master_auth_callback, client, &client->master_tag);
}
+static void master_abort_request(struct anvil_request *anvil_request)
+{
+ const char *cookie;
+
+ cookie = binary_to_hex(anvil_request->cookie,
+ sizeof(anvil_request->cookie));
+ auth_client_send_cancel(auth_client, anvil_request->auth_id);
+}
+
static void anvil_lookup_callback(const char *reply, void *context)
{
struct anvil_request *req = context;
@@ -155,6 +164,7 @@
set->mail_max_userip_connections);
call_client_callback(client, SASL_SERVER_REPLY_MASTER_FAILED,
errmsg, NULL);
+ master_abort_request(req);
}
i_free(req);
}
More information about the dovecot-cvs
mailing list