From a040c666caa859cfde5d38e5976cf915a8b8d006 Mon Sep 17 00:00:00 2001 From: Giel van Schijndel Date: Sat, 9 Aug 2014 22:39:16 +0200 Subject: [PATCH] IMAP: don't spam the logs about non-SSL connections to localhost When using IMAP as auth module every single request causes a warning to be logged just because we're not encrypting traffic sent to another process on the *same* machine. This change recognizes that while some people might consider this undesirable, others might have made this a conscious choice and *don't* wish to be spammed for it. As such now only a single warning is logged (the first time in the server's lifetime that a user logs in). Signed-off-by: Giel van Schijndel --- radicale/auth/IMAP.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/radicale/auth/IMAP.py b/radicale/auth/IMAP.py index 394c650..ecca086 100644 --- a/radicale/auth/IMAP.py +++ b/radicale/auth/IMAP.py @@ -40,9 +40,12 @@ IMAP_SERVER = config.get("auth", "imap_hostname") IMAP_SERVER_PORT = config.getint("auth", "imap_port") IMAP_USE_SSL = config.getboolean("auth", "imap_ssl") +IMAP_WARNED_UNENCRYPTED = False def is_authenticated(user, password): """Check if ``user``/``password`` couple is valid.""" + global IMAP_WARNED_UNENCRYPTED + if not user or not password: return False @@ -72,7 +75,8 @@ def is_authenticated(user, password): "IMAP server at %s failed to accept TLS connection " "because of: %s" % (IMAP_SERVER, exception)) - if server_is_local and not connection_is_secure: + if server_is_local and not connection_is_secure and not IMAP_WARNED_UNENCRYPTED: + IMAP_WARNED_UNENCRYPTED = True log.LOGGER.warning( "IMAP server is local. " "Will allow transmitting unencrypted credentials.")