ccffd0
From b590dcef10680b4ea3181ae1caec183e5967562b Mon Sep 17 00:00:00 2001
ccffd0
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
ccffd0
Date: Fri, 11 Dec 2020 07:35:59 +0200
ccffd0
Subject: [PATCH] ipatests: add TestInstallWithoutSudo
ccffd0
MIME-Version: 1.0
ccffd0
Content-Type: text/plain; charset=UTF-8
ccffd0
Content-Transfer-Encoding: 8bit
ccffd0
ccffd0
Test IPA servers and clients behavior when sudo is not installed.
ccffd0
ccffd0
Fixes: https://pagure.io/freeipa/issue/8530
ccffd0
Signed-off-by: François Cami <fcami@redhat.com>
ccffd0
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
ccffd0
Reviewed-By: Armando Neto <abiagion@redhat.com>
ccffd0
Reviewed-By: Michal Polovka <mpolovka@redhat.com>
ccffd0
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
ccffd0
Reviewed-By: Armando Neto <abiagion@redhat.com>
ccffd0
Reviewed-By: Michal Polovka <mpolovka@redhat.com>
ccffd0
Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
ccffd0
---
ccffd0
 .../nightly_ipa-4-9_latest.yaml               | 12 ++++
ccffd0
 .../nightly_ipa-4-9_latest_selinux.yaml       | 13 ++++
ccffd0
 .../nightly_ipa-4-9_previous.yaml             | 12 ++++
ccffd0
 .../test_integration/test_installation.py     | 66 +++++++++++++++++++
ccffd0
 4 files changed, 103 insertions(+)
ccffd0
ccffd0
diff --git a/ipatests/prci_definitions/nightly_ipa-4-9_latest.yaml b/ipatests/prci_definitions/nightly_ipa-4-9_latest.yaml
ccffd0
index 3acd6a13c..d91b16cab 100644
ccffd0
--- a/ipatests/prci_definitions/nightly_ipa-4-9_latest.yaml
ccffd0
+++ b/ipatests/prci_definitions/nightly_ipa-4-9_latest.yaml
ccffd0
@@ -535,6 +535,18 @@ jobs:
ccffd0
         timeout: 10800
ccffd0
         topology: *master_1repl
ccffd0
 
ccffd0
+  fedora-latest-ipa-4-9/test_installation_TestInstallWithoutSudo:
ccffd0
+    requires: [fedora-latest-ipa-4-9/build]
ccffd0
+    priority: 50
ccffd0
+    job:
ccffd0
+      class: RunPytest
ccffd0
+      args:
ccffd0
+        build_url: '{fedora-latest-ipa-4-9/build_url}'
ccffd0
+        test_suite: test_integration/test_installation.py::TestInstallWithoutSudo
ccffd0
+        template: *ci-ipa-4-9-latest
ccffd0
+        timeout: 4800
ccffd0
+        topology: *master_1repl_1client
ccffd0
+
ccffd0
   fedora-latest-ipa-4-9/test_idviews:
ccffd0
     requires: [fedora-latest-ipa-4-9/build]
ccffd0
     priority: 50
ccffd0
diff --git a/ipatests/prci_definitions/nightly_ipa-4-9_latest_selinux.yaml b/ipatests/prci_definitions/nightly_ipa-4-9_latest_selinux.yaml
ccffd0
index c01192cf5..8adb06d0c 100644
ccffd0
--- a/ipatests/prci_definitions/nightly_ipa-4-9_latest_selinux.yaml
ccffd0
+++ b/ipatests/prci_definitions/nightly_ipa-4-9_latest_selinux.yaml
ccffd0
@@ -575,6 +575,19 @@ jobs:
ccffd0
         timeout: 10800
ccffd0
         topology: *master_1repl
ccffd0
 
ccffd0
+  fedora-latest-ipa-4-9/test_installation_TestInstallWithoutSudo:
ccffd0
+    requires: [fedora-latest-ipa-4-9/build]
ccffd0
+    priority: 50
ccffd0
+    job:
ccffd0
+      class: RunPytest
ccffd0
+      args:
ccffd0
+        build_url: '{fedora-latest-ipa-4-9/build_url}'
ccffd0
+        selinux_enforcing: True
ccffd0
+        test_suite: test_integration/test_installation.py::TestInstallWithoutSudo
ccffd0
+        template: *ci-ipa-4-9-latest
ccffd0
+        timeout: 4800
ccffd0
+        topology: *master_1repl_1client
ccffd0
+
ccffd0
   fedora-latest-ipa-4-9/test_idviews:
ccffd0
     requires: [fedora-latest-ipa-4-9/build]
ccffd0
     priority: 50
ccffd0
diff --git a/ipatests/prci_definitions/nightly_ipa-4-9_previous.yaml b/ipatests/prci_definitions/nightly_ipa-4-9_previous.yaml
ccffd0
index a6ea24f6a..2b5d4fd5e 100644
ccffd0
--- a/ipatests/prci_definitions/nightly_ipa-4-9_previous.yaml
ccffd0
+++ b/ipatests/prci_definitions/nightly_ipa-4-9_previous.yaml
ccffd0
@@ -535,6 +535,18 @@ jobs:
ccffd0
         timeout: 10800
ccffd0
         topology: *master_1repl
ccffd0
 
ccffd0
+  fedora-previous-ipa-4-9/test_installation_TestInstallWithoutSudo:
ccffd0
+    requires: [fedora-previous-ipa-4-9/build]
ccffd0
+    priority: 50
ccffd0
+    job:
ccffd0
+      class: RunPytest
ccffd0
+      args:
ccffd0
+        build_url: '{fedora-previous-ipa-4-9/build_url}'
ccffd0
+        test_suite: test_integration/test_installation.py::TestInstallWithoutSudo
ccffd0
+        template: *ci-ipa-4-9-previous
ccffd0
+        timeout: 4800
ccffd0
+        topology: *master_1repl_1client
ccffd0
+
ccffd0
   fedora-previous-ipa-4-9/test_idviews:
ccffd0
     requires: [fedora-previous-ipa-4-9/build]
ccffd0
     priority: 50
ccffd0
diff --git a/ipatests/test_integration/test_installation.py b/ipatests/test_integration/test_installation.py
ccffd0
index eb6f7d78e..6e8af024c 100644
ccffd0
--- a/ipatests/test_integration/test_installation.py
ccffd0
+++ b/ipatests/test_integration/test_installation.py
ccffd0
@@ -1537,3 +1537,69 @@ class TestInstallReplicaAgainstSpecificServer(IntegrationTest):
ccffd0
                                             self.replicas[0].hostname],
ccffd0
                                            stdin_text=dirman_password)
ccffd0
         assert self.replicas[0].hostname not in cmd.stdout_text
