From 8e0f662210754533b3be2f30622bac943bdc7398 Mon Sep 17 00:00:00 2001 From: Jakub Vavra Date: Wed, 6 Sep 2023 08:55:40 +0200 Subject: [PATCH] Tests: Handle dns with systemd resolved. --- src/tests/multihost/sssd/testlib/common/utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/tests/multihost/sssd/testlib/common/utils.py b/src/tests/multihost/sssd/testlib/common/utils.py index 534e85b831e..5816270f553 100644 --- a/src/tests/multihost/sssd/testlib/common/utils.py +++ b/src/tests/multihost/sssd/testlib/common/utils.py @@ -153,6 +153,12 @@ def update_resolv_conf(self, ip_addr): self.multihost.run_command("chattr -i /etc/resolv.conf", raiseonerr=False) self.multihost.put_file_contents('/etc/resolv.conf', contents) self.multihost.run_command("chattr +i /etc/resolv.conf", raiseonerr=False) + # Try to change dns settings on a machine with systemd.resolved + change_stub = f"sed -ie 's/#\?DNS=.*/DNS={ip_addr}/' /etc/systemd/resolved.conf" + self.multihost.run_command(change_stub, raiseonerr=False) + self.multihost.run_command( + "systemctl restart systemd-resolved", raiseonerr=False + ) def update_etc_hosts(self, ip_addr, hostname): """ Update /etc/hosts with ipaddress and hostname @@ -402,7 +408,6 @@ def realm_join(self, domainname, admin_password, f'--server-software={server_software} ' \ f'--membership-software={membership_software} -v' print(realm_cmd) - self.multihost.run_command("cat /etc/krb5.conf", raiseonerr=False) cmd = self.multihost.run_command(realm_cmd, stdin_text=admin_password, raiseonerr=False) if cmd.returncode == 124: @@ -412,6 +417,8 @@ def realm_join(self, domainname, admin_password, self.service_ctrl('stop', 'realmd') raise SSSDException(f"realm join timed out! {cmd.stderr_text}") elif cmd.returncode != 0: + self.multihost.run_command("cat /etc/krb5.conf", raiseonerr=False) + self.multihost.run_command("resolvectl dns", raiseonerr=False) raise SSSDException("Error: %s" % cmd.stderr_text) else: return cmd.stderr_text