Mercurial > dovecot > core-2.2
changeset 21562:4d4823518e9c
lib-imap-client: centralize authentication failed error logging
author | Josef 'Jeff' Sipek <jeff.sipek@dovecot.fi> |
---|---|
date | Tue, 14 Feb 2017 08:58:10 -0500 |
parents | f0fbdd5839c1 |
children | b1fd9a5366bf |
files | src/lib-imap-client/imapc-connection.c src/lib-storage/index/imapc/imapc-storage.c |
diffstat | 2 files changed, 14 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-imap-client/imapc-connection.c Sat Feb 04 15:40:41 2017 +0100 +++ b/src/lib-imap-client/imapc-connection.c Tue Feb 14 08:58:10 2017 -0500 @@ -141,6 +141,13 @@ static void imapc_command_free(struct imapc_command *cmd); static void imapc_command_send_more(struct imapc_connection *conn); +static void +imapc_auth_failed(struct imapc_connection *conn, + const char *error) +{ + i_error("imapc(%s): Authentication failed: %s", conn->name, error); +} + struct imapc_connection * imapc_connection_init(struct imapc_client *client) { @@ -764,12 +771,9 @@ const struct imapc_command_reply *reply) { if (reply->state != IMAPC_COMMAND_STATE_OK) { + imapc_auth_failed(conn, reply->text_full); if (conn->login_callback != NULL) imapc_login_callback(conn, reply); - else { - i_error("imapc(%s): Authentication failed: %s", - conn->name, reply->text_full); - } imapc_connection_disconnect(conn); return; } @@ -832,15 +836,14 @@ buf = buffer_create_dynamic(pool_datastack_create(), MAX_BASE64_DECODED_SIZE(input_len)); if (base64_decode(reply->text_full, input_len, NULL, buf) < 0) { - i_error("imapc(%s): Authentication failed: Server sent non-base64 input for AUTHENTICATE: %s", - conn->name, reply->text_full); + imapc_auth_failed(conn, + t_strdup_printf("Server sent non-base64 input for AUTHENTICATE: %s", + error)); } else if (dsasl_client_input(conn->sasl_client, buf->data, buf->used, &error) < 0) { - i_error("imapc(%s): Authentication failed: %s", - conn->name, error); + imapc_auth_failed(conn, error); } else if (dsasl_client_output(conn->sasl_client, &sasl_output, &sasl_output_len, &error) < 0) { - i_error("imapc(%s): Authentication failed: %s", - conn->name, error); + imapc_auth_failed(conn, error); } else { string_t *imap_output = t_str_new(MAX_BASE64_ENCODED_SIZE(sasl_output_len)+2); @@ -912,8 +915,7 @@ if (set->sasl_mechanisms != NULL && set->sasl_mechanisms[0] != '\0') { if (imapc_connection_get_sasl_mech(conn, &sasl_mech, &error) < 0) { - i_error("imapc(%s): Authentication failed: %s", - conn->name, error); + imapc_auth_failed(conn, error); imapc_connection_disconnect(conn); return; }
--- a/src/lib-storage/index/imapc/imapc-storage.c Sat Feb 04 15:40:41 2017 +0100 +++ b/src/lib-storage/index/imapc/imapc-storage.c Tue Feb 14 08:58:10 2017 -0500 @@ -230,7 +230,6 @@ return; } - i_error("imapc: Authentication failed: %s", reply->text_full); client->auth_failed = TRUE; if (client->_storage != NULL) {