diff options
author | Michael Scherer <misc@redhat.com> | 2016-10-14 02:11:25 +0200 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2016-10-15 08:16:07 -0700 |
commit | 4d45ed1d36070d9659afc034ab0f30c21c0c5e62 (patch) | |
tree | eb2d5a6b29ddca97379b6a7bb8794a63c67d3424 | |
parent | 34d61418abee4ebf8083e7a5a53a3679c222ca71 (diff) | |
download | ansible-modules-core-4d45ed1d36070d9659afc034ab0f30c21c0c5e62.tar.gz |
Convert name to bytes to compare it to bools
On python 3, bools is a list of bytes:
>>> rc,bools = selinux.security_get_boolean_names()
>>> 'virt_use_nfs' in bools
False
>>> bools
[b'abrt_anon_write', b'abrt_handle_event', ...]
(cherry picked from commit a35b77a10c8b5e6cf380c01607fbef9d71702d9f)
-rw-r--r-- | system/seboolean.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/system/seboolean.py b/system/seboolean.py index 1fc9ac25..4581c133 100644 --- a/system/seboolean.py +++ b/system/seboolean.py @@ -71,7 +71,7 @@ def has_boolean_value(module, name): rc, bools = selinux.security_get_boolean_names() except OSError: module.fail_json(msg="Failed to get list of boolean names") - if name in bools: + if to_bytes(name) in bools: return True else: return False @@ -215,4 +215,5 @@ def main(): # import module snippets from ansible.module_utils.basic import * +from ansible.module_utils._text import to_bytes main() |