dovecot-1.1: Proxy: Log destuser in the "proxying" line if it's ...

dovecot at dovecot.org dovecot at dovecot.org
Thu Aug 14 10:11:07 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/5d0406541434
changeset: 7821:5d0406541434
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Aug 14 03:10:34 2008 -0400
description:
Proxy: Log destuser in the "proxying" line if it's different from username.

diffstat:

2 files changed, 25 insertions(+), 12 deletions(-)
src/imap-login/imap-proxy.c |   18 ++++++++++++------
src/pop3-login/pop3-proxy.c |   19 +++++++++++++------

diffs (85 lines):

diff -r 0dd6386cbc93 -r 5d0406541434 src/imap-login/imap-proxy.c
--- a/src/imap-login/imap-proxy.c	Tue Aug 12 18:20:46 2008 -0400
+++ b/src/imap-login/imap-proxy.c	Thu Aug 14 03:10:34 2008 -0400
@@ -15,7 +15,6 @@ static int proxy_input_line(struct imap_
 			    struct ostream *output, const char *line)
 {
 	string_t *str;
-	const char *msg;
 
 	i_assert(!client->destroyed);
 
@@ -53,10 +52,17 @@ static int proxy_input_line(struct imap_
 		(void)o_stream_send(client->output,
 				    str_data(str), str_len(str));
 
-		msg = t_strdup_printf("proxy(%s): started proxying to %s:%u",
-				      client->common.virtual_user,
-				      login_proxy_get_host(client->proxy),
-				      login_proxy_get_port(client->proxy));
+		str_truncate(str, 0);
+		str_printfa(str, "proxy(%s): started proxying to %s:%u",
+			    client->common.virtual_user,
+			    login_proxy_get_host(client->proxy),
+			    login_proxy_get_port(client->proxy));
+		if (strcmp(client->common.virtual_user,
+			   client->proxy_user) != 0) {
+			/* remote username is different, log it */
+			str_append_c(str, '/');
+			str_append(str, client->proxy_user);
+		}
 
 		(void)client_skip_line(client);
 		login_proxy_detach(client->proxy, client->input,
@@ -66,7 +72,7 @@ static int proxy_input_line(struct imap_
 		client->input = NULL;
 		client->output = NULL;
 		client->common.fd = -1;
-		client_destroy_success(client, msg);
+		client_destroy_success(client, str_c(str));
 		return -1;
 	} else if (strncmp(line, "P ", 2) == 0) {
 		/* If the backend server isn't Dovecot, the error message may
diff -r 0dd6386cbc93 -r 5d0406541434 src/pop3-login/pop3-proxy.c
--- a/src/pop3-login/pop3-proxy.c	Tue Aug 12 18:20:46 2008 -0400
+++ b/src/pop3-login/pop3-proxy.c	Thu Aug 14 03:10:34 2008 -0400
@@ -15,7 +15,7 @@ static void proxy_input(struct istream *
 			struct pop3_client *client)
 {
 	string_t *str;
-	const char *line, *msg;
+	const char *line;
 
 	if (input == NULL) {
 		if (client->io != NULL) {
@@ -102,10 +102,17 @@ static void proxy_input(struct istream *
 		line = t_strconcat(line, "\r\n", NULL);
 		(void)o_stream_send_str(client->output, line);
 
-		msg = t_strdup_printf("proxy(%s): started proxying to %s:%u",
-				      client->common.virtual_user,
-				      login_proxy_get_host(client->proxy),
-				      login_proxy_get_port(client->proxy));
+		str = t_str_new(128);
+		str_printfa(str, "proxy(%s): started proxying to %s:%u",
+			    client->common.virtual_user,
+			    login_proxy_get_host(client->proxy),
+			    login_proxy_get_port(client->proxy));
+		if (strcmp(client->common.virtual_user,
+			   client->proxy_user) != 0) {
+			/* remote username is different, log it */
+			str_append_c(str, '/');
+			str_append(str, client->proxy_user);
+		}
 
 		login_proxy_detach(client->proxy, client->input,
 				   client->output);
@@ -114,7 +121,7 @@ static void proxy_input(struct istream *
 		client->input = NULL;
 		client->output = NULL;
 		client->common.fd = -1;
-		client_destroy_success(client, msg);
+		client_destroy_success(client, str_c(str));
 		return;
 	}
 


More information about the dovecot-cvs mailing list