dovecot-2.0: imap-login: Using CAPABILITY command after STARTTLS...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jun 17 20:05:50 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/e8301a8f9cf7
changeset: 9489:e8301a8f9cf7
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jun 17 13:05:32 2009 -0400
description:
imap-login: Using CAPABILITY command after STARTTLS shouldn't trigger CAPABILITY pushing workaround.

diffstat:

4 files changed, 13 insertions(+), 6 deletions(-)
src/imap-login/client-authenticate.c |    3 ++-
src/imap-login/client.c              |    7 ++++++-
src/imap-login/client.h              |    3 ++-
src/imap-login/imap-proxy.c          |    6 +++---

diffs (84 lines):

diff -r 1492d688d8a9 -r e8301a8f9cf7 src/imap-login/client-authenticate.c
--- a/src/imap-login/client-authenticate.c	Wed Jun 17 12:44:33 2009 -0400
+++ b/src/imap-login/client-authenticate.c	Wed Jun 17 13:05:32 2009 -0400
@@ -327,7 +327,8 @@ static int client_auth_begin(struct imap
 {
 	char *prefix;
 
-	prefix = i_strdup_printf("%d%s", client->capability_command_used,
+	prefix = i_strdup_printf("%d%s",
+				 client->client_ignores_capability_resp_code,
 				 client->cmd_tag);
 
 	i_free(client->common.master_data_prefix);
diff -r 1492d688d8a9 -r e8301a8f9cf7 src/imap-login/client.c
--- a/src/imap-login/client.c	Wed Jun 17 12:44:33 2009 -0400
+++ b/src/imap-login/client.c	Wed Jun 17 13:05:32 2009 -0400
@@ -111,7 +111,11 @@ static const char *get_capability(struct
 
 static int cmd_capability(struct imap_client *client)
 {
-	client->capability_command_used = TRUE;
+	/* Client is required to send CAPABILITY after STARTTLS, so the
+	   capability resp-code workaround checks only pre-STARTTLS
+	   CAPABILITY commands. */
+	if (!client->starttls)
+		client->client_ignores_capability_resp_code = TRUE;
 	client_send_line(client, t_strconcat(
 		"* CAPABILITY ", get_capability(client), NULL));
 	client_send_tagline(client, "OK Capability completed.");
@@ -135,6 +139,7 @@ static void client_start_tls(struct imap
 		return;
 	}
 
+	client->starttls = TRUE;
 	client->common.proxying = TRUE;
 	client->common.tls = TRUE;
 	client->common.secured = TRUE;
diff -r 1492d688d8a9 -r e8301a8f9cf7 src/imap-login/client.h
--- a/src/imap-login/client.h	Wed Jun 17 12:44:33 2009 -0400
+++ b/src/imap-login/client.h	Wed Jun 17 13:05:32 2009 -0400
@@ -27,6 +27,7 @@ struct imap_client {
 
 	const char *cmd_tag, *cmd_name;
 
+	unsigned int starttls:1;
 	unsigned int login_success:1;
 	unsigned int cmd_finished:1;
 	unsigned int proxy_sasl_ir:1;
@@ -37,7 +38,7 @@ struct imap_client {
 	unsigned int greeting_sent:1;
 	unsigned int id_logged:1;
 	unsigned int auth_initializing:1;
-	unsigned int capability_command_used:1;
+	unsigned int client_ignores_capability_resp_code:1;
 };
 
 void client_destroy(struct imap_client *client, const char *reason);
diff -r 1492d688d8a9 -r e8301a8f9cf7 src/imap-login/imap-proxy.c
--- a/src/imap-login/imap-proxy.c	Wed Jun 17 12:44:33 2009 -0400
+++ b/src/imap-login/imap-proxy.c	Wed Jun 17 13:05:32 2009 -0400
@@ -73,12 +73,12 @@ client_send_capability_if_needed(struct 
 client_send_capability_if_needed(struct imap_client *client, string_t *str,
 				 const char *capability)
 {
-	if (!client->capability_command_used || capability == NULL)
+	if (!client->client_ignores_capability_resp_code || capability == NULL)
 		return;
 
 	/* reset this so that we don't re-send the CAPABILITY in case server
 	   sends it multiple times */
-	client->capability_command_used = FALSE;
+	client->client_ignores_capability_resp_code = FALSE;
 
 	/* client has used CAPABILITY command, so it didn't understand the
 	   capabilities in the banner. send the backend's untagged CAPABILITY
@@ -88,7 +88,7 @@ client_send_capability_if_needed(struct 
 
 static void proxy_write_login(struct imap_client *client, string_t *str)
 {
-	if (client->capability_command_used)
+	if (client->client_ignores_capability_resp_code)
 		str_append(str, "C CAPABILITY\r\n");
 
 	if (client->proxy_master_user == NULL) {


More information about the dovecot-cvs mailing list