diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-12-01 10:45:29 -0500 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-12-01 10:45:29 -0500 |
commit | 1565a3b0017b3a97086278c539256bfd14c50943 (patch) | |
tree | 0cb02b94964630b9d8726258b471ea5dc389c8ee | |
parent | 38a8de5510da52765cf81348a1137d91b42d3088 (diff) | |
download | b4-1565a3b0017b3a97086278c539256bfd14c50943.tar.gz |
Fix crash when dnspython is not available
If we don't have dnspython, then we don't have _resolver. Make sure it
exists and check if it's not None before looking for hasattr.
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r-- | b4/__init__.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/b4/__init__.py b/b4/__init__.py index b10b3e1..7cffe47 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -36,6 +36,7 @@ try: _resolver = dns.resolver.get_default_resolver() except ModuleNotFoundError: can_dkim_verify = False + _resolver = None __VERSION__ = '0.6.0-dev' @@ -1698,7 +1699,7 @@ class LoreAttestationSignatureDKIM(LoreAttestationSignature): ddata = get_parts_from_header(dks) self.attestor = LoreAttestorDKIM(ddata['d']) # Do we have a resolve method? - if hasattr(_resolver, 'resolve'): + if _resolver and hasattr(_resolver, 'resolve'): res = dkim.verify(self.msg.as_bytes(), dnsfunc=dkim_get_txt) else: res = dkim.verify(self.msg.as_bytes()) |