From 93a63babd44e8fc7652b4e6c3c078133f234310f Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Tue, 18 Jan 2022 15:59:09 +0100 Subject: [PATCH] Look for modules in /usr/share/selinux/packages Not all packages shipping SELinux modules own their directory in /var/lib/selinux/... Some of them own just .pp.bz2 file in /usr/share/selinux/packages. Lets look there when we try to detect the right component for the report. --- src/setroubleshoot/util.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/setroubleshoot/util.py b/src/setroubleshoot/util.py index de10c7319138..1405bb84c342 100755 --- a/src/setroubleshoot/util.py +++ b/src/setroubleshoot/util.py @@ -430,6 +430,9 @@ Finds an SELinux module which defines given SELinux type >>> get_rpm_nvr_by_type("mysqld_log_t")[0:13] 'mysql-selinux' +>>> get_rpm_nvr_by_type("spc_t")[0:17] +'container-selinux' + """ if module_type_cache is None: @@ -439,7 +442,22 @@ Finds an SELinux module which defines given SELinux type path = module_type_cache.get(selinux_type, None) - return get_package_nvr_by_file_path(path) + if path is None: + return None + + package = get_package_nvr_by_file_path(path) + + if package is None: + module_name = path.split('/')[-1] + path = '/usr/share/selinux/packages/' + module_name + '.pp' + package = get_package_nvr_by_file_path(path) + if package is None: + path += '.bz2' + package = get_package_nvr_by_file_path(path) + + return package + + # check if given string represents an integer def __str_is_int(str): -- 2.34.1