590d18
From 42353682a3d9e92f4053877d66f54e44f516bb53 Mon Sep 17 00:00:00 2001
590d18
From: David Kupka <dkupka@redhat.com>
590d18
Date: Tue, 7 Jul 2015 15:49:51 +0200
590d18
Subject: [PATCH] ipa-client-install: Do not (re)start certmonger and DBus
590d18
 daemons.
590d18
590d18
When DBus is present in the system it is always running.
590d18
590d18
Starting of certmomger is handled in ipapython/certmonger.py module if
590d18
necessary. Restarting is no longer needed since freeipa is not changing
590d18
certmonger's files.
590d18
590d18
https://fedorahosted.org/freeipa/ticket/5095
590d18
590d18
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
590d18
---
590d18
 ipa-client/ipa-install/ipa-client-install | 71 +++++++------------------------
590d18
 1 file changed, 15 insertions(+), 56 deletions(-)
590d18
590d18
diff --git a/ipa-client/ipa-install/ipa-client-install b/ipa-client/ipa-install/ipa-client-install
590d18
index 96b30b486585bc60b0882263cff58292a3538df9..91323ae115a27d221bcbc43fee887c56d99c8635 100755
590d18
--- a/ipa-client/ipa-install/ipa-client-install
590d18
+++ b/ipa-client/ipa-install/ipa-client-install
590d18
@@ -522,20 +522,7 @@ def uninstall(options, env):
590d18
     ipa_db = certdb.NSSDatabase(paths.IPA_NSSDB_DIR)
590d18
     sys_db = certdb.NSSDatabase(paths.NSS_DB_DIR)
590d18
 
590d18
-    # Always start certmonger. We can't untrack something if it isn't
590d18
-    # running
590d18
-    messagebus = services.knownservices.messagebus
590d18
-    try:
590d18
-        messagebus.start()
590d18
-    except Exception, e:
590d18
-        log_service_error(messagebus.service_name, 'start', e)
590d18
-
590d18
     cmonger = services.knownservices.certmonger
590d18
-    try:
590d18
-        cmonger.start()
590d18
-    except Exception, e:
590d18
-        log_service_error(cmonger.service_name, 'start', e)
590d18
-
590d18
     if ipa_db.has_nickname('Local IPA host'):
590d18
         try:
590d18
             certmonger.stop_tracking(paths.IPA_NSSDB_DIR,
590d18
@@ -576,14 +563,14 @@ def uninstall(options, env):
590d18
                                   nickname, sys_db.secdir, e)
590d18
                 break
590d18
 
590d18
+    # Remove any special principal names we added to the IPA CA helper
590d18
+    certmonger.remove_principal_from_cas()
590d18
+
590d18
     try:
590d18
         cmonger.stop()
590d18
     except Exception, e:
590d18
         log_service_error(cmonger.service_name, 'stop', e)
590d18
 
590d18
-    # Remove any special principal names we added to the IPA CA helper
590d18
-    certmonger.remove_principal_from_cas()
590d18
-
590d18
     try:
590d18
         cmonger.disable()
590d18
     except Exception, e:
590d18
@@ -1138,41 +1125,14 @@ def configure_certmonger(fstore, subject_base, cli_realm, hostname, options,
590d18
             "Not requesting host certificate.")
590d18
         return
590d18
 
590d18
-    started = True
590d18
     principal = 'host/%s@%s' % (hostname, cli_realm)
590d18
 
590d18
-    messagebus = services.knownservices.messagebus
590d18
-    try:
590d18
-        messagebus.start()
590d18
-    except Exception, e:
590d18
-        log_service_error(messagebus.service_name, 'start', e)
590d18
-
590d18
-    # Ensure that certmonger has been started at least once to generate the
590d18
-    # cas files in /var/lib/certmonger/cas.
590d18
-    cmonger = services.knownservices.certmonger
590d18
-    try:
590d18
-        cmonger.restart()
590d18
-    except Exception, e:
590d18
-        log_service_error(cmonger.service_name, 'restart', e)
590d18
-
590d18
     if options.hostname:
590d18
-        # It needs to be stopped if we touch them
590d18
-        try:
590d18
-            cmonger.stop()
590d18
-        except Exception, e:
590d18
-            log_service_error(cmonger.service_name, 'stop', e)
590d18
         # If the hostname is explicitly set then we need to tell certmonger
590d18
         # which principal name to use when requesting certs.
590d18
         certmonger.add_principal_to_cas(principal)
590d18
 
590d18
-    try:
590d18
-        cmonger.restart()
590d18
-    except Exception, e:
590d18
-        log_service_error(cmonger.service_name, 'restart', e)
590d18
-        root_logger.warning(
590d18
-            "Automatic certificate management will not be available")
590d18
-        started = False
590d18
-
590d18
+    cmonger = services.knownservices.certmonger
590d18
     try:
590d18
         cmonger.enable()
590d18
     except Exception, e:
590d18
@@ -1183,18 +1143,17 @@ def configure_certmonger(fstore, subject_base, cli_realm, hostname, options,
590d18
             "Automatic certificate management will not be available")
590d18
 
590d18
     # Request our host cert
590d18
-    if started:
590d18
-        subject = str(DN(('CN', hostname), subject_base))
590d18
-        passwd_fname = os.path.join(paths.IPA_NSSDB_DIR, 'pwdfile.txt')
590d18
-        try:
590d18
-            certmonger.request_cert(nssdb=paths.IPA_NSSDB_DIR,
590d18
-                                    nickname='Local IPA host',
590d18
-                                    subject=subject,
590d18
-                                    principal=principal,
590d18
-                                    passwd_fname=passwd_fname)
590d18
-        except Exception:
590d18
-            root_logger.error("%s request for host certificate failed",
590d18
-                              cmonger.service_name)
590d18
+    subject = str(DN(('CN', hostname), subject_base))
590d18
+    passwd_fname = os.path.join(paths.IPA_NSSDB_DIR, 'pwdfile.txt')
590d18
+    try:
590d18
+        certmonger.request_cert(nssdb=paths.IPA_NSSDB_DIR,
590d18
+                                nickname='Local IPA host',
590d18
+                                subject=subject,
590d18
+                                principal=principal,
590d18
+                                passwd_fname=passwd_fname)
590d18
+    except Exception:
590d18
+        root_logger.error("%s request for host certificate failed",
590d18
+                          cmonger.service_name)
590d18
 
590d18
 def configure_sssd_conf(fstore, cli_realm, cli_domain, cli_server, options, client_domain, client_hostname):
590d18
     try:
590d18
-- 
590d18
2.4.3
590d18