[evolution-data-server/evolution-data-server-3-12] [IMAPX] Do not expose user credentials in debug logs
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/evolution-data-server-3-12] [IMAPX] Do not expose user credentials in debug logs
- Date: Wed, 16 Apr 2014 16:58:46 +0000 (UTC)
commit 5fa3bda4dd018c2690c34d42505b359f077adc51
Author: Milan Crha <mcrha redhat com>
Date: Wed Apr 16 18:56:10 2014 +0200
[IMAPX] Do not expose user credentials in debug logs
And skip trailing \r\n in the io logs as well.
camel/providers/imapx/camel-imapx-logger.c | 29 +++++++++++++++++++++++++--
1 files changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-logger.c b/camel/providers/imapx/camel-imapx-logger.c
index 30f9de9..6bfd9ce 100644
--- a/camel/providers/imapx/camel-imapx-logger.c
+++ b/camel/providers/imapx/camel-imapx-logger.c
@@ -112,6 +112,7 @@ imapx_logger_convert (GConverter *converter,
CamelIMAPXLoggerPrivate *priv;
GConverterResult result;
gsize min_size;
+ const gchar *login_start;
priv = CAMEL_IMAPX_LOGGER_GET_PRIVATE (converter);
@@ -120,9 +121,31 @@ imapx_logger_convert (GConverter *converter,
memcpy (outbuf, inbuf, min_size);
*bytes_read = *bytes_written = min_size;
- camel_imapx_debug (
- io, priv->prefix, "I/O: '%.*s'\n",
- (gint) min_size, (gchar *) outbuf);
+ login_start = g_strstr_len (outbuf, min_size, " LOGIN ");
+ if (login_start > (const gchar *) outbuf) {
+ const gchar *space = g_strstr_len (outbuf, min_size, " ");
+
+ if (space == login_start) {
+ camel_imapx_debug (
+ io, priv->prefix, "I/O: '%.*s ...'\n",
+ (gint) (login_start - ((const gchar *) outbuf) + 6), (gchar *) outbuf);
+ } else {
+ /* To print the command the other way */
+ login_start = NULL;
+ }
+ }
+
+ if (!login_start) {
+ /* Skip ending '\n' '\r'; it may sometimes show wrong data,
+ when the input is divided into wrong chunks, but it will
+ usually work as is needed, no extra new-lines in the log */
+ while (min_size > 0 && (((gchar *) outbuf)[min_size - 1] == '\r' || ((gchar *)
outbuf)[min_size - 1] == '\n'))
+ min_size--;
+
+ camel_imapx_debug (
+ io, priv->prefix, "I/O: '%.*s'\n",
+ (gint) min_size, (gchar *) outbuf);
+ }
if ((flags & G_CONVERTER_INPUT_AT_END) != 0)
result = G_CONVERTER_FINISHED;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]