From 3d8ea0e6edac2eb2ae76d4538751ea838a299063 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Fri, 2 Jan 2015 22:49:25 +0000 Subject: [PATCH] mail log scanner: dont assume lines are utf8 --- management/mail_log.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/management/mail_log.py b/management/mail_log.py index 1d8d1299..c506a75d 100755 --- a/management/mail_log.py +++ b/management/mail_log.py @@ -18,8 +18,9 @@ def scan_mail_log(logger, env): for fn in ('/var/log/mail.log.1', '/var/log/mail.log'): if not os.path.exists(fn): continue - with open(fn) as log: + with open(fn, 'rb') as log: for line in log: + line = line.decode("utf8", errors='replace') scan_mail_log_line(line.strip(), collector) if collector["imap-logins"]: