selinux: check if policy exists before switching (#31834)

* selinux: check if policy exists before switching

* Check the policy dir
This commit is contained in:
Martin Krizek 2017-11-28 17:09:25 +01:00 committed by Sam Doran
parent 452028ab7d
commit 0592fd47bc
2 changed files with 40 additions and 0 deletions

View file

@ -151,6 +151,9 @@ def set_state(module, state):
def set_config_policy(module, policy, configfile):
if not os.path.exists('/etc/selinux/%s/policy' % policy):
module.fail_json(msg='Policy %s does not exist in /etc/selinux/' % policy)
# edit config file with state value
# SELINUXTYPE=targeted
policyline = 'SELINUXTYPE=%s' % policy