summaryrefslogtreecommitdiffstats
path: root/base/server/upgrade
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2017-01-19 21:43:24 +0100
committerEndi S. Dewata <edewata@redhat.com>2017-01-20 01:35:30 +0100
commitcb839206d6c1d562e2e4385f6822c7934e9455c6 (patch)
treec48041a26a97c242bad7e7c5be5e8cf12f891311 /base/server/upgrade
parentaec3e5e7206a076d9218e6038df6b7451ed3c5f1 (diff)
downloadpki-cb839206d6c1d562e2e4385f6822c7934e9455c6.tar.gz
pki-cb839206d6c1d562e2e4385f6822c7934e9455c6.tar.xz
pki-cb839206d6c1d562e2e4385f6822c7934e9455c6.zip
Added upgrade script to update AJP loopback address.
An upgrade script has been added to replace IPv4- and IPv6-specific AJP loopback address with a more generic "localhost" in existing instances. https://fedorahosted.org/pki/ticket/2570
Diffstat (limited to 'base/server/upgrade')
-rwxr-xr-xbase/server/upgrade/10.4.0/01-UpdateAJPLoopbackAddress62
1 files changed, 62 insertions, 0 deletions
diff --git a/base/server/upgrade/10.4.0/01-UpdateAJPLoopbackAddress b/base/server/upgrade/10.4.0/01-UpdateAJPLoopbackAddress
new file mode 100755
index 000000000..b7d5c0e44
--- /dev/null
+++ b/base/server/upgrade/10.4.0/01-UpdateAJPLoopbackAddress
@@ -0,0 +1,62 @@
+#!/usr/bin/python
+# Authors:
+# Endi S. Dewata <edewata@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) 2017 Red Hat, Inc.
+# All rights reserved.
+#
+
+from __future__ import absolute_import
+import os
+from lxml import etree
+
+import pki
+
+
+class UpdateAJPLoopbackAddress(
+ pki.server.upgrade.PKIServerUpgradeScriptlet):
+
+ def __init__(self):
+ super(UpdateAJPLoopbackAddress, self).__init__()
+ self.message = 'Update AJP loopback address'
+
+ self.parser = etree.XMLParser(remove_blank_text=True)
+
+ def upgrade_instance(self, instance):
+
+ server_xml = os.path.join(instance.conf_dir, 'server.xml')
+ self.backup(server_xml)
+
+ document = etree.parse(server_xml, self.parser)
+
+ server = document.getroot()
+ connectors = server.findall('.//Connector')
+
+ # replace IPv4- or IPv6-specific AJP loopback address with localhost
+ for connector in connectors:
+
+ protocol = connector.get('protocol')
+ if protocol != 'AJP/1.3':
+ continue
+
+ address = connector.get('address')
+ if address != '127.0.0.1' and address != '::1':
+ continue
+
+ connector.set('address', 'localhost')
+
+ with open(server_xml, 'wb') as f:
+ document.write(f, pretty_print=True, encoding='utf-8')