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)
{
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;
}
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);
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;
}