python/semanage: import sepolicy only when it's needed
Related: https://github.com/SELinuxProject/selinux/issues/81 Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
This commit is contained in:
parent
a73b0bba1a
commit
e718c2ab77
1 changed files with 6 additions and 2 deletions
|
@ -73,7 +73,7 @@ usage_interface_dict = {' --add': ('-t TYPE', '-r RANGE', 'interface'), ' --modi
|
|||
usage_boolean = "semanage boolean [-h] [-n] [-N] [-S STORE] ["
|
||||
usage_boolean_dict = {' --modify': ('(', '--on', '|', '--off', ')', 'boolean'), ' --list': ('-C',), ' --extract': ('',), ' --deleteall': ('',)}
|
||||
|
||||
import sepolicy
|
||||
|
||||
|
||||
|
||||
class CheckRole(argparse.Action):
|
||||
|
@ -82,7 +82,11 @@ class CheckRole(argparse.Action):
|
|||
newval = getattr(namespace, self.dest)
|
||||
if not newval:
|
||||
newval = []
|
||||
roles = sepolicy.get_all_roles()
|
||||
try:
|
||||
import sepolicy
|
||||
roles = sepolicy.get_all_roles()
|
||||
except ValueError:
|
||||
roles = []
|
||||
for v in value.split():
|
||||
if v not in roles:
|
||||
raise ValueError("%s must be an SELinux role:\nValid roles: %s" % (v, ", ".join(roles)))
|
||||
|
|
Loading…
Reference in a new issue