ccffd0
+
ccffd0
+
ccffd0
+class TestInstallWithoutSudo(IntegrationTest):
ccffd0
+
ccffd0
+    num_clients = 1
ccffd0
+    num_replicas = 1
ccffd0
+    no_sudo_str = "The sudo binary does not seem to be present on this"
ccffd0
+
ccffd0
+    @classmethod
ccffd0
+    def install(cls, mh):
ccffd0
+        pass
ccffd0
+
ccffd0
+    def test_sudo_removal(self):
ccffd0
+        # ipa-client makes sudo depend on libsss_sudo.
ccffd0
+
ccffd0
+        # --nodeps is mandatory because dogtag uses sudo at install
ccffd0
+        # time until commit 49585867207922479644a03078c29548de02cd03
ccffd0
+        # which is scheduled to land in 10.10.
ccffd0
+
ccffd0
+        # This also means sudo+libsss_sudo cannot be uninstalled on
ccffd0
+        # IPA servers with a CA.
ccffd0
+        assert tasks.is_package_installed(self.clients[0], 'sudo')
ccffd0
+        assert tasks.is_package_installed(self.clients[0], 'libsss_sudo')
ccffd0
+        tasks.uninstall_packages(
ccffd0
+            self.clients[0], ['sudo', 'libsss_sudo'], nodeps=True
ccffd0
+        )
ccffd0
+
ccffd0
+    def test_ipa_installation_without_sudo(self):
ccffd0
+        # FixMe: When Dogtag 10.10 is out, test installation without sudo
ccffd0
+        tasks.install_master(self.master, setup_dns=True)
ccffd0
+
ccffd0
+    def test_replica_installation_without_sudo(self):
ccffd0
+        # FixMe: When Dogtag 10.10 is out, test replica installation
ccffd0
+        # without sudo and with CA
ccffd0
+        tasks.uninstall_packages(
ccffd0
+            self.replicas[0], ['sudo', 'libsss_sudo'], nodeps=True
ccffd0
+        )
ccffd0
+        # One-step install is needed.
ccffd0
+        # With promote=True, two-step install is done and that only captures
ccffd0
+        # the ipa-replica-install stdout/stderr, not ipa-client-install's.
ccffd0
+        result = tasks.install_replica(
ccffd0
+            self.master, self.replicas[0], promote=False,
ccffd0
+            setup_dns=True, setup_ca=False
ccffd0
+        )
ccffd0
+        assert self.no_sudo_str in result.stderr_text
ccffd0
+
ccffd0
+    def test_client_installation_without_sudo(self):
ccffd0
+        result = tasks.install_client(self.master, self.clients[0])
ccffd0
+        assert self.no_sudo_str in result.stderr_text
ccffd0
+
ccffd0
+    def test_remove_sudo_on_ipa(self):
ccffd0
+        tasks.uninstall_packages(
ccffd0
+            self.master, ['sudo', 'libsss_sudo'], nodeps=True
ccffd0
+        )
ccffd0
+        self.master.run_command(
ccffd0
+            ['ipactl', 'restart']
ccffd0
+        )
ccffd0
+
ccffd0
+    def test_install_sudo_on_client(self):
ccffd0
+        """ Check that installing sudo pulls libsss_sudo in"""
ccffd0
+        for pkg in ('sudo', 'libsss_sudo'):
ccffd0
+            assert tasks.is_package_installed(self.clients[0], pkg) is False
ccffd0
+        tasks.uninstall_client(self.clients[0])
ccffd0
+        tasks.install_packages(self.clients[0], ['sudo'])
ccffd0
+        for pkg in ('sudo', 'libsss_sudo'):
ccffd0
+            assert tasks.is_package_installed(self.clients[0], pkg)
ccffd0
-- 
ccffd0
2.29.2
ccffd0
ccffd0
From 0c2741af9f353d2fbb21a5768e6433c0e99da0e9 Mon Sep 17 00:00:00 2001
ccffd0
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
ccffd0
Date: Thu, 10 Dec 2020 08:35:12 +0200
ccffd0
Subject: [PATCH] ipatests: tasks: handle uninstalling packages with nodeps
ccffd0
MIME-Version: 1.0
ccffd0
Content-Type: text/plain; charset=UTF-8
ccffd0
Content-Transfer-Encoding: 8bit
ccffd0
ccffd0
Handle package removal without taking dependencies into account.
ccffd0
E.g. add frontends for rpm -e --nodeps.
ccffd0
ccffd0
Related: ipatests/pytest_ipa/integration/tasks.py
ccffd0
Signed-off-by: François Cami <fcami@redhat.com>
ccffd0
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
ccffd0
Reviewed-By: Armando Neto <abiagion@redhat.com>
ccffd0
Reviewed-By: Michal Polovka <mpolovka@redhat.com>
ccffd0
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
ccffd0
Reviewed-By: Armando Neto <abiagion@redhat.com>
ccffd0
Reviewed-By: Michal Polovka <mpolovka@redhat.com>
ccffd0
Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
ccffd0
---
ccffd0
 ipatests/pytest_ipa/integration/tasks.py | 51 +++++++++++++++++++-----
ccffd0
 1 file changed, 41 insertions(+), 10 deletions(-)
ccffd0
ccffd0
diff --git a/ipatests/pytest_ipa/integration/tasks.py b/ipatests/pytest_ipa/integration/tasks.py
ccffd0
index b91859816..2fe78367f 100755
ccffd0
--- a/ipatests/pytest_ipa/integration/tasks.py
ccffd0
+++ b/ipatests/pytest_ipa/integration/tasks.py
ccffd0
@@ -29,6 +29,7 @@ import re
ccffd0
 import collections
ccffd0
 import itertools
ccffd0
 import shutil
ccffd0
+import shlex
ccffd0
 import copy
ccffd0
 import subprocess
ccffd0
 import tempfile
ccffd0
@@ -2381,20 +2382,33 @@ def download_packages(host, pkgs):
ccffd0
     return tmpdir
ccffd0
 
ccffd0
 
ccffd0
-def uninstall_packages(host, pkgs):
ccffd0
+def uninstall_packages(host, pkgs, nodeps=False):
ccffd0
     """Uninstall packages on a remote host.
ccffd0
-    :param host: the host where the uninstallation takes place
ccffd0
-    :param pkgs: packages to uninstall, provided as a list of strings
ccffd0
+    :param host: the host where the uninstallation takes place.
ccffd0
+    :param pkgs: packages to uninstall, provided as a list of strings.
ccffd0
+    :param nodeps: ignore dependencies (dangerous!).
ccffd0
     """
ccffd0
     platform = get_platform(host)
ccffd0
-    # Only supports RHEL 8+ and Fedora for now
ccffd0
-    if platform in ('rhel', 'fedora'):
ccffd0
-        install_cmd = ['/usr/bin/dnf', 'remove', '-y']
ccffd0
-    elif platform in ('ubuntu'):
ccffd0
-        install_cmd = ['apt-get', 'remove', '-y']
ccffd0
+    if platform not in ('rhel', 'fedora', 'ubuntu'):
ccffd0
+        raise ValueError('uninstall_packages: unknown platform %s' % platform)
ccffd0
+    if nodeps:
ccffd0
+        if platform in ('rhel', 'fedora'):
ccffd0
+            cmd = "rpm -e --nodeps"
ccffd0
+        elif platform in ('ubuntu'):
ccffd0
+            cmd = "dpkg -P --force-depends"
ccffd0
+        for package in pkgs:
ccffd0
+            uninstall_cmd = shlex.split(cmd)
ccffd0
+            uninstall_cmd.append(package)
ccffd0
+            # keep raiseonerr=True here. --fcami
ccffd0
+            host.run_command(uninstall_cmd)
ccffd0
     else:
ccffd0
-        raise ValueError('install_packages: unknown platform %s' % platform)
ccffd0
-    host.run_command(install_cmd + pkgs, raiseonerr=False)
ccffd0
+        if platform in ('rhel', 'fedora'):
ccffd0
+            cmd = "/usr/bin/dnf remove -y"
ccffd0
+        elif platform in ('ubuntu'):
ccffd0
+            cmd = "apt-get remove -y"
ccffd0
+        uninstall_cmd = shlex.split(cmd)
ccffd0
+        uninstall_cmd.extend(pkgs)
ccffd0
+        host.run_command(uninstall_cmd, raiseonerr=False)
ccffd0
 
ccffd0
 
ccffd0
 def wait_for_request(host, request_id, timeout=120):
ccffd0
@@ -2649,3 +2663,20 @@ def run_ssh_cmd(
ccffd0
             assert "Authentication succeeded" not in stderr
ccffd0
             assert "No more authentication methods to try." in stderr
ccffd0
     return (return_code, stdout, stderr)
ccffd0
+
ccffd0
+
ccffd0
+def is_package_installed(host, pkg):
ccffd0
+    platform = get_platform(host)
ccffd0
+    if platform in ('rhel', 'fedora'):
ccffd0
+        result = host.run_command(
ccffd0
+            ['rpm', '-q', pkg], raiseonerr=False
ccffd0
+        )
ccffd0
+    elif platform in ['ubuntu']:
ccffd0
+        result = host.run_command(
ccffd0
+            ['dpkg', '-s', pkg], raiseonerr=False
ccffd0
+        )
ccffd0
+    else:
ccffd0
+        raise ValueError(
ccffd0
+            'is_package_installed: unknown platform %s' % platform
ccffd0
+        )
ccffd0
+    return result.returncode == 0
ccffd0
-- 
ccffd0
2.29.2
ccffd0
ccffd0
From fe157ca349e3146a53884e90e6e588efb4e97eeb Mon Sep 17 00:00:00 2001
ccffd0
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
ccffd0
Date: Thu, 10 Dec 2020 08:15:22 +0200
ccffd0
Subject: [PATCH] ipa-client-install: output a warning if sudo is not present
ccffd0
MIME-Version: 1.0
ccffd0
Content-Type: text/plain; charset=UTF-8
ccffd0
Content-Transfer-Encoding: 8bit
ccffd0
ccffd0
Fixes: https://pagure.io/freeipa/issue/8530
ccffd0
Signed-off-by: François Cami <fcami@redhat.com>
ccffd0
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
ccffd0
Reviewed-By: Armando Neto <abiagion@redhat.com>
ccffd0
Reviewed-By: Michal Polovka <mpolovka@redhat.com>
ccffd0
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
ccffd0
Reviewed-By: Armando Neto <abiagion@redhat.com>
ccffd0
Reviewed-By: Michal Polovka <mpolovka@redhat.com>
ccffd0
Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
ccffd0
---
ccffd0
 ipaclient/install/client.py | 14 +++++++++++++-
ccffd0
 1 file changed, 13 insertions(+), 1 deletion(-)
ccffd0
ccffd0
diff --git a/ipaclient/install/client.py b/ipaclient/install/client.py
ccffd0
index 8acfa0cd1..0e478fa26 100644
ccffd0
--- a/ipaclient/install/client.py
ccffd0
+++ b/ipaclient/install/client.py
ccffd0
@@ -24,6 +24,7 @@ import re
ccffd0
 import SSSDConfig
ccffd0
 import shutil
ccffd0
 import socket
ccffd0
+import subprocess
ccffd0
 import sys
ccffd0
 import tempfile
ccffd0
 import textwrap
ccffd0
@@ -2200,7 +2201,18 @@ def install_check(options):
ccffd0
             "authentication resources",
ccffd0
             rval=CLIENT_INSTALL_ERROR)
