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

Catch pycrypto warning about gmp and show a nice warning on stderr

This commit is contained in:
James Cammarata 2014-04-29 14:27:51 -05:00
parent dcd471b96f
commit 4cadcccc48

View file

@ -44,6 +44,7 @@ import getpass
import sys import sys
import textwrap import textwrap
import json import json
import warnings
#import vault #import vault
from vault import VaultLib from vault import VaultLib
@ -75,6 +76,17 @@ except:
KEYCZAR_AVAILABLE=False KEYCZAR_AVAILABLE=False
try: try:
from Crypto.pct_warnings import PowmInsecureWarning
with warnings.catch_warnings(record=True) as warning_handler:
warnings.simplefilter("error", PowmInsecureWarning)
try:
import keyczar.errors as key_errors
from keyczar.keys import AesKey
except PowmInsecureWarning:
display("The version of gmp you have installed has a known issue regarding timing vulnerabilities when used with pycrypto. " + \
"If possible, you should update it (ie. yum update gmp).", color="purple", stderr=True)
warnings.resetwarnings()
warnings.simplefilter("ignore")
import keyczar.errors as key_errors import keyczar.errors as key_errors
from keyczar.keys import AesKey from keyczar.keys import AesKey
KEYCZAR_AVAILABLE=True KEYCZAR_AVAILABLE=True