Blame SOURCES/0002-Patch-ECAdminCertProfile-upgrade-script.patch

3b22ff
From dc00a5c3aaf84f8fb2a3c0473e31646b9d57badc Mon Sep 17 00:00:00 2001
3b22ff
From: Dinesh Prasanth M K <SilleBille@users.noreply.github.com>
3b22ff
Date: Wed, 25 Mar 2020 16:02:15 -0400
3b22ff
Subject: [PATCH] Patch ECAdminCertProfile upgrade script
3b22ff
3b22ff
Backport of PR #355
3b22ff
3b22ff
The caECAdminCert profile was added 2 years ago but was never patched
3b22ff
to be added to the CS.cfg. Hence, when a user tries to upgrade, the path
3b22ff
did not exist and so, the upgrade failed. This patch adds the missing
3b22ff
attribute to ensure smooth upgradation process
3b22ff
3b22ff
Move 10.8.2 upgrade script to 10.8.3
3b22ff
3b22ff
Resolves: BZ#1814242
3b22ff
Upstream: https://pagure.io/dogtagpki/issue/3168
3b22ff
3b22ff
Signed-off-by: Dinesh Prasanth M K <dmoluguw@redhat.com>
3b22ff
---
3b22ff
 .../10.8.2/01-FixECAdminCertProfile.py        | 39 -------------
3b22ff
 .../10.8.3/01-FixECAdminCertProfile.py        | 55 +++++++++++++++++++
3b22ff
 2 files changed, 55 insertions(+), 39 deletions(-)
3b22ff
 delete mode 100644 base/server/upgrade/10.8.2/01-FixECAdminCertProfile.py
3b22ff
 create mode 100644 base/server/upgrade/10.8.3/01-FixECAdminCertProfile.py
3b22ff
3b22ff
diff --git a/base/server/upgrade/10.8.2/01-FixECAdminCertProfile.py b/base/server/upgrade/10.8.2/01-FixECAdminCertProfile.py
3b22ff
deleted file mode 100644
3b22ff
index ebdb98304..000000000
3b22ff
--- a/base/server/upgrade/10.8.2/01-FixECAdminCertProfile.py
3b22ff
+++ /dev/null
3b22ff
@@ -1,39 +0,0 @@
3b22ff
-# Authors:
3b22ff
-#     Endi S. Dewata <edewata@redhat.com>
3b22ff
-#
3b22ff
-# Copyright Red Hat, Inc.
3b22ff
-#
3b22ff
-# SPDX-License-Identifier: GPL-2.0-or-later
3b22ff
-
3b22ff
-from __future__ import absolute_import
3b22ff
-import logging
3b22ff
-import os
3b22ff
-
3b22ff
-import pki
3b22ff
-
3b22ff
-logger = logging.getLogger(__name__)
3b22ff
-
3b22ff
-
3b22ff
-class FixECAdminCertProfile(pki.server.upgrade.PKIServerUpgradeScriptlet):
3b22ff
-
3b22ff
-    def __init__(self):
3b22ff
-        super(FixECAdminCertProfile, self).__init__()
3b22ff
-        self.message = 'Fix EC admin certificate profile'
3b22ff
-
3b22ff
-    def upgrade_subsystem(self, instance, subsystem):
3b22ff
-
3b22ff
-        if subsystem.name != 'ca':
3b22ff
-            return
3b22ff
-
3b22ff
-        self.backup(subsystem.cs_conf)
3b22ff
-
3b22ff
-        path = subsystem.config.get('profile.caECAdminCert.config')
3b22ff
-        logger.info('Current path: %s', path)
3b22ff
-
3b22ff
-        dirname = os.path.dirname(path)
3b22ff
-
3b22ff
-        path = os.path.join(dirname, 'caECAdminCert.cfg')
3b22ff
-        logger.info('New path: %s', path)
3b22ff
-
3b22ff
-        subsystem.config['profile.caECAdminCert.config'] = path
3b22ff
-        subsystem.save()
3b22ff
diff --git a/base/server/upgrade/10.8.3/01-FixECAdminCertProfile.py b/base/server/upgrade/10.8.3/01-FixECAdminCertProfile.py
3b22ff
new file mode 100644
3b22ff
index 000000000..92664d292
3b22ff
--- /dev/null
3b22ff
+++ b/base/server/upgrade/10.8.3/01-FixECAdminCertProfile.py
3b22ff
@@ -0,0 +1,55 @@
3b22ff
+# Authors:
3b22ff
+#     Endi S. Dewata <edewata@redhat.com>
3b22ff
+#
3b22ff
+# Copyright Red Hat, Inc.
3b22ff
+#
3b22ff
+# SPDX-License-Identifier: GPL-2.0-or-later
3b22ff
+
3b22ff
+from __future__ import absolute_import
3b22ff
+import logging
3b22ff
+import os
3b22ff
+
3b22ff
+import pki
3b22ff
+
3b22ff
+logger = logging.getLogger(__name__)
3b22ff
+
3b22ff
+
3b22ff
+class FixECAdminCertProfile(pki.server.upgrade.PKIServerUpgradeScriptlet):
3b22ff
+
3b22ff
+    def __init__(self):
3b22ff
+        super(FixECAdminCertProfile, self).__init__()
3b22ff
+        self.message = 'Fix EC admin certificate profile'
3b22ff
+
3b22ff
+    def upgrade_subsystem(self, instance, subsystem):
3b22ff
+
3b22ff
+        if subsystem.name != 'ca':
3b22ff
+            return
3b22ff
+
3b22ff
+        self.backup(subsystem.cs_conf)
3b22ff
+
3b22ff
+        path = subsystem.config.get('profile.caECAdminCert.config')
3b22ff
+        if path is None:
3b22ff
+            # Add missing path
3b22ff
+            logger.info('Missing profile.caECAdminCert.config')
3b22ff
+
3b22ff
+            path = "{0}/profiles/{1}/caECAdminCert.cfg".format(
3b22ff
+                subsystem.base_dir, subsystem.name)
3b22ff
+
3b22ff
+        else:
3b22ff
+            # Fix existing path
3b22ff
+            logger.info("Fixing profile.caECAdminCert.config")
3b22ff
+            dirname = os.path.dirname(path)
3b22ff
+            path = os.path.join(dirname, 'caECAdminCert.cfg')
3b22ff
+
3b22ff
+        logger.info('New path: %s', path)
3b22ff
+        subsystem.config['profile.caECAdminCert.config'] = path
3b22ff
+
3b22ff
+        subsystem.config['profile.caECAdminCert.class_id'] = 'caEnrollImpl'
3b22ff
+
3b22ff
+        # check if caECAdminCert is part of profile.list
3b22ff
+        profile_list = subsystem.config['profile.list'].split(',')
3b22ff
+        if 'caECAdminCert' not in profile_list:
3b22ff
+            profile_list.append('caECAdminCert')
3b22ff
+            subsystem.config['profile.list'] = ','.join(profile_list)
3b22ff
+
3b22ff
+        subsystem.save()
3b22ff
-- 
3b22ff
2.23.0
3b22ff