diff --git a/changelogs/fragments/debug_ldap_client-failure.yml b/changelogs/fragments/debug_ldap_client-failure.yml new file mode 100644 index 0000000..e4855b8 --- /dev/null +++ b/changelogs/fragments/debug_ldap_client-failure.yml @@ -0,0 +1,2 @@ +bugfixes: +- debug_ldap_client - handle failures when attempting to get the krb5 context and default CCache rather than fail with a traceback diff --git a/plugins/action/debug_ldap_client.py b/plugins/action/debug_ldap_client.py index a33f21d..fbe990f 100644 --- a/plugins/action/debug_ldap_client.py +++ b/plugins/action/debug_ldap_client.py @@ -52,7 +52,9 @@ def run( "dns": dns_info, "kerberos": kerb_info, "packages": { - "dnspython": self._import_lib("dns.resolver", package_name="dnspython"), + "dnspython": self._import_lib( + "dns.resolver", package_name="dnspython" + ), "dpapi_ng": self._import_lib("dpapi_ng", package_name="dpapi-ng"), "krb5": self._import_lib("krb5"), "pyspnego": self._import_lib("spnego", package_name="pyspnego"), @@ -77,8 +79,6 @@ def _get_kerberos_info(self) -> t.Dict[str, t.Any]: ctx = krb5.init_context() except Exception: res["exception"] = traceback.format_exc() - - if not ctx: return res try: @@ -106,8 +106,6 @@ def _get_kerberos_cc_info( default_cc = krb5.cc_default(ctx) except Exception: res["exception"] = traceback.format_exc() - - if not default_cc: return res try: @@ -154,7 +152,9 @@ def _get_server_lookup_info( } ) - highest_record = next(iter(sorted(records, key=lambda k: (k["priority"], -k["weight"]))), None) + highest_record = next( + iter(sorted(records, key=lambda k: (k["priority"], -k["weight"]))), None + ) if highest_record: res["default_server"] = highest_record["target"].rstrip(".") res["default_port"] = highest_record["port"]