mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
Merge utils: catch TypeError exception for binary logs
When a log like system.journal is passed on to aa-genprof, for
example, the user receives a TypeError exception: in method
'parse_record', argument 1 of type 'char *'
This patch catches that exception and displays a more meaningful
message.
Fixes: https://gitlab.com/apparmor/apparmor/-/issues/436
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
Closes #436
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1354
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit cb0f84e101
)
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
This commit is contained in:
parent
af37940d59
commit
7ead5556dd
1 changed files with 8 additions and 1 deletions
|
@ -18,6 +18,7 @@ import sys
|
|||
import time
|
||||
|
||||
import LibAppArmor
|
||||
import apparmor.ui as aaui
|
||||
from apparmor.common import AppArmorBug, AppArmorException, DebugLogger, hasher, open_file_read, split_name
|
||||
from apparmor.translations import init_translation
|
||||
|
||||
|
@ -84,7 +85,13 @@ class ReadLog:
|
|||
"""Parse the event from log into key value pairs"""
|
||||
msg = msg.strip()
|
||||
self.debug_logger.info('parse_event: %s', msg)
|
||||
event = LibAppArmor.parse_record(msg)
|
||||
|
||||
try:
|
||||
event = LibAppArmor.parse_record(msg)
|
||||
except TypeError:
|
||||
aaui.UI_Important(_("WARNING: Cannot process log message, skipping entry. Make sure log is plaintext."))
|
||||
return None
|
||||
|
||||
ev = dict()
|
||||
ev['resource'] = event.info
|
||||
ev['active_hat'] = event.active_hat
|
||||
|
|
Loading…
Add table
Reference in a new issue