mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
Now that we convert salt inside of do_encryptas needed, keep salt as text type until then.
This commit is contained in:
parent
cf0da0948d
commit
6d9f780937
2 changed files with 6 additions and 5 deletions
|
@ -248,8 +248,7 @@ class LookupModule(LookupBase):
|
||||||
_write_password_file(b_path, content)
|
_write_password_file(b_path, content)
|
||||||
|
|
||||||
if params['encrypt']:
|
if params['encrypt']:
|
||||||
password = do_encrypt(plaintext_password, params['encrypt'],
|
password = do_encrypt(plaintext_password, params['encrypt'], salt=salt)
|
||||||
salt=to_bytes(salt, encoding='ascii', errors='strict'))
|
|
||||||
ret.append(password)
|
ret.append(password)
|
||||||
else:
|
else:
|
||||||
ret.append(plaintext_password)
|
ret.append(plaintext_password)
|
||||||
|
|
|
@ -67,7 +67,7 @@ except ImportError:
|
||||||
|
|
||||||
from ansible import constants as C
|
from ansible import constants as C
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError
|
||||||
from ansible.module_utils._text import to_text, to_native
|
from ansible.module_utils._text import to_text, to_bytes
|
||||||
|
|
||||||
__all__ = ['do_encrypt']
|
__all__ = ['do_encrypt']
|
||||||
|
|
||||||
|
@ -84,8 +84,10 @@ def do_encrypt(result, encrypt, salt_size=None, salt=None):
|
||||||
if salt_size:
|
if salt_size:
|
||||||
result = crypt.encrypt(result, salt_size=salt_size)
|
result = crypt.encrypt(result, salt_size=salt_size)
|
||||||
elif salt:
|
elif salt:
|
||||||
if not crypt._salt_is_bytes:
|
if crypt._salt_is_bytes:
|
||||||
salt = to_native(salt)
|
salt = to_bytes(salt, encoding='ascii', errors='strict')
|
||||||
|
else:
|
||||||
|
salt = to_text(salt, encoding='ascii', errors='strict')
|
||||||
result = crypt.encrypt(result, salt=salt)
|
result = crypt.encrypt(result, salt=salt)
|
||||||
else:
|
else:
|
||||||
result = crypt.encrypt(result)
|
result = crypt.encrypt(result)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue