From 884e0d36e9f655d0456229d0e259592e65714660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= Date: Thu, 24 Sep 2020 22:15:13 +0200 Subject: [PATCH] ipatests: add get_kdcinfo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit get_kdcinfo(host) retrieves /var/lib/sss/pubconf/kdcinfo.$REALM on host. It also logs whether SSSD considers the IPA domain as Online or not before and after retrieving the file. Related: https://pagure.io/freeipa/issue/8510 Signed-off-by: François Cami Reviewed-By: Florence Blanc-Renaud --- ipatests/pytest_ipa/integration/tasks.py | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/ipatests/pytest_ipa/integration/tasks.py b/ipatests/pytest_ipa/integration/tasks.py index 2c151879d..c41e59269 100755 --- a/ipatests/pytest_ipa/integration/tasks.py +++ b/ipatests/pytest_ipa/integration/tasks.py @@ -2011,6 +2011,42 @@ def kinit_as_user(host, user, password, krb5_trace=False): host.run_command(['kinit', user], stdin_text='{0}\n'.format(password)) +def get_kdcinfo(host): + """Retrieve /var/lib/sss/pubconf/kdcinfo.$REALM on host. + That file contains the IP of the KDC SSSD should be pinned to. + """ + logger.info( + 'Collecting kdcinfo log from: %s', host.hostname + ) + if check_if_sssd_is_online(host): + logger.info("SSSD considers domain %s online.", host.domain.realm) + else: + logger.warning( + "SSSD considers domain %s offline.", host.domain.realm + ) + kdcinfo = None + try: + kdcinfo = host.get_file_contents( + "/var/lib/sss/pubconf/kdcinfo.{}".format(host.domain.realm) + ) + logger.info( + 'kdcinfo %s contains:\n%s', host.hostname, kdcinfo + ) + if check_if_sssd_is_online(host) is False: + logger.warning( + "SSSD still considers domain %s offline.", + host.domain.realm + ) + except (OSError, IOError) as e: + logger.warning( + "Exception collecting kdcinfo.%s: %s\n" + "SSSD is able to function without this file but logon " + "attempts immediately after a password change might break.", + host.domain.realm, e + ) + return kdcinfo + + KeyEntry = collections.namedtuple('KeyEntry', ['kvno', 'principal', 'etype', 'key'])