changeset 9142:5ee5def4f0ff HEAD

imap-login: Using CAPABILITY command after STARTTLS shouldn't trigger CAPABILITY pushing workaround.
author Timo Sirainen <tss@iki.fi>
date Wed, 17 Jun 2009 13:05:40 -0400
parents d21bd1a1710a
children 675f0df22f24
files src/imap-login/client.c src/imap-login/client.h src/imap-login/imap-proxy.c
diffstat 3 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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:40 2009 -0400
@@ -105,7 +105,11 @@
 
 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, TRUE), NULL));
 	client_send_tagline(client, "OK Capability completed.");
@@ -130,6 +134,7 @@
 		return;
 	}
 
+	client->starttls = TRUE;
 	client->common.tls = TRUE;
 	client->common.secured = TRUE;
 	client_set_title(client);
--- 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:40 2009 -0400
@@ -28,6 +28,7 @@
 
 	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;
@@ -38,7 +39,7 @@
 	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);
--- 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:40 2009 -0400
@@ -113,12 +113,12 @@
 	const char *const *backend_capabilities;
 	const char *const *proxy_capabilities;
 
-	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. if backend server has different
@@ -138,7 +138,7 @@
 
 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) {