From 71061059a6c56bad818cb379070ef742bbe517a3 Mon Sep 17 00:00:00 2001
From: Stanislav Laznicka <slaznick@redhat.com>
Date: Mon, 3 Apr 2017 14:08:46 +0200
Subject: [PATCH] Add pki_pin only when needed
If both the pki-tomcat NSS database and its password.conf have been
created, don't try to override the password.conf file.
https://pagure.io/freeipa/issue/6839
Reviewed-By: Tomas Krizek <tkrizek@redhat.com>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
---
ipaserver/install/cainstance.py | 10 +++++++---
ipaserver/install/krainstance.py | 10 +++++++---
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/ipaserver/install/cainstance.py b/ipaserver/install/cainstance.py
index 92bb760d39d23fedb40b7e3c5bea53381f1c87ad..3980e412603437b0db5804623f6626d11e52c009 100644
--- a/ipaserver/install/cainstance.py
+++ b/ipaserver/install/cainstance.py
@@ -541,9 +541,13 @@ class CAInstance(DogtagInstance):
# CA key algorithm
config.set("CA", "pki_ca_signing_key_algorithm", self.ca_signing_algorithm)
- # generate pin which we know can be used for FIPS NSS database
- pki_pin = ipautil.ipa_generate_password()
- config.set("CA", "pki_pin", pki_pin)
+ if not (os.path.isdir(paths.PKI_TOMCAT_ALIAS_DIR) and
+ os.path.isfile(paths.PKI_TOMCAT_PASSWORD_CONF)):
+ # generate pin which we know can be used for FIPS NSS database
+ pki_pin = ipautil.ipa_generate_password()
+ config.set("CA", "pki_pin", pki_pin)
+ else:
+ pki_pin = None
if self.clone:
diff --git a/ipaserver/install/krainstance.py b/ipaserver/install/krainstance.py
index 34d667857a8055752e258a591af983190f33daa5..fc25ac72b0dc593f06a8b070b67b5d54a0ab8bce 100644
--- a/ipaserver/install/krainstance.py
+++ b/ipaserver/install/krainstance.py
@@ -235,9 +235,13 @@ class KRAInstance(DogtagInstance):
"KRA", "pki_share_dbuser_dn",
str(DN(('uid', 'pkidbuser'), ('ou', 'people'), ('o', 'ipaca'))))
- # generate pin which we know can be used for FIPS NSS database
- pki_pin = ipautil.ipa_generate_password()
- config.set("KRA", "pki_pin", pki_pin)
+ if not (os.path.isdir(paths.PKI_TOMCAT_ALIAS_DIR) and
+ os.path.isfile(paths.PKI_TOMCAT_PASSWORD_CONF)):
+ # generate pin which we know can be used for FIPS NSS database
+ pki_pin = ipautil.ipa_generate_password()
+ config.set("KRA", "pki_pin", pki_pin)
+ else:
+ pki_pin = None
_p12_tmpfile_handle, p12_tmpfile_name = tempfile.mkstemp(dir=paths.TMP)
--
2.9.3