[evolution-data-server/gnome-3-0] Do not expose password in imapx log



commit 057e2e8464a30f549aceda877f2bd948fdc199f0
Author: Milan Crha <mcrha redhat com>
Date:   Tue Aug 30 16:52:04 2011 +0200

    Do not expose password in imapx log

 camel/providers/imapx/camel-imapx-server.c |   10 +++++++---
 camel/providers/imapx/camel-imapx-stream.c |    6 +++++-
 2 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 6a90677..622270d 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -621,7 +621,7 @@ imapx_command_addv (CamelIMAPXCommand *ic, const gchar *fmt, va_list ap)
 					break;
 				case 's': /* simple string */
 					s = va_arg (ap, gchar *);
-					c(ic->is->tagprefix, "got string '%s'\n", s);
+					c(ic->is->tagprefix, "got string '%s'\n", g_str_has_prefix (fmt, "LOGIN") ? "***" : s);
 				output_string:
 					if (*s) {
 						guchar mask = imapx_is_mask (s);
@@ -815,7 +815,11 @@ camel_imapx_command_close (CamelIMAPXCommand *ic)
 
 		byte_array = camel_stream_mem_get_byte_array (ic->mem);
 
-		c(ic->is->tagprefix, "completing command buffer is [%d] '%.*s'\n", byte_array->len, (gint)byte_array->len, byte_array->data);
+		if (g_str_has_prefix ((const gchar *) byte_array->data, "LOGIN")) {
+			c(ic->is->tagprefix, "completing command buffer is [%d] 'LOGIN...'\n", byte_array->len);
+		} else {
+			c(ic->is->tagprefix, "completing command buffer is [%d] '%.*s'\n", byte_array->len, (gint)byte_array->len, byte_array->data);
+		}
 		if (byte_array->len > 0)
 			imapx_command_add_part (ic, CAMEL_IMAPX_COMMAND_SIMPLE, NULL);
 
@@ -845,7 +849,7 @@ imapx_command_start (CamelIMAPXServer *imap, CamelIMAPXCommand *ic)
 
 	g_static_rec_mutex_lock (&imap->ostream_lock);
 
-	c(imap->tagprefix, "Starting command (active=%d,%s) %c%05u %s\r\n", camel_dlist_length(&imap->active), imap->literal?" literal":"", imap->tagprefix, ic->tag, cp->data);
+	c(imap->tagprefix, "Starting command (active=%d,%s) %c%05u %s\r\n", camel_dlist_length(&imap->active), imap->literal?" literal":"", imap->tagprefix, ic->tag, cp->data && g_str_has_prefix (cp->data, "LOGIN") ? "LOGIN..." : cp->data);
 	if (!imap->stream || camel_stream_printf((CamelStream *)imap->stream, "%c%05u %s\r\n", imap->tagprefix, ic->tag, cp->data) == -1) {
 		g_set_error (
 			&ic->error, CAMEL_IMAPX_ERROR, 1,
diff --git a/camel/providers/imapx/camel-imapx-stream.c b/camel/providers/imapx/camel-imapx-stream.c
index 88820e1..89a2f06 100644
--- a/camel/providers/imapx/camel-imapx-stream.c
+++ b/camel/providers/imapx/camel-imapx-stream.c
@@ -149,7 +149,11 @@ imapx_stream_write (CamelStream *stream,
 {
 	CamelIMAPXStream *is = (CamelIMAPXStream *)stream;
 
-	io(is->tagprefix, "camel_imapx_write: '%.*s'\n", (gint)n, buffer);
+	if (g_strstr_len (buffer, n, "LOGIN")) {
+		io(is->tagprefix, "camel_imapx_write: 'LOGIN...'\n");
+	} else {
+		io(is->tagprefix, "camel_imapx_write: '%.*s'\n", (gint)n, buffer);
+	}
 
 	return camel_stream_write (is->source, buffer, n, cancellable, error);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]