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:
parent
644362d0be
commit
23a6b88dd2
3 changed files with 4 additions and 7 deletions
|
@ -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)
|
|
2
changelogs/fragments/md5-hash-algorithms-pop-fix.yaml
Normal file
2
changelogs/fragments/md5-hash-algorithms-pop-fix.yaml
Normal 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)
|
|
@ -129,12 +129,10 @@ try:
|
||||||
for attribute in ('available_algorithms', 'algorithms'):
|
for attribute in ('available_algorithms', 'algorithms'):
|
||||||
algorithms = getattr(hashlib, attribute, None)
|
algorithms = getattr(hashlib, attribute, None)
|
||||||
if algorithms:
|
if algorithms:
|
||||||
# convert algorithms to list instead of immutable tuple so md5 can be removed if not available
|
|
||||||
algorithms = list(algorithms)
|
|
||||||
break
|
break
|
||||||
if algorithms is None:
|
if algorithms is None:
|
||||||
# python 2.5+
|
# python 2.5+
|
||||||
algorithms = ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512']
|
algorithms = ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512')
|
||||||
for algorithm in algorithms:
|
for algorithm in algorithms:
|
||||||
AVAILABLE_HASH_ALGORITHMS[algorithm] = getattr(hashlib, algorithm)
|
AVAILABLE_HASH_ALGORITHMS[algorithm] = getattr(hashlib, algorithm)
|
||||||
|
|
||||||
|
@ -142,7 +140,7 @@ try:
|
||||||
try:
|
try:
|
||||||
hashlib.md5()
|
hashlib.md5()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
algorithms.remove('md5')
|
AVAILABLE_HASH_ALGORITHMS.pop('md5', None)
|
||||||
except Exception:
|
except Exception:
|
||||||
import sha
|
import sha
|
||||||
AVAILABLE_HASH_ALGORITHMS = {'sha1': sha.sha}
|
AVAILABLE_HASH_ALGORITHMS = {'sha1': sha.sha}
|
||||||
|
|
Loading…
Reference in a new issue