dovecot-2.0: *-login: Abstract out SASL continue reply sending (...

dovecot at dovecot.org dovecot at dovecot.org
Wed Aug 12 23:43:49 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/50df3e60ab85
changeset: 9767:50df3e60ab85
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Aug 12 16:43:41 2009 -0400
description:
*-login: Abstract out SASL continue reply sending (for managesieve).

diffstat:

5 files changed, 22 insertions(+), 13 deletions(-)
src/imap-login/client.c               |    1 +
src/login-common/client-common-auth.c |   28 +++++++++++++++-------------
src/login-common/client-common.c      |    3 +++
src/login-common/client-common.h      |    2 ++
src/pop3-login/client.c               |    1 +

diffs (104 lines):

diff -r 7c0b29275651 -r 50df3e60ab85 src/imap-login/client.c
--- a/src/imap-login/client.c	Tue Aug 11 16:59:55 2009 -0400
+++ b/src/imap-login/client.c	Wed Aug 12 16:43:41 2009 -0400
@@ -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 -r 7c0b29275651 -r 50df3e60ab85 src/login-common/client-common-auth.c
--- a/src/login-common/client-common-auth.c	Tue Aug 11 16:59:55 2009 -0400
+++ b/src/login-common/client-common-auth.c	Wed Aug 12 16:43:41 2009 -0400
@@ -337,13 +337,25 @@ static void client_auth_input(struct cli
 	}
 }
 
+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, enu
 		}
 		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 -r 7c0b29275651 -r 50df3e60ab85 src/login-common/client-common.c
--- a/src/login-common/client-common.c	Tue Aug 11 16:59:55 2009 -0400
+++ b/src/login-common/client-common.c	Wed Aug 12 16:43:41 2009 -0400
@@ -62,6 +62,9 @@ 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;
+
 	client->created = ioloop_time;
 	client->refcount = 1;
 
diff -r 7c0b29275651 -r 50df3e60ab85 src/login-common/client-common.h
--- a/src/login-common/client-common.h	Tue Aug 11 16:59:55 2009 -0400
+++ b/src/login-common/client-common.h	Wed Aug 12 16:43:41 2009 -0400
@@ -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(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);
 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 7c0b29275651 -r 50df3e60ab85 src/pop3-login/client.c
--- a/src/pop3-login/client.c	Tue Aug 11 16:59:55 2009 -0400
+++ b/src/pop3-login/client.c	Wed Aug 12 16:43:41 2009 -0400
@@ -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
 };


More information about the dovecot-cvs mailing list