ccffd0
 
ccffd0
-    # when installing with '--no-sssd' option, check whether nss-ldap is
ccffd0
+    # When installing without the "--no-sudo" option, check whether sudo is
ccffd0
+    # available.
ccffd0
+    if options.conf_sudo:
ccffd0
+        try:
ccffd0
+            subprocess.Popen(['sudo -V'])
ccffd0
+        except FileNotFoundError:
ccffd0
+            logger.info(
ccffd0
+                "The sudo binary does not seem to be present on this "
ccffd0
+                "system. Please consider installing sudo if required."
ccffd0
+            )
ccffd0
+
ccffd0
+    # when installing with the '--no-sssd' option, check whether nss-ldap is
ccffd0
     # installed
ccffd0
     if not options.sssd:
ccffd0
         if not os.path.exists(paths.PAM_KRB5_SO):
ccffd0
-- 
ccffd0
2.29.2
ccffd0
ccffd0
From ee0ba2df41cf545b82d3d26e7e7e42447bb0f63e Mon Sep 17 00:00:00 2001
ccffd0
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
ccffd0
Date: Thu, 10 Dec 2020 07:55:16 +0200
ccffd0
Subject: [PATCH] freeipa.spec: client: depend on libsss_sudo and sudo
ccffd0
MIME-Version: 1.0
ccffd0
Content-Type: text/plain; charset=UTF-8
ccffd0
Content-Transfer-Encoding: 8bit
ccffd0
ccffd0
On 10.10+ releases of Dogtag, the PKI installer will not depend
ccffd0
on sudo anymore. This opens the possibility of creating IPA servers
ccffd0
without a properly configured sudo.
ccffd0
In fact, even IPA clients should have sudo and libsss_sudo installed
ccffd0
in most cases, so add a weak dependency on both of them to the client
ccffd0
subpackage.
ccffd0
Also make sure libsss_sudo is installed if sudo is present.
ccffd0
ccffd0
Fixes: https://pagure.io/freeipa/issue/8530
ccffd0
Signed-off-by: François Cami <fcami@redhat.com>
ccffd0
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
ccffd0
Reviewed-By: Armando Neto <abiagion@redhat.com>
ccffd0
Reviewed-By: Michal Polovka <mpolovka@redhat.com>
ccffd0
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
ccffd0
Reviewed-By: Armando Neto <abiagion@redhat.com>
ccffd0
Reviewed-By: Michal Polovka <mpolovka@redhat.com>
ccffd0
Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
ccffd0
---
ccffd0
 freeipa.spec.in | 5 +++++
ccffd0
 1 file changed, 5 insertions(+)
ccffd0
ccffd0
diff --git a/freeipa.spec.in b/freeipa.spec.in
ccffd0
index ba52a3834..93e473ac4 100755
ccffd0
--- a/freeipa.spec.in
ccffd0
+++ b/freeipa.spec.in
ccffd0
@@ -640,6 +640,11 @@ Requires: nfs-utils
ccffd0
 Requires: sssd-tools >= %{sssd_version}
ccffd0
 Requires(post): policycoreutils
ccffd0
 
ccffd0
+# https://pagure.io/freeipa/issue/8530
ccffd0
+Recommends: libsss_sudo
ccffd0
+Recommends: sudo
ccffd0
+Requires: (libsss_sudo if sudo)
ccffd0
+
ccffd0
 Provides: %{alt_name}-client = %{version}
ccffd0
 Conflicts: %{alt_name}-client
ccffd0
 Obsoletes: %{alt_name}-client < %{version}
ccffd0
-- 
ccffd0
2.29.2
ccffd0