From: Timo Sirainen Date: Wed, 12 Aug 2009 20:43:41 +0000 (-0400) Subject: *-login: Abstract out SASL continue reply sending (for managesieve). X-Git-Tag: 2.0.alpha1~285 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4c6ddf2491104f917d00e6900e833e80ea02c7b6;p=thirdparty%2Fdovecot%2Fcore.git *-login: Abstract out SASL continue reply sending (for managesieve). --HG-- branch : HEAD --- diff --git a/src/imap-login/client.c b/src/imap-login/client.c index 965be1199d..7be4750933 100644 --- a/src/imap-login/client.c +++ b/src/imap-login/client.c @@ -432,6 +432,7 @@ struct client_vfuncs client_vfuncs = { imap_client_input, imap_client_send_line, imap_client_auth_handle_reply, + NULL, imap_proxy_reset, imap_proxy_parse_line }; diff --git a/src/login-common/client-common-auth.c b/src/login-common/client-common-auth.c index 557e6b3ea5..965ef8827c 100644 --- a/src/login-common/client-common-auth.c +++ b/src/login-common/client-common-auth.c @@ -337,13 +337,25 @@ static void client_auth_input(struct client *client) } } +void client_auth_send_continue(struct client *client, const char *data) +{ + struct const_iovec iov[3]; + + iov[0].iov_base = "+ "; + iov[0].iov_len = 2; + iov[1].iov_base = data; + iov[1].iov_len = strlen(data); + iov[2].iov_base = "\r\n"; + iov[2].iov_len = 2; + + (void)o_stream_sendv(client->output, iov, 3); +} + static void sasl_callback(struct client *client, enum sasl_server_reply sasl_reply, const char *data, const char *const *args) { - struct const_iovec iov[3]; struct client_auth_reply reply; - size_t data_len; i_assert(!client->destroyed || sasl_reply == SASL_SERVER_REPLY_AUTH_ABORTED || @@ -398,17 +410,7 @@ sasl_callback(struct client *client, enum sasl_server_reply sasl_reply, } break; case SASL_SERVER_REPLY_CONTINUE: - data_len = strlen(data); - iov[0].iov_base = "+ "; - iov[0].iov_len = 2; - iov[1].iov_base = data; - iov[1].iov_len = data_len; - iov[2].iov_base = "\r\n"; - iov[2].iov_len = 2; - - /* don't check return value here. it gets tricky if we try - to call client_destroy() in here. */ - (void)o_stream_sendv(client->output, iov, 3); + client->v.auth_send_continue(client, data); if (client->to_auth_waiting != NULL) timeout_remove(&client->to_auth_waiting); diff --git a/src/login-common/client-common.c b/src/login-common/client-common.c index be67626d75..6008a36f62 100644 --- a/src/login-common/client-common.c +++ b/src/login-common/client-common.c @@ -62,6 +62,9 @@ struct client *client_create(int fd, bool ssl, pool_t pool, client = client_vfuncs.alloc(pool); client->v = client_vfuncs; + if (client->v.auth_send_continue == NULL) + client->v.auth_send_continue = client_auth_send_continue; + client->created = ioloop_time; client->refcount = 1; diff --git a/src/login-common/client-common.h b/src/login-common/client-common.h index ae1d01cc2c..58803f3742 100644 --- a/src/login-common/client-common.h +++ b/src/login-common/client-common.h @@ -62,6 +62,7 @@ struct client_vfuncs { const char *text); bool (*auth_handle_reply)(struct client *client, const struct client_auth_reply *reply); + void (*auth_send_continue)(struct client *client, const char *data); void (*proxy_reset)(struct client *client); int (*proxy_parse_line)(struct client *client, const char *line); }; @@ -153,6 +154,7 @@ void client_send_raw_data(struct client *client, const void *data, size_t size); void client_send_raw(struct client *client, const char *data); void client_set_auth_waiting(struct client *client); +void client_auth_send_continue(struct client *client, const char *data); int client_auth_begin(struct client *client, const char *mech_name, const char *init_resp); bool client_check_plaintext_auth(struct client *client, bool pass_sent); diff --git a/src/pop3-login/client.c b/src/pop3-login/client.c index b82dad4e43..9df176d4d5 100644 --- a/src/pop3-login/client.c +++ b/src/pop3-login/client.c @@ -219,6 +219,7 @@ struct client_vfuncs client_vfuncs = { pop3_client_input, pop3_client_send_line, pop3_client_auth_handle_reply, + NULL, pop3_proxy_reset, pop3_proxy_parse_line };