dovecot-2.0: login proxy: Show proxy state in "disconnected" err...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Aug 12 17:30:12 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/c27bca966b54
changeset: 11982:c27bca966b54
user: Timo Sirainen <tss at iki.fi>
date: Thu Aug 12 15:30:08 2010 +0100
description:
login proxy: Show proxy state in "disconnected" error message.
diffstat:
src/imap-login/imap-proxy.c | 17 +++++++++++++++++
src/login-common/client-common-auth.c | 4 ++--
src/login-common/client-common.h | 1 +
src/pop3-login/client.h | 2 --
src/pop3-login/pop3-proxy.c | 12 +++++-------
5 files changed, 25 insertions(+), 11 deletions(-)
diffs (158 lines):
diff -r b9bdcfd6eaa7 -r c27bca966b54 src/imap-login/imap-proxy.c
--- a/src/imap-login/imap-proxy.c Thu Aug 12 15:20:58 2010 +0100
+++ b/src/imap-login/imap-proxy.c Thu Aug 12 15:30:08 2010 +0100
@@ -17,6 +17,16 @@
#include <stdlib.h>
+enum imap_proxy_state {
+ IMAP_PROXY_STATE_NONE,
+ IMAP_PROXY_STATE_BANNER,
+ IMAP_PROXY_STATE_ID,
+ IMAP_PROXY_STATE_STARTTLS,
+ IMAP_PROXY_STATE_CAPABILITY,
+ IMAP_PROXY_STATE_AUTH_CONTINUE,
+ IMAP_PROXY_STATE_LOGIN
+};
+
static void proxy_write_id(struct imap_client *client, string_t *str)
{
str_printfa(str, "I ID ("
@@ -164,6 +174,7 @@
output = login_proxy_get_ostream(client->login_proxy);
if (!imap_client->proxy_seen_banner) {
/* this is a banner */
+ client->proxy_state = IMAP_PROXY_STATE_BANNER;
imap_client->proxy_seen_banner = TRUE;
if (proxy_input_banner(imap_client, output, line) < 0) {
client_proxy_failed(client, TRUE);
@@ -176,6 +187,7 @@
/* used literals with LOGIN command, just ignore. */
return 0;
}
+ client->proxy_state = IMAP_PROXY_STATE_AUTH_CONTINUE;
imap_client->proxy_wait_auth_continue = FALSE;
str = t_str_new(128);
@@ -195,6 +207,7 @@
return -1;
}
/* STARTTLS successful, begin TLS negotiation. */
+ client->proxy_state = IMAP_PROXY_STATE_STARTTLS;
if (login_proxy_starttls(client->login_proxy) < 0) {
client_proxy_failed(client, TRUE);
return -1;
@@ -207,6 +220,7 @@
return 1;
} else if (strncmp(line, "L OK ", 5) == 0) {
/* Login successful. Send this line to client. */
+ client->proxy_state = IMAP_PROXY_STATE_LOGIN;
str = t_str_new(128);
client_send_login_reply(imap_client, str, line + 5);
(void)o_stream_send(client->output,
@@ -258,10 +272,12 @@
return 0;
} else if (strncmp(line, "C ", 2) == 0) {
/* Reply to CAPABILITY command we sent, ignore it */
+ client->proxy_state = IMAP_PROXY_STATE_CAPABILITY;
return 0;
} else if (strncasecmp(line, "I ", 2) == 0 ||
strncasecmp(line, "* ID ", 5) == 0) {
/* Reply to ID command we sent, ignore it */
+ client->proxy_state = IMAP_PROXY_STATE_ID;
return 0;
} else if (strncmp(line, "* ", 2) == 0) {
/* untagged reply. just foward it. */
@@ -283,4 +299,5 @@
imap_client->proxy_sasl_ir = FALSE;
imap_client->proxy_seen_banner = FALSE;
imap_client->proxy_wait_auth_continue = FALSE;
+ client->proxy_state = IMAP_PROXY_STATE_NONE;
}
diff -r b9bdcfd6eaa7 -r c27bca966b54 src/login-common/client-common-auth.c
--- a/src/login-common/client-common-auth.c Thu Aug 12 15:20:58 2010 +0100
+++ b/src/login-common/client-common-auth.c Thu Aug 12 15:30:08 2010 +0100
@@ -217,10 +217,10 @@
return;
case -1:
client_log_err(client, t_strdup_printf(
- "proxy: Remote %s:%u disconnected: %s",
+ "proxy: Remote %s:%u disconnected: %s (state=%u)",
login_proxy_get_host(client->login_proxy),
login_proxy_get_port(client->login_proxy),
- get_disconnect_reason(input)));
+ get_disconnect_reason(input), client->proxy_state));
client_proxy_failed(client, TRUE);
return;
}
diff -r b9bdcfd6eaa7 -r c27bca966b54 src/login-common/client-common.h
--- a/src/login-common/client-common.h Thu Aug 12 15:20:58 2010 +0100
+++ b/src/login-common/client-common.h Thu Aug 12 15:30:08 2010 +0100
@@ -95,6 +95,7 @@
struct login_proxy *login_proxy;
char *proxy_user, *proxy_master_user, *proxy_password;
+ unsigned int proxy_state;
char *auth_mech_name;
struct auth_client_request *auth_request;
diff -r b9bdcfd6eaa7 -r c27bca966b54 src/pop3-login/client.h
--- a/src/pop3-login/client.h Thu Aug 12 15:20:58 2010 +0100
+++ b/src/pop3-login/client.h Thu Aug 12 15:30:08 2010 +0100
@@ -15,8 +15,6 @@
struct pop3_client {
struct client common;
- enum pop3_proxy_state proxy_state;
-
char *last_user;
char *apop_challenge;
unsigned int apop_server_pid, apop_connect_uid;
diff -r b9bdcfd6eaa7 -r c27bca966b54 src/pop3-login/pop3-proxy.c
--- a/src/pop3-login/pop3-proxy.c Thu Aug 12 15:20:58 2010 +0100
+++ b/src/pop3-login/pop3-proxy.c Thu Aug 12 15:30:08 2010 +0100
@@ -48,7 +48,7 @@
str_append(str, "AUTH PLAIN\r\n");
}
(void)o_stream_send(output, str_data(str), str_len(str));
- client->proxy_state = POP3_PROXY_LOGIN1;
+ client->common.proxy_state = POP3_PROXY_LOGIN1;
}
int pop3_proxy_parse_line(struct client *client, const char *line)
@@ -61,7 +61,7 @@
i_assert(!client->destroyed);
output = login_proxy_get_ostream(client->login_proxy);
- switch (pop3_client->proxy_state) {
+ switch (client->proxy_state) {
case POP3_PROXY_BANNER:
/* this is a banner */
if (strncmp(line, "+OK", 3) != 0) {
@@ -77,7 +77,7 @@
proxy_send_login(pop3_client, output);
} else {
(void)o_stream_send_str(output, "STLS\r\n");
- pop3_client->proxy_state = POP3_PROXY_STARTTLS;
+ client->proxy_state = POP3_PROXY_STARTTLS;
}
return 0;
case POP3_PROXY_STARTTLS:
@@ -115,7 +115,7 @@
}
(void)o_stream_send(output, str_data(str), str_len(str));
proxy_free_password(client);
- pop3_client->proxy_state = POP3_PROXY_LOGIN2;
+ client->proxy_state = POP3_PROXY_LOGIN2;
return 0;
case POP3_PROXY_LOGIN2:
if (strncmp(line, "+OK", 3) != 0)
@@ -162,7 +162,5 @@
void pop3_proxy_reset(struct client *client)
{
- struct pop3_client *pop3_client = (struct pop3_client *)client;
-
- pop3_client->proxy_state = POP3_PROXY_BANNER;
+ client->proxy_state = POP3_PROXY_BANNER;
}
More information about the dovecot-cvs
mailing list