From c14eece0c6cd77e9fcdb6206b05de021dac0847a Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 14 Jan 2016 10:24:34 -0500 Subject: [PATCH] md5 now uses smaller salt fixes #13891 --- lib/ansible/plugins/filter/core.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/filter/core.py b/lib/ansible/plugins/filter/core.py index dc9acb4d09..fed5097d91 100644 --- a/lib/ansible/plugins/filter/core.py +++ b/lib/ansible/plugins/filter/core.py @@ -225,7 +225,11 @@ def get_encrypted_password(password, hashtype='sha512', salt=None): if hashtype in cryptmethod: if salt is None: r = SystemRandom() - salt = ''.join([r.choice(string.ascii_letters + string.digits) for _ in range(16)]) + if hashtype in ['md5']: + saltsize = 8 + else: + saltsize = 16 + salt = ''.join([r.choice(string.ascii_letters + string.digits) for _ in range(saltsize)]) if not HAS_PASSLIB: if sys.platform.startswith('darwin'):