1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Modify the correct variable when setting available hashing algorithms (#52994)

* Revert "use list instead of tuple and remove md5 on ValueError (#51357)" c459f040da.
* Modify the correct variable when determining available hashing algorithms
This commit is contained in:
Sam Doran 2019-02-28 07:32:00 -05:00 committed by GitHub
parent 644362d0be
commit 23a6b88dd2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 7 deletions

View file

@ -1,3 +0,0 @@
---
bugfixes:
- ansible.module_utils.basic - fix handling of md5 in algorithms tuple for FIPS compatibility (https://github.com/ansible/ansible/issues/51355)

View file

@ -0,0 +1,2 @@
bugfixes:
- basic - modify the correct variable when determining available hashing algorithms to avoid errors when md5 is not available (https://github.com/ansible/ansible/issues/51355)

View file

@ -129,12 +129,10 @@ try:
for attribute in ('available_algorithms', 'algorithms'):
algorithms = getattr(hashlib, attribute, None)
if algorithms:
# convert algorithms to list instead of immutable tuple so md5 can be removed if not available
algorithms = list(algorithms)
break
if algorithms is None:
# python 2.5+
algorithms = ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512']
algorithms = ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512')
for algorithm in algorithms:
AVAILABLE_HASH_ALGORITHMS[algorithm] = getattr(hashlib, algorithm)
@ -142,7 +140,7 @@ try:
try:
hashlib.md5()
except ValueError:
algorithms.remove('md5')
AVAILABLE_HASH_ALGORITHMS.pop('md5', None)
except Exception:
import sha
AVAILABLE_HASH_ALGORITHMS = {'sha1': sha.sha}