From 95fad04fdd69c8768ff126bdd7b43fa76c6151b1 Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Sat, 30 Jul 2016 10:39:35 +0300 Subject: [PATCH 01/17] Added method to get the LIKE var contents as a list --- certbot/util.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/certbot/util.py b/certbot/util.py index 65aae59e2..1d3e5953c 100644 --- a/certbot/util.py +++ b/certbot/util.py @@ -268,6 +268,19 @@ def get_systemd_os_info(filepath="/etc/os-release"): return (os_name, os_version) +def get_systemd_os_like(filepath="/etc/os-release"): + """ + Get a list of strings that indicate the distribution likeness to + other distributions. + + :param str filepath: File path of os-release file + :returns: List of distribution acronyms + :rtype: `list` of `str` + """ + + return _get_systemd_os_release_var("LIKE", filepath).split(" ") + + def _get_systemd_os_release_var(varname, filepath="/etc/os-release"): """ Get single value from systemd /etc/os-release From a5859910e757667b573b9675f0e6c9d546e7c46c Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Sat, 30 Jul 2016 10:43:38 +0300 Subject: [PATCH 02/17] If os name is not found, try LIKE var from os-release --- certbot-apache/certbot_apache/constants.py | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/certbot-apache/certbot_apache/constants.py b/certbot-apache/certbot_apache/constants.py index 9252814c4..a65a12c5e 100644 --- a/certbot-apache/certbot_apache/constants.py +++ b/certbot-apache/certbot_apache/constants.py @@ -115,13 +115,36 @@ HEADER_ARGS = {"Strict-Transport-Security": HSTS_ARGS, def os_constant(key): - """Get a constant value for operating system + """ + Get a constant value for operating system + :param key: name of cli constant :return: value of constant for active os """ + os_info = util.get_os_info() try: constants = CLI_DEFAULTS[os_info[0].lower()] except KeyError: - constants = CLI_DEFAULTS["debian"] + constants = os_like_constants() + if not constants: + constants = CLI_DEFAULTS["default"] return constants[key] + + +def os_like_constants(): + """ + Try to get constants for distribution with + similar layout and configuration, indicated by + /etc/os-release variable "LIKE" + + :returns: Constants dictionary + :rtype: `dict` + """ + + os_like = util.get_systemd_os_like() + if os_like: + for os_name in os_like: + if os_name in CLI_DEFAULTS.keys(): + return CLI_DEFAULTS[os_name] + return {} From c87282d5aa8e0eb0762bbf5804edf0b32563721c Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Sat, 30 Jul 2016 10:44:46 +0300 Subject: [PATCH 03/17] Un-debian the defaults --- certbot-apache/certbot_apache/constants.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/certbot-apache/certbot_apache/constants.py b/certbot-apache/certbot_apache/constants.py index a65a12c5e..d4ec2d8a8 100644 --- a/certbot-apache/certbot_apache/constants.py +++ b/certbot-apache/certbot_apache/constants.py @@ -2,7 +2,23 @@ import pkg_resources from certbot import util - +CLI_DEFAULTS_DEFAULT = dict( + server_root="/etc/apache2", + vhost_root="/etc/apache2/sites-available", + vhost_files="*", + version_cmd=['apache2ctl', '-v'], + define_cmd=['apache2ctl', '-t', '-D', 'DUMP_RUN_CFG'], + restart_cmd=['apache2ctl', 'graceful'], + conftest_cmd=['apache2ctl', 'configtest'], + enmod="a2enmod", + dismod="a2dismod", + le_vhost_ext="-le-ssl.conf", + handle_mods=False, + handle_sites=False, + challenge_location="/etc/apache2", + MOD_SSL_CONF_SRC=pkg_resources.resource_filename( + "certbot_apache", "options-ssl-apache.conf") +) CLI_DEFAULTS_DEBIAN = dict( server_root="/etc/apache2", vhost_root="/etc/apache2/sites-available", @@ -72,6 +88,7 @@ CLI_DEFAULTS_DARWIN = dict( "certbot_apache", "options-ssl-apache.conf") ) CLI_DEFAULTS = { + "default": CLI_DEFAULTS_DEFAULT, "debian": CLI_DEFAULTS_DEBIAN, "ubuntu": CLI_DEFAULTS_DEBIAN, "centos": CLI_DEFAULTS_CENTOS, From 63a47f8b6baf53e194194798d992890f56bd30c2 Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Sat, 30 Jul 2016 11:07:04 +0300 Subject: [PATCH 04/17] Fix variable name --- certbot/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/certbot/util.py b/certbot/util.py index 1d3e5953c..73985719a 100644 --- a/certbot/util.py +++ b/certbot/util.py @@ -278,7 +278,7 @@ def get_systemd_os_like(filepath="/etc/os-release"): :rtype: `list` of `str` """ - return _get_systemd_os_release_var("LIKE", filepath).split(" ") + return _get_systemd_os_release_var("ID_LIKE", filepath).split(" ") def _get_systemd_os_release_var(varname, filepath="/etc/os-release"): From 093ebd2f0342c23e7d3e28fd0963e1ffc9f1e14a Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Sat, 30 Jul 2016 11:49:04 +0300 Subject: [PATCH 05/17] Tests --- .../certbot_apache/tests/constants_test.py | 17 +++++++++++++++++ certbot/tests/testdata/os-release | 2 +- certbot/tests/util_test.py | 9 +++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/certbot-apache/certbot_apache/tests/constants_test.py b/certbot-apache/certbot_apache/tests/constants_test.py index c040030df..1c842aee9 100644 --- a/certbot-apache/certbot_apache/tests/constants_test.py +++ b/certbot-apache/certbot_apache/tests/constants_test.py @@ -25,3 +25,20 @@ class ConstantsTest(unittest.TestCase): os_info.return_value = ('Nonexistent Linux', '', '') self.assertEqual(constants.os_constant("vhost_root"), "/etc/apache2/sites-available") + + @mock.patch("certbot.util.get_os_info") + def test_get_default_constants(self, os_info): + os_info.return_value = ('Nonexistent Linux', '', '') + with mock.patch("certbot.util.get_systemd_os_like") as os_like: + # Get defaults + os_like.return_value = False + c_hm = constants.os_constant("handle_mods") + c_sr = constants.os_constant("server_root") + self.assertFalse(c_hm) + self.assertEqual(c_sr, "/etc/apache2") + # Use darwin as like test target + os_like.return_value = ["something", "nonexistent", "darwin"] + d_vr = constants.os_constant("vhost_root") + d_em = constants.os_constant("enmod") + self.assertFalse(d_em) + self.assertEqual(d_vr, "/etc/apache2/other") diff --git a/certbot/tests/testdata/os-release b/certbot/tests/testdata/os-release index cd5297acf..15bc5fb3c 100644 --- a/certbot/tests/testdata/os-release +++ b/certbot/tests/testdata/os-release @@ -1,7 +1,7 @@ NAME="SystemdOS" VERSION="42.42.42 LTS, Unreal" ID=systemdos -ID_LIKE=debian +ID_LIKE="something nonexistent debian" VERSION_ID="42" HOME_URL="http://www.example.com/" SUPPORT_URL="http://help.example.com/" diff --git a/certbot/tests/util_test.py b/certbot/tests/util_test.py index 8e1b330ed..36676443a 100644 --- a/certbot/tests/util_test.py +++ b/certbot/tests/util_test.py @@ -359,6 +359,15 @@ class OsInfoTest(unittest.TestCase): with mock.patch('os.path.isfile', return_value=False): self.assertEqual(get_systemd_os_info(), ("", "")) + def test_systemd_os_release_like(self): + from certbot.util import get_systemd_os_like + + with mock.patch('os.path.isfile', return_value=True): + id_likes = get_systemd_os_like(test_util.vector_path( + "os-release")) + self.assertEqual(len(id_likes), 3) + self.assertTrue("debian" in id_likes) + @mock.patch("certbot.util.subprocess.Popen") def test_non_systemd_os_info(self, popen_mock): from certbot.util import (get_os_info, get_python_os_info, From 28fc02143bd9b235ba569c0045795e18c916fe66 Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Sat, 30 Jul 2016 11:59:58 +0300 Subject: [PATCH 06/17] Remove enmod and dismod values as they are not needed --- certbot-apache/certbot_apache/constants.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/certbot-apache/certbot_apache/constants.py b/certbot-apache/certbot_apache/constants.py index d4ec2d8a8..5e296ba0a 100644 --- a/certbot-apache/certbot_apache/constants.py +++ b/certbot-apache/certbot_apache/constants.py @@ -10,8 +10,8 @@ CLI_DEFAULTS_DEFAULT = dict( define_cmd=['apache2ctl', '-t', '-D', 'DUMP_RUN_CFG'], restart_cmd=['apache2ctl', 'graceful'], conftest_cmd=['apache2ctl', 'configtest'], - enmod="a2enmod", - dismod="a2dismod", + enmod=None, + dismod=None, le_vhost_ext="-le-ssl.conf", handle_mods=False, handle_sites=False, From 8a09a7ed6715e345ee03041b933a9f815e815dd8 Mon Sep 17 00:00:00 2001 From: Yen Chi Hsuan Date: Sat, 30 Jul 2016 18:15:32 +0800 Subject: [PATCH 07/17] Python 3 support for certonly --- certbot/auth_handler.py | 6 +++--- certbot/cli.py | 6 ++++-- certbot/constants.py | 2 +- certbot/plugins/disco.py | 11 ++++++----- certbot/plugins/manual.py | 3 ++- certbot/plugins/selection.py | 2 +- certbot/util.py | 3 +++ setup.py | 7 ++++++- 8 files changed, 26 insertions(+), 14 deletions(-) diff --git a/certbot/auth_handler.py b/certbot/auth_handler.py index f5557d604..a94734572 100644 --- a/certbot/auth_handler.py +++ b/certbot/auth_handler.py @@ -1,8 +1,8 @@ """ACME AuthHandler.""" -import itertools import logging import time +import six import zope.component from acme import challenges @@ -141,7 +141,7 @@ class AuthHandler(object): """ active_achalls = [] - for achall, resp in itertools.izip(achalls, resps): + for achall, resp in six.moves.zip(achalls, resps): # This line needs to be outside of the if block below to # ensure failed challenges are cleaned up correctly active_achalls.append(achall) @@ -472,7 +472,7 @@ def _report_failed_challs(failed_achalls): problems.setdefault(achall.error.typ, []).append(achall) reporter = zope.component.getUtility(interfaces.IReporter) - for achalls in problems.itervalues(): + for achalls in six.itervalues(problems): reporter.add_message( _generate_failed_chall_msg(achalls), reporter.MEDIUM_PRIORITY) diff --git a/certbot/cli.py b/certbot/cli.py index 5813af730..b01b0a7f1 100644 --- a/certbot/cli.py +++ b/certbot/cli.py @@ -343,8 +343,10 @@ class HelpfulArgumentParser(object): self.determine_verb() help1 = self.prescan_for_flag("-h", self.help_topics) help2 = self.prescan_for_flag("--help", self.help_topics) - assert max(True, "a") == "a", "Gravity changed direction" - self.help_arg = max(help1, help2) + if isinstance(help1, bool) and isinstance(help2, bool): + self.help_arg = help1 or help2 + else: + self.help_arg = help1 if isinstance(help1, str) else help2 if self.help_arg is True: # just --help with no topic; avoid argparse altogether print(usage) diff --git a/certbot/constants.py b/certbot/constants.py index fb278161d..1ddb9fedf 100644 --- a/certbot/constants.py +++ b/certbot/constants.py @@ -18,7 +18,7 @@ CLI_DEFAULTS = dict( os.path.join(os.environ.get("XDG_CONFIG_HOME", "~/.config"), "letsencrypt", "cli.ini"), ], - verbose_count=-(logging.INFO / 10), + verbose_count=-int(logging.INFO / 10), server="https://acme-v01.api.letsencrypt.org/directory", rsa_key_size=2048, rollback_checkpoints=1, diff --git a/certbot/plugins/disco.py b/certbot/plugins/disco.py index d88b871f6..59410757c 100644 --- a/certbot/plugins/disco.py +++ b/certbot/plugins/disco.py @@ -3,6 +3,7 @@ import collections import itertools import logging import pkg_resources +import six import zope.interface import zope.interface.verify @@ -194,12 +195,12 @@ class PluginsRegistry(collections.Mapping): def init(self, config): """Initialize all plugins in the registry.""" return [plugin_ep.init(config) for plugin_ep - in self._plugins.itervalues()] + in six.itervalues(self._plugins)] def filter(self, pred): """Filter plugins based on predicate.""" return type(self)(dict((name, plugin_ep) for name, plugin_ep - in self._plugins.iteritems() if pred(plugin_ep))) + in six.iteritems(self._plugins) if pred(plugin_ep))) def visible(self): """Filter plugins based on visibility.""" @@ -216,7 +217,7 @@ class PluginsRegistry(collections.Mapping): def prepare(self): """Prepare all plugins in the registry.""" - return [plugin_ep.prepare() for plugin_ep in self._plugins.itervalues()] + return [plugin_ep.prepare() for plugin_ep in six.itervalues(self._plugins)] def available(self): """Filter plugins based on availability.""" @@ -238,7 +239,7 @@ class PluginsRegistry(collections.Mapping): """ # use list instead of set because PluginEntryPoint is not hashable - candidates = [plugin_ep for plugin_ep in self._plugins.itervalues() + candidates = [plugin_ep for plugin_ep in six.itervalues(self._plugins) if plugin_ep.initialized and plugin_ep.init() is plugin] assert len(candidates) <= 1 if candidates: @@ -249,7 +250,7 @@ class PluginsRegistry(collections.Mapping): def __repr__(self): return "{0}({1})".format( self.__class__.__name__, ','.join( - repr(p_ep) for p_ep in self._plugins.itervalues())) + repr(p_ep) for p_ep in six.itervalues(self._plugins))) def __str__(self): if not self._plugins: diff --git a/certbot/plugins/manual.py b/certbot/plugins/manual.py index 9b722aef4..6c7b822ab 100644 --- a/certbot/plugins/manual.py +++ b/certbot/plugins/manual.py @@ -10,6 +10,7 @@ import sys import tempfile import time +import six import zope.component import zope.interface @@ -187,7 +188,7 @@ s.serve_forever()" """ #answer = zope.component.getUtility(interfaces.IDisplay).notification( # message=message, height=25, pause=True) sys.stdout.write(message) - raw_input("Press ENTER to continue") + six.moves.input("Press ENTER to continue") def cleanup(self, achalls): # pylint: disable=missing-docstring,no-self-use,unused-argument diff --git a/certbot/plugins/selection.py b/certbot/plugins/selection.py index 21ebe9029..b16515d8f 100644 --- a/certbot/plugins/selection.py +++ b/certbot/plugins/selection.py @@ -84,7 +84,7 @@ def pick_plugin(config, default, plugins, question, ifaces): else: return plugin_ep.init() elif len(prepared) == 1: - plugin_ep = prepared.values()[0] + plugin_ep = list(prepared.values())[0] logger.debug("Single candidate plugin: %s", plugin_ep) if plugin_ep.misconfigured: return None diff --git a/certbot/util.py b/certbot/util.py index 65aae59e2..2ad2c4535 100644 --- a/certbot/util.py +++ b/certbot/util.py @@ -409,6 +409,9 @@ def enforce_domain_sanity(domain): else: raise errors.ConfigurationError(str(error_fmt).format(domain)) + if six.PY3: + domain = domain.decode('ascii') + # Remove trailing dot domain = domain[:-1] if domain.endswith('.') else domain diff --git a/setup.py b/setup.py index 21cda901a..093cbc449 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,6 @@ install_requires = [ 'psutil>=2.2.1', # 2.1.0 for net_connections and 2.2.1 resolves #1080 'PyOpenSSL', 'pyrfc3339', - 'python2-pythondialog>=3.2.2rc1', # Debian squeeze support, cf. #280 'pytz', # For pkg_resources. >=1.0 so pip resolves it to a version cryptography # will tolerate; see #2599: @@ -53,6 +52,12 @@ install_requires = [ 'zope.interface', ] +# Debian squeeze support, cf. #280 +if sys.version_info[0] == 2: + install_requires.append('python2-pythondialog>=3.2.2rc1') +else: + install_requires.append('pythondialog>=3.2.2rc1') + # env markers in extras_require cause problems with older pip: #517 # Keep in sync with conditional_requirements.py. if sys.version_info < (2, 7): From b891cac3dc4661a8f4ff99c53955884b727b0975 Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Sun, 31 Jul 2016 01:10:28 +0300 Subject: [PATCH 08/17] Added suse constants --- certbot-apache/certbot_apache/constants.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/certbot-apache/certbot_apache/constants.py b/certbot-apache/certbot_apache/constants.py index 5e296ba0a..001ef1caa 100644 --- a/certbot-apache/certbot_apache/constants.py +++ b/certbot-apache/certbot_apache/constants.py @@ -87,6 +87,23 @@ CLI_DEFAULTS_DARWIN = dict( MOD_SSL_CONF_SRC=pkg_resources.resource_filename( "certbot_apache", "options-ssl-apache.conf") ) +CLI_DEFAULTS_SUSE = dict( + server_root="/etc/apache2", + vhost_root="/etc/apache2/vhosts.d", + vhost_files="*.conf", + version_cmd=['apache2ctl', '-v'], + define_cmd=['apache2ctl', '-t', '-D', 'DUMP_RUN_CFG'], + restart_cmd=['apache2ctl', 'graceful'], + conftest_cmd=['apache2ctl', 'configtest'], + enmod="a2enmod", + dismod="a2dismod", + le_vhost_ext="-le-ssl.conf", + handle_mods=True, + handle_sites=False, + challenge_location="/etc/apache2/vhosts.d", + MOD_SSL_CONF_SRC=pkg_resources.resource_filename( + "certbot_apache", "options-ssl-apache.conf") +) CLI_DEFAULTS = { "default": CLI_DEFAULTS_DEFAULT, "debian": CLI_DEFAULTS_DEBIAN, @@ -100,6 +117,8 @@ CLI_DEFAULTS = { "gentoo": CLI_DEFAULTS_GENTOO, "gentoo base system": CLI_DEFAULTS_GENTOO, "darwin": CLI_DEFAULTS_DARWIN, + "opensuse": CLI_DEFAULTS_SUSE, + "suse": CLI_DEFAULTS_SUSE, } """CLI defaults.""" From c346cdf2f33e136950ef7ad324215f9d8752ba9f Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Tue, 2 Aug 2016 09:57:34 +0300 Subject: [PATCH 09/17] Changed SUSE mod handling constant --- certbot-apache/certbot_apache/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/certbot-apache/certbot_apache/constants.py b/certbot-apache/certbot_apache/constants.py index 001ef1caa..ba545c613 100644 --- a/certbot-apache/certbot_apache/constants.py +++ b/certbot-apache/certbot_apache/constants.py @@ -98,7 +98,7 @@ CLI_DEFAULTS_SUSE = dict( enmod="a2enmod", dismod="a2dismod", le_vhost_ext="-le-ssl.conf", - handle_mods=True, + handle_mods=False, handle_sites=False, challenge_location="/etc/apache2/vhosts.d", MOD_SSL_CONF_SRC=pkg_resources.resource_filename( From e49a41be34b572a6a01160bf38fbfa1f10c46965 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Mon, 8 Aug 2016 12:17:42 -0700 Subject: [PATCH 10/17] Change "hacking" to "getting started" in the docs --- docs/contributing.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/contributing.rst b/docs/contributing.rst index f1eec04df..a5b9b5688 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -6,9 +6,9 @@ Developer Guide :local: -.. _hacking: +.. _getting_started: -Hacking +Getting Started ======= Running a local copy of the client From c29e8c3332640611909c5f7c6913525c86d9d8d5 Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Tue, 9 Aug 2016 23:43:11 +0300 Subject: [PATCH 11/17] Refactored get_file_path --- certbot-apache/certbot_apache/configurator.py | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/certbot-apache/certbot_apache/configurator.py b/certbot-apache/certbot_apache/configurator.py index 238255133..4a68461ce 100644 --- a/certbot-apache/certbot_apache/configurator.py +++ b/certbot-apache/certbot_apache/configurator.py @@ -1801,25 +1801,17 @@ def get_file_path(vhost_path): :rtype: str """ - # Strip off /files - avail_fp = vhost_path[6:] - # This can be optimized... - while True: - # Cast all to lowercase to be case insensitive - find_if = avail_fp.lower().find("/ifmodule") - if find_if != -1: - avail_fp = avail_fp[:find_if] - continue - find_vh = avail_fp.lower().find("/virtualhost") - if find_vh != -1: - avail_fp = avail_fp[:find_vh] - continue - find_macro = avail_fp.lower().find("/macro") - if find_macro != -1: - avail_fp = avail_fp[:find_macro] - continue - break - return avail_fp + # Strip off /files/ + avail_fp = vhost_path[7:].split("/") + last_good = "" + # Loop through the path parts and validate after every addition + for p in avail_fp: + cur_path = last_good+"/"+p + if os.path.exists(cur_path): + last_good = cur_path + else: + break + return last_good def install_ssl_options_conf(options_ssl): From f4948855f02b1e1dde4434e7c8e15beb8c06a150 Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Wed, 10 Aug 2016 00:25:35 +0300 Subject: [PATCH 12/17] Added None check and according test --- certbot-apache/certbot_apache/configurator.py | 8 +++++++- certbot-apache/certbot_apache/tests/configurator_test.py | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/certbot-apache/certbot_apache/configurator.py b/certbot-apache/certbot_apache/configurator.py index 4a68461ce..abe3edede 100644 --- a/certbot-apache/certbot_apache/configurator.py +++ b/certbot-apache/certbot_apache/configurator.py @@ -538,6 +538,9 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): is_ssl = True filename = get_file_path(self.aug.get("/augeas/files%s/path" % get_file_path(path))) + if filename is None: + return None + if self.conf("handle-sites"): is_enabled = self.is_site_enabled(filename) else: @@ -1802,7 +1805,10 @@ def get_file_path(vhost_path): """ # Strip off /files/ - avail_fp = vhost_path[7:].split("/") + try: + avail_fp = vhost_path[7:].split("/") + except TypeError: + return None last_good = "" # Loop through the path parts and validate after every addition for p in avail_fp: diff --git a/certbot-apache/certbot_apache/tests/configurator_test.py b/certbot-apache/certbot_apache/tests/configurator_test.py index ac692ae54..59692302d 100644 --- a/certbot-apache/certbot_apache/tests/configurator_test.py +++ b/certbot-apache/certbot_apache/tests/configurator_test.py @@ -125,6 +125,10 @@ class MultipleVhostsTest(util.ApacheTest): self.assertTrue("google.com" in names) self.assertTrue("certbot.demo" in names) + def test_get_bad_path(self): + from certbot_apache.configurator import get_file_path + self.assertEqual(get_file_path(None), None) + def test_bad_servername_alias(self): ssl_vh1 = obj.VirtualHost( "fp1", "ap1", set([obj.Addr(("*", "443"))]), From 6c3ae10f9b1e94d0f38d73c15f593b348556e5d4 Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Wed, 10 Aug 2016 01:39:53 +0300 Subject: [PATCH 13/17] Added test case --- certbot-apache/certbot_apache/tests/configurator_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/certbot-apache/certbot_apache/tests/configurator_test.py b/certbot-apache/certbot_apache/tests/configurator_test.py index 59692302d..2a8960564 100644 --- a/certbot-apache/certbot_apache/tests/configurator_test.py +++ b/certbot-apache/certbot_apache/tests/configurator_test.py @@ -128,6 +128,7 @@ class MultipleVhostsTest(util.ApacheTest): def test_get_bad_path(self): from certbot_apache.configurator import get_file_path self.assertEqual(get_file_path(None), None) + self.assertEqual(self.config._create_vhost("nonexistent"), None) def test_bad_servername_alias(self): ssl_vh1 = obj.VirtualHost( From 51191c2ea54de8fad135c93b13bb6ab0bc22410c Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Wed, 10 Aug 2016 01:50:40 +0300 Subject: [PATCH 14/17] Added linter exception --- certbot-apache/certbot_apache/tests/configurator_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/certbot-apache/certbot_apache/tests/configurator_test.py b/certbot-apache/certbot_apache/tests/configurator_test.py index 2a8960564..f8bf7676c 100644 --- a/certbot-apache/certbot_apache/tests/configurator_test.py +++ b/certbot-apache/certbot_apache/tests/configurator_test.py @@ -128,7 +128,7 @@ class MultipleVhostsTest(util.ApacheTest): def test_get_bad_path(self): from certbot_apache.configurator import get_file_path self.assertEqual(get_file_path(None), None) - self.assertEqual(self.config._create_vhost("nonexistent"), None) + self.assertEqual(self.config._create_vhost("nonexistent"), None) # pylint: disable=protected-access def test_bad_servername_alias(self): ssl_vh1 = obj.VirtualHost( From 14f371025049bbc5621da943e0ee04cf4e4add8d Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Wed, 10 Aug 2016 10:39:10 +0300 Subject: [PATCH 15/17] Added check for /files/ --- certbot-apache/certbot_apache/configurator.py | 9 +++++++-- certbot-apache/certbot_apache/tests/configurator_test.py | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/certbot-apache/certbot_apache/configurator.py b/certbot-apache/certbot_apache/configurator.py index abe3edede..02602ace6 100644 --- a/certbot-apache/certbot_apache/configurator.py +++ b/certbot-apache/certbot_apache/configurator.py @@ -1806,9 +1806,14 @@ def get_file_path(vhost_path): """ # Strip off /files/ try: - avail_fp = vhost_path[7:].split("/") - except TypeError: + if vhost_path.startswith("/files/"): + avail_fp = vhost_path[7:].split("/") + else: + return None + except AttributeError: + # If we recieved a None path return None + last_good = "" # Loop through the path parts and validate after every addition for p in avail_fp: diff --git a/certbot-apache/certbot_apache/tests/configurator_test.py b/certbot-apache/certbot_apache/tests/configurator_test.py index f8bf7676c..dc953174e 100644 --- a/certbot-apache/certbot_apache/tests/configurator_test.py +++ b/certbot-apache/certbot_apache/tests/configurator_test.py @@ -128,6 +128,7 @@ class MultipleVhostsTest(util.ApacheTest): def test_get_bad_path(self): from certbot_apache.configurator import get_file_path self.assertEqual(get_file_path(None), None) + self.assertEqual(get_file_path("nonexistent"), None) self.assertEqual(self.config._create_vhost("nonexistent"), None) # pylint: disable=protected-access def test_bad_servername_alias(self): From dd1de2bc9e4d6de7ffb7192dede23fcc68618510 Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Wed, 10 Aug 2016 11:49:55 -0700 Subject: [PATCH 16/17] Fix travis --- tests/boulder-fetch.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/boulder-fetch.sh b/tests/boulder-fetch.sh index 469c5cd80..0c0a8009b 100755 --- a/tests/boulder-fetch.sh +++ b/tests/boulder-fetch.sh @@ -5,6 +5,6 @@ set -xe # Check out special branch until latest docker changes land in Boulder master. git clone -b docker-integration https://github.com/letsencrypt/boulder $BOULDERPATH cd $BOULDERPATH -sed -i 's/FAKE_DNS: .*/FAKE_DNS: 172.17.42.1/' docker-compose.yml +FAKE_DNS=$(ifconfig docker0 | grep "inet addr:" | cut -d: -f2 | awk '{ print $1}') +sed -i "s/FAKE_DNS: .*/FAKE_DNS: $FAKE_DNS/" docker-compose.yml docker-compose up -d - From fd1629e347a3fce7cf2bc63b7e05063e3d294cd8 Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Wed, 10 Aug 2016 11:51:12 -0700 Subject: [PATCH 17/17] Make letstest docker ip more robust --- tests/letstest/scripts/boulder_install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/letstest/scripts/boulder_install.sh b/tests/letstest/scripts/boulder_install.sh index 7e298783f..f997268bd 100755 --- a/tests/letstest/scripts/boulder_install.sh +++ b/tests/letstest/scripts/boulder_install.sh @@ -5,5 +5,6 @@ # Check out special branch until latest docker changes land in Boulder master. git clone -b docker-integration https://github.com/letsencrypt/boulder $BOULDERPATH cd $BOULDERPATH -sed -i 's/FAKE_DNS: .*/FAKE_DNS: 172.17.42.1/' docker-compose.yml +FAKE_DNS=$(ifconfig docker0 | grep "inet addr:" | cut -d: -f2 | awk '{ print $1}') +sed -i "s/FAKE_DNS: .*/FAKE_DNS: $FAKE_DNS/" docker-compose.yml docker-compose up -d