diff options
author | Matt Robinson <git@nerdoftheherd.com> | 2016-10-18 19:50:45 +0100 |
---|---|---|
committer | Michael Scherer <mscherer@users.noreply.github.com> | 2016-10-23 01:46:05 +0200 |
commit | 692bfa872a0f90de08fa4852963d5ad1998bc79b (patch) | |
tree | 01467d7cc5e6d344546332d73507461453af19f9 /lib/ansible/plugins/filter | |
parent | 843de98bad5f9ff67b2ba8b20a96770f19c22188 (diff) | |
download | ansible-692bfa872a0f90de08fa4852963d5ad1998bc79b.tar.gz |
Make bcrypt + passlib work in password_hash filter
If hashtype for the password_hash filter is 'blowfish' and passlib is
available, hashing fails as the hash function for this is named 'bcrypt'
(and not 'blowfish_crypt'). Special case this so that the correct
function is called.
Diffstat (limited to 'lib/ansible/plugins/filter')
-rw-r--r-- | lib/ansible/plugins/filter/core.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/ansible/plugins/filter/core.py b/lib/ansible/plugins/filter/core.py index 276a95dd16..81463ce0e3 100644 --- a/lib/ansible/plugins/filter/core.py +++ b/lib/ansible/plugins/filter/core.py @@ -257,7 +257,11 @@ def get_encrypted_password(password, hashtype='sha512', salt=None): saltstring = "$%s$%s" % (cryptmethod[hashtype],salt) encrypted = crypt.crypt(password, saltstring) else: - cls = getattr(passlib.hash, '%s_crypt' % hashtype) + if hashtype == 'blowfish': + cls = passlib.hash.bcrypt; + else: + cls = getattr(passlib.hash, '%s_crypt' % hashtype) + encrypted = cls.encrypt(password, salt=salt) return encrypted |