[evolution-data-server] Do not expose password in imapx log



commit bbe1f6ced61be92019d6d7f85ee765ca3166517d
Author: Milan Crha <mcrha redhat com>
Date:   Tue Aug 30 16:46:56 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 4a859d8..15ca8ef 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -629,7 +629,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);
@@ -832,7 +832,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);
 
@@ -863,7 +867,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 != NULL) {
 		gchar *string;
 
diff --git a/camel/providers/imapx/camel-imapx-stream.c b/camel/providers/imapx/camel-imapx-stream.c
index 72b0888..d3b74e6 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]