mirror of
https://github.com/SELinuxProject/setools
synced 2025-02-18 21:17:08 +00:00
Restructure TERule __str__
Eliminate instance check and try common case of getting perms; catch exception for type_* rules case.
This commit is contained in:
parent
3cdb59cdd0
commit
de06014e0f
@ -55,23 +55,23 @@ class TERule(rule.PolicyRule):
|
||||
rule_string = "{0.ruletype} {0.source} {0.target}:{0.tclass} ".format(
|
||||
self)
|
||||
|
||||
if isinstance(self.qpol_symbol, qpol.qpol_avrule_t):
|
||||
try:
|
||||
perms = self.perms
|
||||
except rule.InvalidRuleUse:
|
||||
# type_* rules
|
||||
rule_string += str(self.default)
|
||||
|
||||
try:
|
||||
rule_string += " \"{0}\";".format(self.filename)
|
||||
except TERuleNoFilename:
|
||||
rule_string += ";"
|
||||
else:
|
||||
# allow/dontaudit/auditallow/neverallow rules
|
||||
if len(perms) > 1:
|
||||
rule_string += "{{ {0} }};".format(string.join(perms))
|
||||
else:
|
||||
# convert to list since sets cannot be indexed
|
||||
rule_string += "{0};".format(list(perms)[0])
|
||||
else:
|
||||
rule_string += str(self.default)
|
||||
|
||||
try:
|
||||
rule_string += " \"{0}\"".format(self.filename)
|
||||
except TERuleNoFilename:
|
||||
pass
|
||||
|
||||
rule_string += ";"
|
||||
|
||||
try:
|
||||
cond = self.conditional
|
||||
|
Loading…
Reference in New Issue
Block a user