basic.py: catch ValueError when trying to import hash algorithms (#44551)
* basic.py: catch more Exceptions when trying to import md5 hash algorithms
This commit is contained in:
parent
c8ee383783
commit
e07352b9de
2 changed files with 10 additions and 2 deletions
2
changelogs/fragments/fips_md5_import.yaml
Normal file
2
changelogs/fragments/fips_md5_import.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- basic.py - catch ValueError in case a FIPS enabled platform raises this exception - https://github.com/ansible/ansible/issues/44447
|
|
@ -132,13 +132,19 @@ try:
|
|||
algorithms = ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512')
|
||||
for algorithm in algorithms:
|
||||
AVAILABLE_HASH_ALGORITHMS[algorithm] = getattr(hashlib, algorithm)
|
||||
except ImportError:
|
||||
|
||||
# we may have been able to import md5 but it could still not be available
|
||||
try:
|
||||
hashlib.md5()
|
||||
except ValueError:
|
||||
algorithms.pop('md5', None)
|
||||
except Exception:
|
||||
import sha
|
||||
AVAILABLE_HASH_ALGORITHMS = {'sha1': sha.sha}
|
||||
try:
|
||||
import md5
|
||||
AVAILABLE_HASH_ALGORITHMS['md5'] = md5.md5
|
||||
except ImportError:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
from ansible.module_utils.common._collections_compat import (
|
||||
|
|
Loading…
Reference in a new issue