Mercurial > dovecot > core-2.2
changeset 2089:d8cd285b148b HEAD
PLAIN auth fallbacking works now with initial responses
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 30 May 2004 07:50:06 +0300 |
parents | 4d0834aaa365 |
children | 0a4b2c006096 |
files | src/lib-auth/auth-server-request.c |
diffstat | 1 files changed, 41 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-auth/auth-server-request.c Sun May 30 07:41:27 2004 +0300 +++ b/src/lib-auth/auth-server-request.c Sun May 30 07:50:06 2004 +0300 @@ -31,6 +31,44 @@ }; static int auth_server_send_new_request(struct auth_server_connection *conn, + struct auth_request *request); + +static struct auth_server_connection * +get_next_plain_server(struct auth_server_connection *conn) +{ + conn = conn->next; + while (conn != NULL) { + if (conn->has_plain_mech) + return conn; + conn = conn->next; + } + return NULL; +} + +static void +auth_server_request_check_retry(struct auth_request *request, + const unsigned char *data, size_t data_size) +{ + if (strcmp(request->mech, "PLAIN") == 0 && + request->plaintext_data == NULL && request->conn != NULL) { + request->next_conn = get_next_plain_server(request->conn); + if (request->next_conn != NULL) { + /* plaintext authentication - save the data so we can + try it for the next */ + request->plaintext_data = i_malloc(data_size); + memcpy(request->plaintext_data, data, data_size); + request->plaintext_data_size = data_size; + + hash_insert(request->next_conn->requests, + POINTER_CAST(request->id), request); + auth_server_send_new_request(request->next_conn, + request); + request->retrying = TRUE; + } + } +} + +static int auth_server_send_new_request(struct auth_server_connection *conn, struct auth_request *request) { struct auth_client_request_new auth_request; @@ -76,6 +114,8 @@ return FALSE; } + auth_server_request_check_retry(request, request->initial_resp_data, + request->initial_resp_size); return TRUE; } @@ -99,18 +139,6 @@ } } -static struct auth_server_connection * -get_next_plain_server(struct auth_server_connection *conn) -{ - conn = conn->next; - while (conn != NULL) { - if (conn->has_plain_mech) - return conn; - conn = conn->next; - } - return NULL; -} - void auth_server_request_handle_reply(struct auth_server_connection *conn, struct auth_client_request_reply *reply, const unsigned char *data) @@ -255,23 +283,7 @@ { auth_server_send_continue(request->conn, request, data, data_size); - if (strcmp(request->mech, "PLAIN") == 0 && - request->plaintext_data == NULL && request->conn != NULL) { - request->next_conn = get_next_plain_server(request->conn); - if (request->next_conn != NULL) { - /* plaintext authentication - save the data so we can - try it for the next */ - request->plaintext_data = i_malloc(data_size); - memcpy(request->plaintext_data, data, data_size); - request->plaintext_data_size = data_size; - - hash_insert(request->next_conn->requests, - POINTER_CAST(request->id), request); - auth_server_send_new_request(request->next_conn, - request); - request->retrying = TRUE; - } - } + auth_server_request_check_retry(request, data, data_size); } void auth_client_request_abort(struct auth_request *request)