mirror of
https://github.com/SELinuxProject/selinux
synced 2025-03-31 07:56:22 +00:00
python/sepolicy/sepolicy: optimise sepolicy gui loading
Significantly speed up sepolicy gui loading by aggregating setools queries. Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
This commit is contained in:
parent
ef387e88bd
commit
8fe1b0ca27
@ -663,6 +663,23 @@ def get_init_entrypoint(transtype):
|
||||
|
||||
return entrypoints
|
||||
|
||||
def get_init_entrypoints_str():
|
||||
q = setools.TERuleQuery(_pol,
|
||||
ruletype=["type_transition"],
|
||||
source="init_t",
|
||||
tclass=["process"])
|
||||
entrypoints = {}
|
||||
for i in q.results():
|
||||
try:
|
||||
transtype = str(i.default)
|
||||
if transtype in entrypoints:
|
||||
entrypoints[transtype].append(str(i.target))
|
||||
else:
|
||||
entrypoints[transtype] = [str(i.target)]
|
||||
except AttributeError:
|
||||
continue
|
||||
|
||||
return entrypoints
|
||||
|
||||
def get_init_entrypoint_target(entrypoint):
|
||||
try:
|
||||
|
@ -499,6 +499,8 @@ class SELinuxGui():
|
||||
|
||||
loading_gui.show()
|
||||
length = len(self.all_domains)
|
||||
|
||||
entrypoint_dict = sepolicy.get_init_entrypoints_str()
|
||||
for domain in self.all_domains:
|
||||
# After the user selects a path in the drop down menu call
|
||||
# get_init_entrypoint_target(entrypoint) to get the transtype
|
||||
@ -509,8 +511,7 @@ class SELinuxGui():
|
||||
self.progress_bar.set_pulse_step(self.percentage)
|
||||
self.idle_func()
|
||||
|
||||
entrypoints = [str(x) for x in sepolicy.get_init_entrypoint(domain)]
|
||||
for entrypoint in entrypoints:
|
||||
for entrypoint in entrypoint_dict.get(domain, []):
|
||||
path = sepolicy.find_entrypoint_path(entrypoint)
|
||||
if path:
|
||||
self.combo_box_add(path, domain)
|
||||
|
Loading…
Reference in New Issue
Block a user