From 59d1907e54e76bce6cc0c33287cc8d36ff2c2f89 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Jan 02 2020 09:33:03 +0000 Subject: framework: sepolicy.info() returns a generator, not a list Commit c55edb36ca68 ("framework: Fix AVC.__typeMatch to handle aliases properly") was forward ported from stable branch. Unfortunately, stable branch is supposed to be used with sepolicy version which generates a list, while master branch is used with version generating a generator. Fixes: File "/usr/lib/python3.8/site-packages/setroubleshoot/audit_data.py", line 737, in __typeMatch _info = info(TYPE, context.type)[0] TypeError: 'generator' object is not subscriptable Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1784564 --- diff --git a/framework/src/setroubleshoot/audit_data.py b/framework/src/setroubleshoot/audit_data.py index 746bc61..66986a7 100644 --- a/framework/src/setroubleshoot/audit_data.py +++ b/framework/src/setroubleshoot/audit_data.py @@ -734,10 +734,10 @@ class AVC: def __typeMatch(self, context, type_list): # get array of context type and it's aliases try: - _info = info(TYPE, context.type)[0] + _info = next(info(TYPE, context.type)) ctypes = _info.get('aliases', []) ctypes.append(_info['name']) - except (RuntimeError, IndexError): + except (RuntimeError, IndexError, StopIteration): ctypes = [context.type] for type in type_list: