summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorMatthew Harmsen <mharmsen@redhat.com>2017-05-17 17:17:42 -0600
committerMatthew Harmsen <mharmsen@redhat.com>2017-05-17 17:17:42 -0600
commitea036b22d7d15cefb8f7a56e9c9781b545dec8ee (patch)
treeeab8c10c51a95a8bfdbbb786be1405ca3a110e69 /base
parent0af026413a65386a0e8c8aba81fe667412ef7f0d (diff)
downloadpki-ea036b22d7d15cefb8f7a56e9c9781b545dec8ee.tar.gz
pki-ea036b22d7d15cefb8f7a56e9c9781b545dec8ee.tar.xz
pki-ea036b22d7d15cefb8f7a56e9c9781b545dec8ee.zip
Correct section headings in user deployment configuration file
Bugzilla Bug #1447144 - CA brought down during separate KRA instance creation dogtagpki Pagure Issue #2674 - CA brought down during separate KRA instance creation
Diffstat (limited to 'base')
-rwxr-xr-xbase/server/sbin/pkispawn39
1 files changed, 39 insertions, 0 deletions
diff --git a/base/server/sbin/pkispawn b/base/server/sbin/pkispawn
index 9394b8e47..9e2ebc812 100755
--- a/base/server/sbin/pkispawn
+++ b/base/server/sbin/pkispawn
@@ -30,9 +30,12 @@ if not hasattr(sys, "hexversion") or sys.hexversion < 0x020700f0:
print("Please upgrade to at least Python 2.7.0.")
sys.exit(1)
try:
+ import fileinput
import ldap
import os
import requests
+ import time
+ from time import strftime as date
import traceback
import pki
from pki.server.deployment import pkiconfig as config
@@ -105,6 +108,8 @@ def main(argv):
interactive = True
parser.indent = 0
print(log.PKISPAWN_INTERACTIVE_INSTALLATION)
+ else:
+ sanitize_user_deployment_cfg(config.user_deployment_cfg)
# Only run this program as "root".
if not os.geteuid() == 0:
@@ -574,6 +579,40 @@ def main(argv):
print_final_install_information(parser.mdict)
+def sanitize_user_deployment_cfg(cfg):
+ # Generate a timestamp
+ ticks = time.time()
+ timestamp = date('%Y%m%d%H%M%S', time.localtime(ticks))
+
+ # Correct any section headings in the user's configuration file
+ for line in fileinput.FileInput(cfg, inplace=1, backup='.' + timestamp):
+ # Remove extraneous leading and trailing whitespace from all lines
+ line = line.strip()
+ # Normalize section headings to match '/etc/pki/default.cfg'
+ if line.startswith("["):
+ if line.upper().startswith("[DEFAULT"):
+ line = "[DEFAULT]"
+ elif line.upper().startswith("[TOMCAT"):
+ line = "[Tomcat]"
+ elif line.upper().startswith("[CA"):
+ line = "[CA]"
+ elif line.upper().startswith("[KRA"):
+ line = "[KRA]"
+ elif line.upper().startswith("[OCSP"):
+ line = "[OCSP]"
+ elif line.upper().startswith("[RA"):
+ line = "[RA]"
+ elif line.upper().startswith("[TKS"):
+ line = "[TKS]"
+ elif line.upper().startswith("[TPS"):
+ line = "[TPS]"
+ else:
+ # Notify user of the existence of an invalid section heading
+ sys.stderr.write("'%s' contains an invalid section "
+ "heading called '%s'!\n" % (cfg, line))
+ print(line)
+
+
def start_logging():
# Enable 'pkispawn' logging.
config.pki_log_dir = config.pki_root_prefix + \