Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/elog/
Date: Fri, 18 Nov 2011 02:55:49
Message-Id: 87cd5dba474f758e291b87a39366bd7edd748bf7.zmedico@gentoo
1 commit: 87cd5dba474f758e291b87a39366bd7edd748bf7
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Fri Nov 18 02:55:28 2011 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Fri Nov 18 02:55:28 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=87cd5dba
7
8 collect_ebuild_messages: validate msg type
9
10 This will handle invalid message types like the one that triggers the
11 KeyError in dblink._elog_process for bug #390833. It will also output
12 the content of the line in order to help diagnose the source of
13 corruption.
14
15 ---
16 pym/portage/elog/messages.py | 12 +++++++++++-
17 1 files changed, 11 insertions(+), 1 deletions(-)
18
19 diff --git a/pym/portage/elog/messages.py b/pym/portage/elog/messages.py
20 index f5232d3..98d6206 100644
21 --- a/pym/portage/elog/messages.py
22 +++ b/pym/portage/elog/messages.py
23 @@ -18,6 +18,14 @@ from portage import _unicode_decode
24 import io
25 import sys
26
27 +_log_levels = frozenset([
28 + "ERROR",
29 + "INFO",
30 + "LOG",
31 + "QA",
32 + "WARN",
33 +])
34 +
35 def collect_ebuild_messages(path):
36 """ Collect elog messages generated by the bash logging function stored
37 at 'path'.
38 @@ -52,9 +60,11 @@ def collect_ebuild_messages(path):
39 continue
40 try:
41 msgtype, msg = l.split(" ", 1)
42 + if msgtype not in _log_levels:
43 + raise ValueError(msgtype)
44 except ValueError:
45 writemsg(_("!!! malformed entry in "
46 - "log file: '%s'\n") % filename, noiselevel=-1)
47 + "log file: '%s': %s\n") % (filename, l), noiselevel=-1)
48 continue
49
50 if lastmsgtype is None: