ac7d03
From acb04249a77f62f72179899223bfeacdd2292883 Mon Sep 17 00:00:00 2001
ac7d03
From: Jan Cholasta <jcholast@redhat.com>
ac7d03
Date: Fri, 7 Apr 2017 07:44:21 +0200
ac7d03
Subject: [PATCH] install: request service certs after host keytab is set up
ac7d03
ac7d03
The certmonger renew agent and restart scripts use host keytab for
ac7d03
authentication. When they are executed during a certmonger request before
ac7d03
the host keytab is set up, the authentication will fail.
ac7d03
ac7d03
Make sure all certmonger requests in the installer are done after the host
ac7d03
keytab is set up.
ac7d03
ac7d03
https://pagure.io/freeipa/issue/6757
ac7d03
ac7d03
Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
ac7d03
---
ac7d03
 ipaserver/install/dsinstance.py            | 17 +++++++----------
ac7d03
 ipaserver/install/server/install.py        | 18 +++++++-----------
ac7d03
 ipaserver/install/server/replicainstall.py |  5 ++---
ac7d03
 3 files changed, 16 insertions(+), 24 deletions(-)
ac7d03
ac7d03
diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py
ac7d03
index 31dbd4ec8bcaf4a7545b4f9f316fe609b845cb75..72fcb65f2eb699d0077d3c5cc02a3fcaaad9b8e5 100644
ac7d03
--- a/ipaserver/install/dsinstance.py
ac7d03
+++ b/ipaserver/install/dsinstance.py
ac7d03
@@ -256,7 +256,7 @@ class DsInstance(service.Service):
ac7d03
 
ac7d03
     subject_base = ipautil.dn_attribute_property('_subject_base')
ac7d03
 
ac7d03
-    def __common_setup(self, enable_ssl=False):
ac7d03
+    def __common_setup(self):
ac7d03
 
ac7d03
         self.step("creating directory server user", create_ds_user)
ac7d03
         self.step("creating directory server instance", self.__create_instance)
ac7d03
@@ -279,8 +279,6 @@ class DsInstance(service.Service):
ac7d03
         self.step("configuring topology plugin", self.__config_topology_module)
ac7d03
         self.step("creating indices", self.__create_indices)
ac7d03
         self.step("enabling referential integrity plugin", self.__add_referint_module)
ac7d03
-        if enable_ssl:
ac7d03
-            self.step("configuring TLS for DS instance", self.__enable_ssl)
ac7d03
         self.step("configuring certmap.conf", self.__certmap_conf)
ac7d03
         self.step("configure new location for managed entries", self.__repoint_managed_entries)
ac7d03
         self.step("configure dirsrv ccache", self.configure_dirsrv_ccache)
ac7d03
@@ -356,8 +354,12 @@ class DsInstance(service.Service):
ac7d03
         self.steps = []
ac7d03
 
ac7d03
         self.step("configuring TLS for DS instance", self.__enable_ssl)
ac7d03
+        if self.master_fqdn is None:
ac7d03
+            self.step("adding CA certificate entry", self.__upload_ca_cert)
ac7d03
+        else:
ac7d03
+            self.step("importing CA certificates from LDAP",
ac7d03
+                      self.__import_ca_certs)
ac7d03
         self.step("restarting directory server", self.__restart_instance)
ac7d03
-        self.step("adding CA certificate entry", self.__upload_ca_cert)
ac7d03
 
ac7d03
         self.start_creation()
ac7d03
 
ac7d03
@@ -391,21 +393,16 @@ class DsInstance(service.Service):
ac7d03
         self.promote = promote
ac7d03
         self.api = api
ac7d03
 
ac7d03
-        self.__common_setup(enable_ssl=(not self.promote))
ac7d03
+        self.__common_setup()
ac7d03
         self.step("restarting directory server", self.__restart_instance)
ac7d03
 
ac7d03
         self.step("creating DS keytab", self.request_service_keytab)
ac7d03
-        if self.promote:
ac7d03
-            self.step("configuring TLS for DS instance", self.__enable_ssl)
ac7d03
-            self.step("restarting directory server", self.__restart_instance)
ac7d03
-
ac7d03
         self.step("setting up initial replication", self.__setup_replica)
ac7d03
         self.step("adding sasl mappings to the directory", self.__configure_sasl_mappings)
ac7d03
         self.step("updating schema", self.__update_schema)
ac7d03
         # See LDIFs for automember configuration during replica install
ac7d03
         self.step("setting Auto Member configuration", self.__add_replica_automember_config)
ac7d03
         self.step("enabling S4U2Proxy delegation", self.__setup_s4u2proxy)
ac7d03
-        self.step("importing CA certificates from LDAP", self.__import_ca_certs)
ac7d03
 
ac7d03
         self.__common_post_setup()
ac7d03
 
ac7d03
diff --git a/ipaserver/install/server/install.py b/ipaserver/install/server/install.py
ac7d03
index f8e64ec26e85bbc6218018eec8f403a0567b45a2..bf2e248dceaae36ba0030d3eaa47976f51ce60ba 100644
ac7d03
--- a/ipaserver/install/server/install.py
ac7d03
+++ b/ipaserver/install/server/install.py
ac7d03
@@ -770,6 +770,13 @@ def install(installer):
ac7d03
             realm_name, host_name, domain_name, dm_password,
ac7d03
             options.subject_base, options.ca_subject, 1101, 1100, None)
ac7d03
 
ac7d03
+    krb = krbinstance.KrbInstance(fstore)
ac7d03
+    krb.create_instance(realm_name, host_name, domain_name,
ac7d03
+                        dm_password, master_password,
ac7d03
+                        setup_pkinit=not options.no_pkinit,
ac7d03
+                        pkcs12_info=pkinit_pkcs12_info,
ac7d03
+                        subject_base=options.subject_base)
ac7d03
+
ac7d03
     if setup_ca:
ac7d03
         if not options.external_cert_files and options.external_ca:
ac7d03
             # stage 1 of external CA installation
ac7d03
@@ -793,17 +800,6 @@ def install(installer):
ac7d03
     # we now need to enable ssl on the ds
ac7d03
     ds.enable_ssl()
ac7d03
 
ac7d03
-    krb = krbinstance.KrbInstance(fstore)
ac7d03
-    krb.create_instance(realm_name, host_name, domain_name,
ac7d03
-                        dm_password, master_password,
ac7d03
-                        setup_pkinit=not options.no_pkinit,
ac7d03
-                        pkcs12_info=pkinit_pkcs12_info,
ac7d03
-                        subject_base=options.subject_base)
ac7d03
-
ac7d03
-    # restart DS to enable ipa-pwd-extop plugin
ac7d03
-    print("Restarting directory server to enable password extension plugin")
ac7d03
-    ds.restart()
ac7d03
-
ac7d03
     if setup_ca:
ac7d03
         ca.install_step_1(False, None, options)
ac7d03
 
ac7d03
diff --git a/ipaserver/install/server/replicainstall.py b/ipaserver/install/server/replicainstall.py
ac7d03
index cd6a62f9540f4a46da70e0cc5686eff5f54e7dfe..6f1a0d6d29b20d53986205a63382a385e75f80ea 100644
ac7d03
--- a/ipaserver/install/server/replicainstall.py
ac7d03
+++ b/ipaserver/install/server/replicainstall.py
ac7d03
@@ -1422,9 +1422,8 @@ def install(installer):
ac7d03
         setup_pkinit=not options.no_pkinit,
ac7d03
         promote=promote)
ac7d03
 
ac7d03
-    # restart DS to enable ipa-pwd-extop plugin
ac7d03
-    print("Restarting directory server to enable password extension plugin")
ac7d03
-    ds.restart()
ac7d03
+    # we now need to enable ssl on the ds
ac7d03
+    ds.enable_ssl()
ac7d03
 
ac7d03
     install_http(
ac7d03
         config,
ac7d03
-- 
ac7d03
2.9.3
ac7d03