ldap_attr: Use byte values instead of str (#41248)

The LDAP values may be of any kind (pictures, bytes, etc.) thus, ldap module enforce a "bytes" type.
We should pass properly encoded values instead of str

Fixes: #39569

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2018-06-08 07:34:49 +05:30 committed by GitHub
parent effa235eb6
commit e3a073fdb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -152,7 +152,7 @@ modlist:
import traceback
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils._text import to_native
from ansible.module_utils._text import to_native, to_bytes
from ansible.module_utils.ldap import LdapGeneric, gen_specs
try:
@ -173,9 +173,9 @@ class LdapAttr(LdapGeneric):
# Normalize values
if isinstance(self.module.params['values'], list):
self.values = map(str, self.module.params['values'])
self.values = map(to_bytes, self.module.params['values'])
else:
self.values = [str(self.module.params['values'])]
self.values = [to_bytes(self.module.params['values'])]
def add(self):
values_to_add = filter(self._is_value_absent, self.values)