mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 08:08:00 +02:00
Merge pull request #2314 from letsencrypt/rpm-apache22
Small Apache 2.2 fixes
This commit is contained in:
@@ -874,9 +874,15 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||||||
# See if the exact address appears in any other vhost
|
# See if the exact address appears in any other vhost
|
||||||
# Remember 1.1.1.1:* == 1.1.1.1 -> hence any()
|
# Remember 1.1.1.1:* == 1.1.1.1 -> hence any()
|
||||||
for addr in vhost.addrs:
|
for addr in vhost.addrs:
|
||||||
|
# In Apache 2.2, when a NameVirtualHost directive is not
|
||||||
|
# set, "*" and "_default_" will conflict when sharing a port
|
||||||
|
if addr.get_addr() in ("*", "_default_"):
|
||||||
|
addrs = [obj.Addr((a, addr.get_port(),))
|
||||||
|
for a in ("*", "_default_")]
|
||||||
|
|
||||||
for test_vh in self.vhosts:
|
for test_vh in self.vhosts:
|
||||||
if (vhost.filep != test_vh.filep and
|
if (vhost.filep != test_vh.filep and
|
||||||
any(test_addr == addr for
|
any(test_addr in addrs for
|
||||||
test_addr in test_vh.addrs) and
|
test_addr in test_vh.addrs) and
|
||||||
not self.is_name_vhost(addr)):
|
not self.is_name_vhost(addr)):
|
||||||
self.add_name_vhost(addr)
|
self.add_name_vhost(addr)
|
||||||
|
|||||||
@@ -597,7 +597,7 @@ class ApacheParser(object):
|
|||||||
.. todo:: Make sure that files are included
|
.. todo:: Make sure that files are included
|
||||||
|
|
||||||
"""
|
"""
|
||||||
default = self._set_user_config_file()
|
default = self.loc["root"]
|
||||||
|
|
||||||
temp = os.path.join(self.root, "ports.conf")
|
temp = os.path.join(self.root, "ports.conf")
|
||||||
if os.path.isfile(temp):
|
if os.path.isfile(temp):
|
||||||
@@ -618,23 +618,6 @@ class ApacheParser(object):
|
|||||||
|
|
||||||
raise errors.NoInstallationError("Could not find configuration root")
|
raise errors.NoInstallationError("Could not find configuration root")
|
||||||
|
|
||||||
def _set_user_config_file(self):
|
|
||||||
"""Set the appropriate user configuration file
|
|
||||||
|
|
||||||
.. todo:: This will have to be updated for other distros versions
|
|
||||||
|
|
||||||
:param str root: pathname which contains the user config
|
|
||||||
|
|
||||||
"""
|
|
||||||
# Basic check to see if httpd.conf exists and
|
|
||||||
# in hierarchy via direct include
|
|
||||||
# httpd.conf was very common as a user file in Apache 2.2
|
|
||||||
if (os.path.isfile(os.path.join(self.root, "httpd.conf")) and
|
|
||||||
self.find_dir("Include", "httpd.conf", self.loc["root"])):
|
|
||||||
return os.path.join(self.root, "httpd.conf")
|
|
||||||
else:
|
|
||||||
return os.path.join(self.root, "apache2.conf")
|
|
||||||
|
|
||||||
|
|
||||||
def case_i(string):
|
def case_i(string):
|
||||||
"""Returns case insensitive regex.
|
"""Returns case insensitive regex.
|
||||||
|
|||||||
@@ -606,6 +606,14 @@ class TwoVhost80Test(util.ApacheTest):
|
|||||||
self.config._add_name_vhost_if_necessary(self.vh_truth[0])
|
self.config._add_name_vhost_if_necessary(self.vh_truth[0])
|
||||||
self.assertTrue(self.config.save.called)
|
self.assertTrue(self.config.save.called)
|
||||||
|
|
||||||
|
new_addrs = set()
|
||||||
|
for addr in self.vh_truth[0].addrs:
|
||||||
|
new_addrs.add(obj.Addr(("_default_", addr.get_port(),)))
|
||||||
|
|
||||||
|
self.vh_truth[0].addrs = new_addrs
|
||||||
|
self.config._add_name_vhost_if_necessary(self.vh_truth[0])
|
||||||
|
self.assertEqual(self.config.save.call_count, 2)
|
||||||
|
|
||||||
@mock.patch("letsencrypt_apache.configurator.tls_sni_01.ApacheTlsSni01.perform")
|
@mock.patch("letsencrypt_apache.configurator.tls_sni_01.ApacheTlsSni01.perform")
|
||||||
@mock.patch("letsencrypt_apache.configurator.ApacheConfigurator.restart")
|
@mock.patch("letsencrypt_apache.configurator.ApacheConfigurator.restart")
|
||||||
def test_perform(self, mock_restart, mock_perform):
|
def test_perform(self, mock_restart, mock_perform):
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ class BasicParserTest(util.ParserTest):
|
|||||||
def test_set_locations(self):
|
def test_set_locations(self):
|
||||||
with mock.patch("letsencrypt_apache.parser.os.path") as mock_path:
|
with mock.patch("letsencrypt_apache.parser.os.path") as mock_path:
|
||||||
|
|
||||||
mock_path.isfile.side_effect = [True, False, False]
|
mock_path.isfile.side_effect = [False, False]
|
||||||
|
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
results = self.parser._set_locations()
|
results = self.parser._set_locations()
|
||||||
@@ -114,16 +114,6 @@ class BasicParserTest(util.ParserTest):
|
|||||||
self.assertEqual(results["default"], results["listen"])
|
self.assertEqual(results["default"], results["listen"])
|
||||||
self.assertEqual(results["default"], results["name"])
|
self.assertEqual(results["default"], results["name"])
|
||||||
|
|
||||||
def test_set_user_config_file(self):
|
|
||||||
# pylint: disable=protected-access
|
|
||||||
path = os.path.join(self.parser.root, "httpd.conf")
|
|
||||||
open(path, 'w').close()
|
|
||||||
self.parser.add_dir(self.parser.loc["default"], "Include",
|
|
||||||
"httpd.conf")
|
|
||||||
|
|
||||||
self.assertEqual(
|
|
||||||
path, self.parser._set_user_config_file())
|
|
||||||
|
|
||||||
@mock.patch("letsencrypt_apache.parser.ApacheParser._get_runtime_cfg")
|
@mock.patch("letsencrypt_apache.parser.ApacheParser._get_runtime_cfg")
|
||||||
def test_update_runtime_variables(self, mock_cfg):
|
def test_update_runtime_variables(self, mock_cfg):
|
||||||
mock_cfg.return_value = (
|
mock_cfg.return_value = (
|
||||||
|
|||||||
Reference in New Issue
Block a user