policycoreutils-3.5-0.rc2.2
- python/sepolicy: Cache conditional rule queries Related: rhbz#2145229
This commit is contained in:
parent
a2173eef83
commit
e634de4b77
74
0009-python-sepolicy-Cache-conditional-rule-queries.patch
Normal file
74
0009-python-sepolicy-Cache-conditional-rule-queries.patch
Normal file
@ -0,0 +1,74 @@
|
||||
From 38a0c330a652af92d66ee5f77e6c797a631ff07e Mon Sep 17 00:00:00 2001
|
||||
From: Vit Mojzis <vmojzis@redhat.com>
|
||||
Date: Tue, 24 Jan 2023 21:05:05 +0100
|
||||
Subject: [PATCH] python/sepolicy: Cache conditional rule queries
|
||||
Content-type: text/plain
|
||||
|
||||
Commit 7506771e4b630fe0ab853f96574e039055cb72eb
|
||||
"add missing booleans to man pages" dramatically slowed down
|
||||
"sepolicy manpage -a" by removing caching of setools rule query.
|
||||
Re-add said caching and update the query to only return conditional
|
||||
rules.
|
||||
|
||||
Before commit 7506771e:
|
||||
#time sepolicy manpage -a
|
||||
real 1m43.153s
|
||||
# time sepolicy manpage -d httpd_t
|
||||
real 0m4.493s
|
||||
|
||||
After commit 7506771e:
|
||||
#time sepolicy manpage -a
|
||||
real 1h56m43.153s
|
||||
# time sepolicy manpage -d httpd_t
|
||||
real 0m8.352s
|
||||
|
||||
After this commit:
|
||||
#time sepolicy manpage -a
|
||||
real 1m41.074s
|
||||
# time sepolicy manpage -d httpd_t
|
||||
real 0m7.358s
|
||||
|
||||
Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
|
||||
---
|
||||
python/sepolicy/sepolicy/__init__.py | 11 ++++++++++-
|
||||
1 file changed, 10 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/python/sepolicy/sepolicy/__init__.py b/python/sepolicy/sepolicy/__init__.py
|
||||
index e2d5c11a0ca9..c177cdfc529d 100644
|
||||
--- a/python/sepolicy/sepolicy/__init__.py
|
||||
+++ b/python/sepolicy/sepolicy/__init__.py
|
||||
@@ -125,6 +125,7 @@ all_attributes = None
|
||||
booleans = None
|
||||
booleans_dict = None
|
||||
all_allow_rules = None
|
||||
+all_bool_rules = None
|
||||
all_transitions = None
|
||||
|
||||
|
||||
@@ -1136,6 +1137,14 @@ def get_all_allow_rules():
|
||||
all_allow_rules = search([ALLOW])
|
||||
return all_allow_rules
|
||||
|
||||
+def get_all_bool_rules():
|
||||
+ global all_bool_rules
|
||||
+ if not all_bool_rules:
|
||||
+ q = TERuleQuery(_pol, boolean=".*", boolean_regex=True,
|
||||
+ ruletype=[ALLOW, DONTAUDIT])
|
||||
+ all_bool_rules = [_setools_rule_to_dict(x) for x in q.results()]
|
||||
+ return all_bool_rules
|
||||
+
|
||||
def get_all_transitions():
|
||||
global all_transitions
|
||||
if not all_transitions:
|
||||
@@ -1146,7 +1155,7 @@ def get_bools(setype):
|
||||
bools = []
|
||||
domainbools = []
|
||||
domainname, short_name = gen_short_name(setype)
|
||||
- for i in map(lambda x: x['booleans'], filter(lambda x: 'booleans' in x and x['source'] == setype, search([ALLOW, DONTAUDIT]))):
|
||||
+ for i in map(lambda x: x['booleans'], filter(lambda x: 'booleans' in x and x['source'] == setype, get_all_bool_rules())):
|
||||
for b in i:
|
||||
if not isinstance(b, tuple):
|
||||
continue
|
||||
--
|
||||
2.39.1
|
||||
|
@ -11,7 +11,7 @@
|
||||
Summary: SELinux policy core utilities
|
||||
Name: policycoreutils
|
||||
Version: 3.5
|
||||
Release: 0.rc2.1%{?dist}
|
||||
Release: 0.rc2.2%{?dist}
|
||||
License: GPLv2
|
||||
# https://github.com/SELinuxProject/selinux/wiki/Releases
|
||||
Source0: https://github.com/SELinuxProject/selinux/releases/download/3.5-rc2/selinux-3.5-rc2.tar.gz
|
||||
@ -39,6 +39,7 @@ Patch0005: 0005-sepolicy-generate-Handle-more-reserved-port-types.patch
|
||||
Patch0006: 0006-sandbox-Use-matchbox-window-manager-instead-of-openb.patch
|
||||
Patch0007: 0007-Use-SHA-2-instead-of-SHA-1.patch
|
||||
Patch0008: 0008-sepolicy-Drop-old-interface-file_type_is_executable-.patch
|
||||
Patch0009: 0009-python-sepolicy-Cache-conditional-rule-queries.patch
|
||||
# Patch list end
|
||||
Obsoletes: policycoreutils < 2.0.61-2
|
||||
Conflicts: filesystem < 3, selinux-policy-base < 3.13.1-138
|
||||
@ -444,6 +445,9 @@ The policycoreutils-restorecond package contains the restorecond service.
|
||||
%systemd_postun_with_restart restorecond.service
|
||||
|
||||
%changelog
|
||||
* Thu Jan 26 2023 Vit Mojzis <vmojzis@redhat.com> - 3.5-0.rc2.2
|
||||
- python/sepolicy: Cache conditional rule queries
|
||||
|
||||
* Tue Jan 17 2023 Petr Lautrbach <lautrbach@redhat.com> - 3.5-0.rc2.1
|
||||
- SELinux userspace 3.5-rc2 release
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user