ac7d03
From 9cacddeb763c3e07ee31ac5bc2528cfb274b57b1 Mon Sep 17 00:00:00 2001
ac7d03
From: David Kupka <dkupka@redhat.com>
ac7d03
Date: Mon, 27 Mar 2017 09:30:53 +0200
ac7d03
Subject: [PATCH] httpinstance.disable_system_trust: Don't fail if module 'Root
ac7d03
 Certs' is not available
ac7d03
ac7d03
Server installation failed when attmpting to disable module 'Root Certs' and
ac7d03
the module was not available in HTTP_ALIAS_DIR. When the module is not
ac7d03
available there's no need to disable it and the error may be treated as
ac7d03
success.
ac7d03
ac7d03
https://pagure.io/freeipa/issue/6803
ac7d03
ac7d03
Reviewed-By: Christian Heimes <cheimes@redhat.com>
ac7d03
Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
ac7d03
---
ac7d03
 ipaserver/install/httpinstance.py | 14 +++++++++++---
ac7d03
 1 file changed, 11 insertions(+), 3 deletions(-)
ac7d03
ac7d03
diff --git a/ipaserver/install/httpinstance.py b/ipaserver/install/httpinstance.py
ac7d03
index f6f0b0c4f6acd648aa9f6f5d7400617613245473..01b55e7a7b00d020b7745c419267ad4f0ba86804 100644
ac7d03
--- a/ipaserver/install/httpinstance.py
ac7d03
+++ b/ipaserver/install/httpinstance.py
ac7d03
@@ -355,9 +355,17 @@ class HTTPInstance(service.Service):
ac7d03
         name = 'Root Certs'
ac7d03
         args = [paths.MODUTIL, '-dbdir', paths.HTTPD_ALIAS_DIR, '-force']
ac7d03
 
ac7d03
-        result = ipautil.run(args + ['-list', name],
ac7d03
-                             env={},
ac7d03
-                             capture_output=True)
ac7d03
+        try:
ac7d03
+            result = ipautil.run(args + ['-list', name],
ac7d03
+                                 env={},
ac7d03
+                                 capture_output=True)
ac7d03
+        except ipautil.CalledProcessError as e:
ac7d03
+            if e.returncode == 29:  # ERROR: Module not found in database.
ac7d03
+                root_logger.debug(
ac7d03
+                    'Module %s not available, treating as disabled', name)
ac7d03
+                return False
ac7d03
+            raise
ac7d03
+
ac7d03
         if 'Status: Enabled' in result.output:
ac7d03
             ipautil.run(args + ['-disable', name], env={})
ac7d03
             return True
ac7d03
-- 
ac7d03
2.12.1
ac7d03