Blame SOURCES/0012-ipa-replica-install_--setup-adtrust_check_for_package_ipa-server-trust-ad_rhbz#1658294.patch

b01884
From be968ea01adf1721b0afd7393872a8d311d89d0c Mon Sep 17 00:00:00 2001
b01884
From: Florence Blanc-Renaud <flo@redhat.com>
b01884
Date: Oct 24 2018 14:21:47 +0000
b01884
Subject: ipa-replica-install --setup-adtrust: check for package ipa-server-trust-ad
b01884
b01884
b01884
When adding the option --setup-adtrust to ipa-replica-install,
b01884
we need to check that the package freeipa-server-trust-ad is
b01884
installed.
b01884
To avoid relying on OS-specific commands like yum, the check is instead
b01884
ensuring that the file /usr/share/ipa/smb.conf.empty is present
b01884
(this file is delivered by the package).
b01884
When the check is unsuccessful, ipa-replica-install exits with an error
b01884
message.
b01884
b01884
Fixes: https://pagure.io/freeipa/issue/7602
b01884
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
b01884
b01884
---
b01884
b01884
diff --git a/ipaplatform/base/constants.py b/ipaplatform/base/constants.py
b01884
index be832fe..c67b991 100644
b01884
--- a/ipaplatform/base/constants.py
b01884
+++ b/ipaplatform/base/constants.py
b01884
@@ -15,6 +15,7 @@ class BaseConstantsNamespace(object):
b01884
     HTTPD_USER = "apache"
b01884
     HTTPD_GROUP = "apache"
b01884
     GSSPROXY_USER = "root"
b01884
+    IPA_ADTRUST_PACKAGE_NAME = "freeipa-server-trust-ad"
b01884
     IPA_DNS_PACKAGE_NAME = "freeipa-server-dns"
b01884
     KDCPROXY_USER = "kdcproxy"
b01884
     NAMED_USER = "named"
b01884
diff --git a/ipaplatform/rhel/constants.py b/ipaplatform/rhel/constants.py
b01884
index 945f3dc..72335ac 100644
b01884
--- a/ipaplatform/rhel/constants.py
b01884
+++ b/ipaplatform/rhel/constants.py
b01884
@@ -13,6 +13,7 @@ from ipaplatform.redhat.constants import RedHatConstantsNamespace
b01884
 
b01884
 
b01884
 class RHELConstantsNamespace(RedHatConstantsNamespace):
b01884
+    IPA_ADTRUST_PACKAGE_NAME = "ipa-server-trust-ad"
b01884
     IPA_DNS_PACKAGE_NAME = "ipa-server-dns"
b01884
 
b01884
 constants = RHELConstantsNamespace()
b01884
diff --git a/ipaserver/install/adtrustinstance.py b/ipaserver/install/adtrustinstance.py
b01884
index 3a751cc..67317ee 100644
b01884
--- a/ipaserver/install/adtrustinstance.py
b01884
+++ b/ipaserver/install/adtrustinstance.py
b01884
@@ -72,6 +72,15 @@ def check_inst():
b01884
                   "start the installation again")
b01884
             return False
b01884
 
b01884
+    # Check that ipa-server-trust-ad package is installed,
b01884
+    # by looking for the file /usr/share/ipa/smb.conf.empty
b01884
+    if not os.path.exists(os.path.join(paths.USR_SHARE_IPA_DIR,
b01884
+                                       "smb.conf.empty")):
b01884
+        print("AD Trust requires the '%s' package" %
b01884
+              constants.IPA_ADTRUST_PACKAGE_NAME)
b01884
+        print("Please install the package and start the installation again")
b01884
+        return False
b01884
+
b01884
     #TODO: Add check for needed samba4 libraries
b01884
 
b01884
     return True
b01884