Port seboolean to py3/py2.4 syntax (#3679)
This commit is contained in:
parent
c793571bc3
commit
cca89ef489
1 changed files with 5 additions and 4 deletions
|
@ -69,7 +69,7 @@ def has_boolean_value(module, name):
|
||||||
bools = []
|
bools = []
|
||||||
try:
|
try:
|
||||||
rc, bools = selinux.security_get_boolean_names()
|
rc, bools = selinux.security_get_boolean_names()
|
||||||
except OSError, e:
|
except OSError:
|
||||||
module.fail_json(msg="Failed to get list of boolean names")
|
module.fail_json(msg="Failed to get list of boolean names")
|
||||||
if name in bools:
|
if name in bools:
|
||||||
return True
|
return True
|
||||||
|
@ -80,7 +80,7 @@ def get_boolean_value(module, name):
|
||||||
state = 0
|
state = 0
|
||||||
try:
|
try:
|
||||||
state = selinux.security_get_boolean_active(name)
|
state = selinux.security_get_boolean_active(name)
|
||||||
except OSError, e:
|
except OSError:
|
||||||
module.fail_json(msg="Failed to determine current state for boolean %s" % name)
|
module.fail_json(msg="Failed to determine current state for boolean %s" % name)
|
||||||
if state == 1:
|
if state == 1:
|
||||||
return True
|
return True
|
||||||
|
@ -138,7 +138,8 @@ def semanage_boolean_value(module, name, state):
|
||||||
|
|
||||||
semanage.semanage_disconnect(handle)
|
semanage.semanage_disconnect(handle)
|
||||||
semanage.semanage_handle_destroy(handle)
|
semanage.semanage_handle_destroy(handle)
|
||||||
except Exception, e:
|
except Exception:
|
||||||
|
e = get_exception()
|
||||||
module.fail_json(msg="Failed to manage policy for boolean %s: %s" % (name, str(e)))
|
module.fail_json(msg="Failed to manage policy for boolean %s: %s" % (name, str(e)))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -149,7 +150,7 @@ def set_boolean_value(module, name, state):
|
||||||
value = 1
|
value = 1
|
||||||
try:
|
try:
|
||||||
rc = selinux.security_set_boolean(name, value)
|
rc = selinux.security_set_boolean(name, value)
|
||||||
except OSError, e:
|
except OSError:
|
||||||
module.fail_json(msg="Failed to set boolean %s to %s" % (name, value))
|
module.fail_json(msg="Failed to set boolean %s to %s" % (name, value))
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in a new issue