Blob Blame History Raw
From 9cacddeb763c3e07ee31ac5bc2528cfb274b57b1 Mon Sep 17 00:00:00 2001
From: David Kupka <dkupka@redhat.com>
Date: Mon, 27 Mar 2017 09:30:53 +0200
Subject: [PATCH] httpinstance.disable_system_trust: Don't fail if module 'Root
 Certs' is not available

Server installation failed when attmpting to disable module 'Root Certs' and
the module was not available in HTTP_ALIAS_DIR. When the module is not
available there's no need to disable it and the error may be treated as
success.

https://pagure.io/freeipa/issue/6803

Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
---
 ipaserver/install/httpinstance.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/ipaserver/install/httpinstance.py b/ipaserver/install/httpinstance.py
index f6f0b0c4f6acd648aa9f6f5d7400617613245473..01b55e7a7b00d020b7745c419267ad4f0ba86804 100644
--- a/ipaserver/install/httpinstance.py
+++ b/ipaserver/install/httpinstance.py
@@ -355,9 +355,17 @@ class HTTPInstance(service.Service):
         name = 'Root Certs'
         args = [paths.MODUTIL, '-dbdir', paths.HTTPD_ALIAS_DIR, '-force']
 
-        result = ipautil.run(args + ['-list', name],
-                             env={},
-                             capture_output=True)
+        try:
+            result = ipautil.run(args + ['-list', name],
+                                 env={},
+                                 capture_output=True)
+        except ipautil.CalledProcessError as e:
+            if e.returncode == 29:  # ERROR: Module not found in database.
+                root_logger.debug(
+                    'Module %s not available, treating as disabled', name)
+                return False
+            raise
+
         if 'Status: Enabled' in result.output:
             ipautil.run(args + ['-disable', name], env={})
             return True
-- 
2.12.1