dovecot-2.0: *-login: Allow backend to parse SASL responses from...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Aug 13 20:00:52 EEST 2009
details: http://hg.dovecot.org/dovecot-2.0/rev/19912e4a2fb3
changeset: 9781:19912e4a2fb3
user: Timo Sirainen <tss at iki.fi>
date: Thu Aug 13 13:00:43 2009 -0400
description:
*-login: Allow backend to parse SASL responses from client (for managesieve).
diffstat:
5 files changed, 42 insertions(+), 27 deletions(-)
src/imap-login/client.c | 1
src/login-common/client-common-auth.c | 55 +++++++++++++++++++--------------
src/login-common/client-common.c | 6 ++-
src/login-common/client-common.h | 6 ++-
src/pop3-login/client.c | 1
diffs (136 lines):
diff -r 8a6d1d2db78c -r 19912e4a2fb3 src/imap-login/client.c
--- a/src/imap-login/client.c Thu Aug 13 13:00:17 2009 -0400
+++ b/src/imap-login/client.c Thu Aug 13 13:00:43 2009 -0400
@@ -433,6 +433,7 @@ struct client_vfuncs client_vfuncs = {
imap_client_send_line,
imap_client_auth_handle_reply,
NULL,
+ NULL,
imap_proxy_reset,
imap_proxy_parse_line
};
diff -r 8a6d1d2db78c -r 19912e4a2fb3 src/login-common/client-common-auth.c
--- a/src/login-common/client-common-auth.c Thu Aug 13 13:00:17 2009 -0400
+++ b/src/login-common/client-common-auth.c Thu Aug 13 13:00:43 2009 -0400
@@ -324,31 +324,40 @@ client_auth_handle_reply(struct client *
return client->v.auth_handle_reply(client, reply);
}
+int client_auth_parse_response(struct client *client, char **data_r)
+{
+ if (!client_read(client))
+ return 0;
+
+ /* @UNSAFE */
+ *data_r = i_stream_next_line(client->input);
+ if (*data_r == NULL)
+ return 0;
+
+ if (strcmp(*data_r, "*") == 0) {
+ sasl_server_auth_abort(client);
+ return -1;
+ }
+ return 1;
+}
+
static void client_auth_input(struct client *client)
{
char *line;
-
- if (!client_read(client))
- return;
-
- /* @UNSAFE */
- line = i_stream_next_line(client->input);
- if (line == NULL)
- return;
-
- if (strcmp(line, "*") == 0)
- sasl_server_auth_abort(client);
- else {
- client_set_auth_waiting(client);
- auth_client_request_continue(client->auth_request, line);
- io_remove(&client->io);
-
- /* clear sensitive data */
- safe_memset(line, 0, strlen(line));
- }
-}
-
-void client_auth_send_continue(struct client *client, const char *data)
+ int ret;
+
+ if ((ret = client->v.auth_parse_response(client, &line)) <= 0)
+ return;
+
+ client_set_auth_waiting(client);
+ auth_client_request_continue(client->auth_request, line);
+ io_remove(&client->io);
+
+ /* clear sensitive data */
+ safe_memset(line, 0, strlen(line));
+}
+
+void client_auth_send_challenge(struct client *client, const char *data)
{
struct const_iovec iov[3];
@@ -421,7 +430,7 @@ sasl_callback(struct client *client, enu
}
break;
case SASL_SERVER_REPLY_CONTINUE:
- client->v.auth_send_continue(client, data);
+ client->v.auth_send_challenge(client, data);
if (client->to_auth_waiting != NULL)
timeout_remove(&client->to_auth_waiting);
diff -r 8a6d1d2db78c -r 19912e4a2fb3 src/login-common/client-common.c
--- a/src/login-common/client-common.c Thu Aug 13 13:00:17 2009 -0400
+++ b/src/login-common/client-common.c Thu Aug 13 13:00:43 2009 -0400
@@ -62,8 +62,10 @@ struct client *client_create(int fd, boo
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;
+ if (client->v.auth_send_challenge == NULL)
+ client->v.auth_send_challenge = client_auth_send_challenge;
+ if (client->v.auth_parse_response == NULL)
+ client->v.auth_parse_response = client_auth_parse_response;
client->created = ioloop_time;
client->refcount = 1;
diff -r 8a6d1d2db78c -r 19912e4a2fb3 src/login-common/client-common.h
--- a/src/login-common/client-common.h Thu Aug 13 13:00:17 2009 -0400
+++ b/src/login-common/client-common.h Thu Aug 13 13:00:43 2009 -0400
@@ -63,7 +63,8 @@ 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 (*auth_send_challenge)(struct client *client, const char *data);
+ int (*auth_parse_response)(struct client *client, char **data_r);
void (*proxy_reset)(struct client *client);
int (*proxy_parse_line)(struct client *client, const char *line);
};
@@ -155,7 +156,8 @@ void client_send_raw(struct client *clie
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);
+void client_auth_send_challenge(struct client *client, const char *data);
+int client_auth_parse_response(struct client *client, char **data_r);
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 -r 8a6d1d2db78c -r 19912e4a2fb3 src/pop3-login/client.c
--- a/src/pop3-login/client.c Thu Aug 13 13:00:17 2009 -0400
+++ b/src/pop3-login/client.c Thu Aug 13 13:00:43 2009 -0400
@@ -220,6 +220,7 @@ struct client_vfuncs client_vfuncs = {
pop3_client_send_line,
pop3_client_auth_handle_reply,
NULL,
+ NULL,
pop3_proxy_reset,
pop3_proxy_parse_line
};
More information about the dovecot-cvs
mailing list