From 4a50b46a387cc3c581c8a7bf2d24c0124c279f59 Mon Sep 17 00:00:00 2001
From: Matthew Harmsen <mharmsen@redhat.com>
Date: Fri, 6 Sep 2013 19:11:47 -0700
Subject: [PATCH] TRAC Ticket #707 - Do not "require" the following pkispawn
 parameters for                    GUI-based configuration

---
 .../python/pki/server/deployment/pkihelper.py      | 42 ++++++++++++----------
 base/server/sbin/pkispawn                          | 20 +++++++++++
 2 files changed, 43 insertions(+), 19 deletions(-)

diff --git a/base/server/python/pki/server/deployment/pkihelper.py b/base/server/python/pki/server/deployment/pkihelper.py
index 9bbe810..9257cbf 100644
--- a/base/server/python/pki/server/deployment/pkihelper.py
+++ b/base/server/python/pki/server/deployment/pkihelper.py
@@ -452,15 +452,17 @@ class ConfigurationFile:
     def verify_sensitive_data(self):
         # Silently verify the existence of 'sensitive' data
         if self.master_dict['pki_subsystem'] in config.PKI_TOMCAT_SUBSYSTEMS:
-            # Verify existence of Directory Server Password (ALWAYS)
-            if not self.master_dict.has_key('pki_ds_password') or\
-               not len(self.master_dict['pki_ds_password']):
-                config.pki_log.error(
-                    log.PKIHELPER_UNDEFINED_CONFIGURATION_FILE_ENTRY_2,
-                    "pki_ds_password",
-                    self.master_dict['pki_user_deployment_cfg'],
-                    extra=config.PKI_INDENTATION_LEVEL_2)
-                raise Exception(log.PKIHELPER_UNDEFINED_CONFIGURATION_FILE_ENTRY_2 % ("pki_ds_password",
+            # Verify existence of Directory Server Password
+            # (unless configuration will not be automatically executed)
+            if not config.str2bool(self.master_dict['pki_skip_configuration']):
+                if not self.master_dict.has_key('pki_ds_password') or\
+                   not len(self.master_dict['pki_ds_password']):
+                    config.pki_log.error(
+                        log.PKIHELPER_UNDEFINED_CONFIGURATION_FILE_ENTRY_2,
+                        "pki_ds_password",
+                        self.master_dict['pki_user_deployment_cfg'],
+                        extra=config.PKI_INDENTATION_LEVEL_2)
+                    raise Exception(log.PKIHELPER_UNDEFINED_CONFIGURATION_FILE_ENTRY_2 % ("pki_ds_password",
                                                                                      self.master_dict['pki_user_deployment_cfg']))
             # Verify existence of Admin Password (except for Clones)
             if not config.str2bool(self.master_dict['pki_clone']):
@@ -515,19 +517,21 @@ class ConfigurationFile:
                         extra=config.PKI_INDENTATION_LEVEL_2)
                     raise Exception(log.PKIHELPER_UNDEFINED_CONFIGURATION_FILE_ENTRY_2 % ("pki_clone_pkcs12_password",
                                                                                          self.master_dict['pki_user_deployment_cfg']))
-            # Verify existence of Security Domain Password File
-            # (ONLY for Clones, KRA, OCSP, TKS, TPS, or Subordinate CA)
+            # Verify existence of Security Domain Password
+            # (ONLY for Clones, KRA, OCSP, TKS, TPS, or Subordinate CA
+            #  that will be automatically configured)
             if config.str2bool(self.master_dict['pki_clone']) or\
                not self.master_dict['pki_subsystem'] == "CA" or\
                config.str2bool(self.master_dict['pki_subordinate']):
-                if not self.master_dict.has_key('pki_security_domain_password') or\
-                   not len(self.master_dict['pki_security_domain_password']):
-                    config.pki_log.error(
-                        log.PKIHELPER_UNDEFINED_CONFIGURATION_FILE_ENTRY_2,
-                        "pki_security_domain_password",
-                        self.master_dict['pki_user_deployment_cfg'],
-                        extra=config.PKI_INDENTATION_LEVEL_2)
-                    raise Exception(log.PKIHELPER_UNDEFINED_CONFIGURATION_FILE_ENTRY_2 % ("pki_security_domain_password",
+                if not config.str2bool(self.master_dict['pki_skip_configuration']):
+                    if not self.master_dict.has_key('pki_security_domain_password') or\
+                       not len(self.master_dict['pki_security_domain_password']):
+                        config.pki_log.error(
+                            log.PKIHELPER_UNDEFINED_CONFIGURATION_FILE_ENTRY_2,
+                            "pki_security_domain_password",
+                            self.master_dict['pki_user_deployment_cfg'],
+                            extra=config.PKI_INDENTATION_LEVEL_2)
+                        raise Exception(log.PKIHELPER_UNDEFINED_CONFIGURATION_FILE_ENTRY_2 % ("pki_security_domain_password",
                                                                                           self.master_dict['pki_user_deployment_cfg']))
             # If required, verify existence of Token Password
             if not self.master_dict['pki_token_name'] == "internal":
diff --git a/base/server/sbin/pkispawn b/base/server/sbin/pkispawn
index 988dd60..72841c9 100755
--- a/base/server/sbin/pkispawn
+++ b/base/server/sbin/pkispawn
@@ -327,6 +327,16 @@ def main(argv):
     if not interactive and\
         not config.str2bool(parser.pki_master_dict['pki_skip_configuration']):
         try:
+            # Verify existence of Directory Server Password
+            if not parser.pki_master_dict.has_key('pki_ds_password') or\
+               not len(parser.pki_master_dict['pki_ds_password']):
+                config.pki_log.error(
+                    log.PKIHELPER_UNDEFINED_CONFIGURATION_FILE_ENTRY_2,
+                    "pki_ds_password",
+                    parser.pki_master_dict['pki_user_deployment_cfg'],
+                    extra=config.PKI_INDENTATION_LEVEL_0)
+                sys.exit(1)
+
             parser.ds_connect()
             parser.ds_bind()
 
@@ -345,6 +355,16 @@ def main(argv):
             config.str2bool(parser.pki_master_dict['pki_clone']) or\
             config.str2bool(parser.pki_master_dict['pki_subordinate']):
             try:
+                # Verify existence of Security Domain Password
+                if not parser.pki_master_dict.has_key('pki_security_domain_password') or\
+                   not len(parser.pki_master_dict['pki_security_domain_password']):
+                    config.pki_log.error(
+                        log.PKIHELPER_UNDEFINED_CONFIGURATION_FILE_ENTRY_2,
+                        "pki_security_domain_password",
+                        parser.pki_master_dict['pki_user_deployment_cfg'],
+                        extra=config.PKI_INDENTATION_LEVEL_0)
+                    sys.exit(1)
+
                 parser.sd_connect()
                 info = parser.sd_get_info()
                 parser.set_property(config.pki_subsystem, 'pki_security_domain_name', info.name)
-- 
1.8.2.1

