URL: https://github.com/freeipa/freeipa/pull/5992
Author: fcami
 Title: #5992: [Backport][ipa-4-9] Specify PKI installation log paths
Action: opened

PR body:
"""
This PR was opened automatically because PR #5973 was pushed to master and 
backport to ipa-4-9 is required.
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/5992/head:pr5992
git checkout pr5992
From 4a3bb18c76b752b9442cae99887e630818a74d1a Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edew...@redhat.com>
Date: Thu, 12 Aug 2021 13:26:42 -0500
Subject: [PATCH] Specify PKI installation log paths

The DogtagInstance.spawn_instance() and uninstall() have
been modified to specify the paths of PKI installation
logs using --log-file option on PKI 11.0.0 or later.

This allows IPA to have a full control over the log files
instead of relying on PKI's default log files.

Fixes: https://pagure.io/freeipa/issue/8966
Signed-off-by: Endi Sukma Dewata <edew...@redhat.com>
---
 ipaserver/install/dogtaginstance.py | 35 ++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/ipaserver/install/dogtaginstance.py b/ipaserver/install/dogtaginstance.py
index 644acd4eace..0d9aebb542f 100644
--- a/ipaserver/install/dogtaginstance.py
+++ b/ipaserver/install/dogtaginstance.py
@@ -36,8 +36,10 @@
 
 import six
 
+import pki
 from pki.client import PKIConnection
 import pki.system
+import pki.util
 
 from ipalib import api, errors, x509
 from ipalib.install import certmonger
@@ -202,6 +204,18 @@ def spawn_instance(self, cfg_file, nolog_list=()):
                 "-f", cfg_file,
                 "--debug"]
 
+        # specify --log-file <path> on PKI 11.0.0 or later
+
+        pki_version = pki.util.Version(pki.specification_version())
+        if pki_version >= pki.util.Version("11.0.0"):
+            timestamp = time.strftime(
+                "%Y%m%d%H%M%S",
+                time.localtime(time.time()))
+            log_file = os.path.join(
+                paths.VAR_LOG_PKI_DIR,
+                "pki-%s-spawn.%s.log" % (self.subsystem.lower(), timestamp))
+            args.extend(["--log-file", log_file])
+
         with open(cfg_file) as f:
             logger.debug(
                 'Contents of pkispawn configuration file (%s):\n%s',
@@ -290,10 +304,25 @@ def uninstall(self):
         if self.is_installed():
             self.print_msg("Unconfiguring %s" % self.subsystem)
 
+        args = [paths.PKIDESTROY,
+                "-i", "pki-tomcat",
+                "-s", self.subsystem]
+
+        # specify --log-file <path> on PKI 11.0.0 or later
+
+        pki_version = pki.util.Version(pki.specification_version())
+        if pki_version >= pki.util.Version("11.0.0"):
+            timestamp = time.strftime(
+                "%Y%m%d%H%M%S",
+                time.localtime(time.time()))
+            log_file = os.path.join(
+                paths.VAR_LOG_PKI_DIR,
+                "pki-%s-destroy.%s.log" % (self.subsystem.lower(), timestamp))
+            args.extend(["--log-file", log_file])
+
         try:
-            ipautil.run([paths.PKIDESTROY,
-                         "-i", 'pki-tomcat',
-                         "-s", self.subsystem])
+            ipautil.run(args)
+
         except ipautil.CalledProcessError as e:
             logger.critical("failed to uninstall %s instance %s",
                             self.subsystem, e)
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/freeipa-devel@lists.fedorahosted.org
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure

Reply via email to