Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |