summaryrefslogtreecommitdiffstats
path: root/base/server
diff options
context:
space:
mode:
authorJack Magne <jmagne@localhost.localdomain>2015-07-14 10:07:10 -0700
committerJack Magne <jmagne@localhost.localdomain>2015-07-16 19:11:12 -0700
commit5952c616ad8dd271af7ceaa19f84dd81ca3be34d (patch)
tree6a771fa482c6529487d593978bda37745d6afb79 /base/server
parenta499bee6d673be26faeb08f83e356e6d80a816aa (diff)
downloadpki-5952c616ad8dd271af7ceaa19f84dd81ca3be34d.tar.gz
pki-5952c616ad8dd271af7ceaa19f84dd81ca3be34d.tar.xz
pki-5952c616ad8dd271af7ceaa19f84dd81ca3be34d.zip
TPS add phone home URLs to pkidaemon status message.
Ticket # 1466 . Also remove some needless copies of server.xml from the code.
Diffstat (limited to 'base/server')
-rw-r--r--base/server/scripts/operations4
-rw-r--r--base/server/tomcat7/conf/server.xml2
-rw-r--r--base/server/tomcat8/conf/server.xml2
-rwxr-xr-xbase/server/upgrade/10.2.6/02-AddPhoneHomeURLsToTPSsServerXML112
4 files changed, 120 insertions, 0 deletions
diff --git a/base/server/scripts/operations b/base/server/scripts/operations
index 8fa58e1ba..ede5f8229 100644
--- a/base/server/scripts/operations
+++ b/base/server/scripts/operations
@@ -488,6 +488,8 @@ get_pki_status_definitions_tomcat()
secure_admin_url_statement="Secure Admin URL"
pki_console_command_statement="PKI Console Command"
tomcat_port_statement="Tomcat Port"
+ unsecure_phone_home_statement="Unsecure PHONE HOME"
+ secure_phone_home_statement="Secure PHONE HOME"
# initialize looping variables
pki_status_comment_found=0
@@ -615,6 +617,8 @@ get_pki_status_definitions_tomcat()
[ "$head" == "$secure_admin_url_statement" ] ||
[ "$head" == "$secure_ee_client_auth_url_statement" ] ||
[ "$head" == "$pki_console_command_statement" ] ||
+ [ "$head" == "$unsecure_phone_home_statement" ] ||
+ [ "$head" == "$secure_phone_home_statement" ] ||
[ "$head" == "$tomcat_port_statement" ] ; then
echo " $line"
total_ports=`expr ${total_ports} + 1`
diff --git a/base/server/tomcat7/conf/server.xml b/base/server/tomcat7/conf/server.xml
index c52bd5bab..81a801628 100644
--- a/base/server/tomcat7/conf/server.xml
+++ b/base/server/tomcat7/conf/server.xml
@@ -64,6 +64,8 @@ Tomcat Port = [TOMCAT_SERVER_PORT] (for shutdown)
<!--
Unsecure URL = http://[PKI_HOSTNAME]:[PKI_UNSECURE_PORT]/tps
Secure URL = https://[PKI_HOSTNAME]:[PKI_SECURE_PORT]/tps
+Unsecure PHONE HOME = http://[PKI_HOSTNAME]:[PKI_UNSECURE_PORT]/tps/phoneHome
+Secure PHONE HOME = https://[PKI_HOSTNAME]:[PKI_SECURE_PORT]/tps/phoneHome
Tomcat Port = [TOMCAT_SERVER_PORT] (for shutdown)
-->
<!-- DO NOT REMOVE - End PKI Status Definitions -->
diff --git a/base/server/tomcat8/conf/server.xml b/base/server/tomcat8/conf/server.xml
index a794760d8..c482fc138 100644
--- a/base/server/tomcat8/conf/server.xml
+++ b/base/server/tomcat8/conf/server.xml
@@ -64,6 +64,8 @@ Tomcat Port = [TOMCAT_SERVER_PORT] (for shutdown)
<!--
Unsecure URL = http://[PKI_HOSTNAME]:[PKI_UNSECURE_PORT]/tps
Secure URL = https://[PKI_HOSTNAME]:[PKI_SECURE_PORT]/tps
+Unsecure PHONE HOME = http://[PKI_HOSTNAME]:[PKI_UNSECURE_PORT]/tps/phoneHome
+Secure PHONE HOME = https://[PKI_HOSTNAME]:[PKI_SECURE_PORT]/tps/phoneHome
Tomcat Port = [TOMCAT_SERVER_PORT] (for shutdown)
-->
<!-- DO NOT REMOVE - End PKI Status Definitions -->
diff --git a/base/server/upgrade/10.2.6/02-AddPhoneHomeURLsToTPSsServerXML b/base/server/upgrade/10.2.6/02-AddPhoneHomeURLsToTPSsServerXML
new file mode 100755
index 000000000..1cf7413ed
--- /dev/null
+++ b/base/server/upgrade/10.2.6/02-AddPhoneHomeURLsToTPSsServerXML
@@ -0,0 +1,112 @@
+#!/usr/bin/python
+# Authors:
+# Matthew Harmsen <mharmsen@redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2015 Red Hat, Inc.
+# All rights reserved.
+#
+
+import os
+
+import pki.server.upgrade
+
+
+class AddPhoneHomeURLsToTPSsServerXML(
+ pki.server.upgrade.PKIServerUpgradeScriptlet):
+ def __init__(self):
+ super(AddPhoneHomeURLsToTPSsServerXML, self).__init__()
+ self.message = 'Add Phone Home URLs to TPS section of server.xml.'
+
+ def upgrade_instance(self, instance):
+ server_xml = os.path.join(instance.conf_dir, 'server.xml')
+ # Backup
+ self.backup(server_xml)
+
+ # Simply read in the document by lines
+
+ with open(server_xml) as f:
+ content = f.readlines()
+ f.close()
+
+ tps_statuses_pattern = "<!-- TPS Status Definitions -->"
+ tps_end_statuses_pattern = "-->"
+ tps_unsecure_phone_home_pattern = "Unsecure PHONE HOME"
+ tps_secure_phone_home_pattern = "Secure PHONE HOME"
+ tps_secure_url_pattern = "Secure URL"
+ tps_unsecure_url_pattern = "Unsecure URL"
+ tps_phone_home_path = "phoneHome"
+
+ tps_secure_url = None
+ tps_unsecure_url = None
+
+ found_tps_statuses = -1
+ # loop through file, looking for TPS settings
+
+ rewrite_server_xml = False
+ final_content = []
+ for index, line in enumerate(content):
+
+ if found_tps_statuses == -1:
+ found_tps_statuses = line.find(tps_statuses_pattern)
+ else:
+ if line.find(tps_unsecure_phone_home_pattern) != -1:
+ # already upgraded, abort
+ break
+ if line.find(tps_secure_phone_home_pattern) != -1:
+ # already upgraded, abort
+ break
+
+ if line.find(tps_unsecure_url_pattern) != -1:
+ splits = line.split("=")
+ if len(splits) == 2:
+ tps_unsecure_url = splits[1].strip()
+
+ if line.find(tps_secure_url_pattern) != -1:
+ splits = line.split("=")
+ if len(splits) == 2:
+ tps_secure_url = splits[1].strip()
+
+ if line.find(tps_end_statuses_pattern) != -1:
+ if tps_unsecure_url and tps_secure_url:
+ # Create the added lines we need
+ # Phone home url is simply a super set of the base url
+ unsec_phone_home_url = tps_unsecure_phone_home_pattern + \
+ ' = ' + tps_unsecure_url + \
+ '/' + tps_phone_home_path + '\n'
+ sec_phone_home_url = tps_secure_phone_home_pattern + \
+ ' = ' + tps_secure_url + \
+ '/' + tps_phone_home_path + '\n'
+ # Spot to add the URLs
+ final_content.append(unsec_phone_home_url)
+ final_content.append(sec_phone_home_url)
+ # Just write the rest of the original to the copy
+ final_content.extend(content[index:])
+ # Indicate that we want to update the server.xml
+ rewrite_server_xml = True
+ # Done
+ break
+ else:
+ # Just give up
+ break
+
+ final_content.append(line)
+
+ # Rewrite the file if needed
+ if rewrite_server_xml:
+ with open(server_xml, 'w') as fout:
+ for line_out in final_content:
+ fout.write(line_out)
+ fout.close()