Package: dovecot / 1:2.2.13-12~deb8u4

bye_logout_not_sent.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
From: Jaldhar H. Vyas <jaldhar@debian.org>
Date: Tue, 24 Jun 2014 18:34:12 -0400
Subject: Fix for BYE and LOGOUT replies not being sent
Description: This is a combination of three upstream hg patchsets:
 # User Timo Sirainen <tss@iki.fi>
 # Date 1401957019 -10800
 # Node ID 09d3c9c6f0ad473e0114edac67d4ec43cf7255bd
 # Parent  304d545927d25ea352ac596b7d7ce2e96468fe2e
 *-login: Flush SSL output when logging out.
 The BYE and LOGOUT replies weren't being sent when they were sent from
 imap-login process (before logging in).
 .
 # User Teemu Huovila <teemu.huovila@dovecot.fi>
 # Date 1402305282 -10800
 # Node ID 7129fe8bc260642cb79c8bbad9d20ef47e82f3d2
 # Parent  6a9508d28d340091b0a2897e4e4b5ba826d39a17
 login-common: Fixed infinite loop in ssl proxy flushing.
 .
 # User Timo Sirainen <tss@iki.fi>
 # Date 1402310519 -10800
 # Node ID 5259f6320e52d004fcd479d98e33c832f4627966
 # Parent  7129fe8bc260642cb79c8bbad9d20ef47e82f3d2
 login-common: Fixed potential crash at client disconnect.
 Broken by recent change
Bug: #751682

 src/login-common/client-common.c     |  2 ++
 src/login-common/ssl-proxy-openssl.c | 13 ++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)
----
diff --git a/src/login-common/client-common.c b/src/login-common/client-common.c
index 6cebce9..e097d64 100644
--- a/src/login-common/client-common.c
+++ b/src/login-common/client-common.c
@@ -172,6 +172,8 @@ void client_destroy(struct client *client, const char *reason)
 		last_client = client->prev;
 	DLLIST_REMOVE(&clients, client);
 
+	if (client->output != NULL)
+		o_stream_uncork(client->output);
 	if (!client->login_success && client->ssl_proxy != NULL)
 		ssl_proxy_destroy(client->ssl_proxy);
 	if (client->input != NULL)
diff --git a/src/login-common/ssl-proxy-openssl.c b/src/login-common/ssl-proxy-openssl.c
index 92e5dcb..4070dfd 100644
--- a/src/login-common/ssl-proxy-openssl.c
+++ b/src/login-common/ssl-proxy-openssl.c
@@ -79,6 +79,7 @@ struct ssl_proxy {
 	unsigned int cert_received:1;
 	unsigned int cert_broken:1;
 	unsigned int client_proxy:1;
+	unsigned int flushing:1;
 };
 
 struct ssl_parameters {
@@ -806,10 +807,20 @@ static void ssl_proxy_unref(struct ssl_proxy *proxy)
 	i_free(proxy);
 }
 
+static void ssl_proxy_flush(struct ssl_proxy *proxy)
+{
+	/* this is pretty kludgy. mainly this is just for flushing the final
+	   LOGOUT command output. */
+	plain_read(proxy);
+	ssl_step(proxy);
+}
+
 void ssl_proxy_destroy(struct ssl_proxy *proxy)
 {
-	if (proxy->destroyed)
+	if (proxy->destroyed || proxy->flushing)
 		return;
+	proxy->flushing = TRUE;
+	ssl_proxy_flush(proxy);
 	proxy->destroyed = TRUE;
 
 	ssl_proxy_count--;