diff -Nru python-certbot-nginx-1.7.0/certbot_nginx/_internal/configurator.py python-certbot-nginx-1.10.1/certbot_nginx/_internal/configurator.py --- python-certbot-nginx-1.7.0/certbot_nginx/_internal/configurator.py 2020-08-04 18:20:15.000000000 +0000 +++ python-certbot-nginx-1.10.1/certbot_nginx/_internal/configurator.py 2020-12-03 18:20:10.000000000 +0000 @@ -16,6 +16,7 @@ from acme.magic_typing import Dict from acme.magic_typing import List from acme.magic_typing import Set +from acme.magic_typing import Text from certbot import crypto_util from certbot import errors from certbot import interfaces @@ -1175,23 +1176,29 @@ """ try: - proc = subprocess.Popen([nginx_ctl, "-c", nginx_conf, "-s", "reload"], - env=util.env_no_snap_for_external_calls()) - proc.communicate() + reload_output = u"" # type: Text + with tempfile.TemporaryFile() as out: + proc = subprocess.Popen([nginx_ctl, "-c", nginx_conf, "-s", "reload"], + env=util.env_no_snap_for_external_calls(), + stdout=out, stderr=out) + proc.communicate() + out.seek(0) + reload_output = out.read().decode("utf-8") if proc.returncode != 0: - # Maybe Nginx isn't running + logger.debug("nginx reload failed:\n%s", reload_output) + # Maybe Nginx isn't running - try start it # Write to temporary files instead of piping because of communication issues on Arch # https://github.com/certbot/certbot/issues/4324 with tempfile.TemporaryFile() as out: - with tempfile.TemporaryFile() as err: - nginx_proc = subprocess.Popen([nginx_ctl, "-c", nginx_conf], - stdout=out, stderr=err, env=util.env_no_snap_for_external_calls()) - nginx_proc.communicate() - if nginx_proc.returncode != 0: - # Enter recovery routine... - raise errors.MisconfigurationError( - "nginx restart failed:\n%s\n%s" % (out.read(), err.read())) + nginx_proc = subprocess.Popen([nginx_ctl, "-c", nginx_conf], + stdout=out, stderr=out, env=util.env_no_snap_for_external_calls()) + nginx_proc.communicate() + if nginx_proc.returncode != 0: + out.seek(0) + # Enter recovery routine... + raise errors.MisconfigurationError( + "nginx restart failed:\n%s" % out.read().decode("utf-8")) except (OSError, ValueError): raise errors.MisconfigurationError("nginx restart failed") diff -Nru python-certbot-nginx-1.7.0/certbot_nginx/_internal/http_01.py python-certbot-nginx-1.10.1/certbot_nginx/_internal/http_01.py --- python-certbot-nginx-1.7.0/certbot_nginx/_internal/http_01.py 2020-08-04 18:20:15.000000000 +0000 +++ python-certbot-nginx-1.10.1/certbot_nginx/_internal/http_01.py 2020-12-03 18:20:10.000000000 +0000 @@ -1,5 +1,6 @@ """A class that performs HTTP-01 challenges for Nginx""" +import io import logging from acme import challenges @@ -102,7 +103,7 @@ self.configurator.reverter.register_file_creation( True, self.challenge_conf) - with open(self.challenge_conf, "w") as new_conf: + with io.open(self.challenge_conf, "w", encoding="utf-8") as new_conf: nginxparser.dump(config, new_conf) def _default_listen_addresses(self): diff -Nru python-certbot-nginx-1.7.0/certbot_nginx/_internal/nginxparser.py python-certbot-nginx-1.10.1/certbot_nginx/_internal/nginxparser.py --- python-certbot-nginx-1.7.0/certbot_nginx/_internal/nginxparser.py 2020-08-04 18:20:15.000000000 +0000 +++ python-certbot-nginx-1.10.1/certbot_nginx/_internal/nginxparser.py 2020-12-03 18:20:10.000000000 +0000 @@ -16,6 +16,7 @@ from pyparsing import White from pyparsing import ZeroOrMore import six +from acme.magic_typing import IO, Any # pylint: disable=unused-import logger = logging.getLogger(__name__) @@ -130,26 +131,27 @@ def dumps(blocks): - """Dump to a string. + # type: (UnspacedList) -> six.text_type + """Dump to a Unicode string. :param UnspacedList block: The parsed tree - :param int indentation: The number of spaces to indent - :rtype: str + :rtype: six.text_type """ - return str(RawNginxDumper(blocks.spaced)) + return six.text_type(RawNginxDumper(blocks.spaced)) def dump(blocks, _file): + # type: (UnspacedList, IO[Any]) -> None """Dump to a file. :param UnspacedList block: The parsed tree - :param file _file: The file to dump to - :param int indentation: The number of spaces to indent - :rtype: NoneType + :param IO[Any] _file: The file stream to dump to. It must be opened with + Unicode encoding. + :rtype: None """ - return _file.write(dumps(blocks)) + _file.write(dumps(blocks)) spacey = lambda x: (isinstance(x, six.string_types) and x.isspace()) or x == '' diff -Nru python-certbot-nginx-1.7.0/certbot_nginx/_internal/obj.py python-certbot-nginx-1.10.1/certbot_nginx/_internal/obj.py --- python-certbot-nginx-1.7.0/certbot_nginx/_internal/obj.py 2020-08-04 18:20:15.000000000 +0000 +++ python-certbot-nginx-1.10.1/certbot_nginx/_internal/obj.py 2020-12-03 18:20:10.000000000 +0000 @@ -19,7 +19,7 @@ 80. If no address is specified, listen on all addresses. .. _documentation: - http://nginx.org/en/docs/http/ngx_http_core_module.html#listen + https://nginx.org/en/docs/http/ngx_http_core_module.html#listen .. todo:: Old-style nginx configs define SSL vhosts in a separate block instead of using 'ssl' in the listen directive. diff -Nru python-certbot-nginx-1.7.0/certbot_nginx/_internal/parser.py python-certbot-nginx-1.10.1/certbot_nginx/_internal/parser.py --- python-certbot-nginx-1.7.0/certbot_nginx/_internal/parser.py 2020-08-04 18:20:15.000000000 +0000 +++ python-certbot-nginx-1.10.1/certbot_nginx/_internal/parser.py 2020-12-03 18:20:10.000000000 +0000 @@ -249,7 +249,7 @@ continue out = nginxparser.dumps(tree) logger.debug('Writing nginx conf tree to %s:\n%s', filename, out) - with open(filename, 'w') as _file: + with io.open(filename, 'w', encoding='utf-8') as _file: _file.write(out) except IOError: @@ -496,7 +496,8 @@ def _exact_match(target_name, name): - return name in (target_name, '.' + target_name) + target_lower = target_name.lower() + return name.lower() in (target_lower, '.' + target_lower) def _wildcard_match(target_name, name, start): @@ -517,11 +518,11 @@ if first not in ('*', ''): return False - target_name = '.'.join(parts) - name = '.'.join(match_parts) + target_name_lower = '.'.join(parts).lower() + name_lower = '.'.join(match_parts).lower() # Ex: www.eff.org matches *.eff.org, eff.org does not match *.eff.org - return target_name.endswith('.' + name) + return target_name_lower.endswith('.' + name_lower) def _regex_match(target_name, name): diff -Nru python-certbot-nginx-1.7.0/certbot_nginx.egg-info/PKG-INFO python-certbot-nginx-1.10.1/certbot_nginx.egg-info/PKG-INFO --- python-certbot-nginx-1.7.0/certbot_nginx.egg-info/PKG-INFO 2020-08-04 18:20:23.000000000 +0000 +++ python-certbot-nginx-1.10.1/certbot_nginx.egg-info/PKG-INFO 2020-12-03 18:20:42.000000000 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: certbot-nginx -Version: 1.7.0 +Version: 1.10.1 Summary: Nginx plugin for Certbot Home-page: https://github.com/letsencrypt/letsencrypt Author: Certbot Project @@ -17,14 +17,14 @@ Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 +Classifier: Programming Language :: Python :: 3.9 Classifier: Topic :: Internet :: WWW/HTTP Classifier: Topic :: Security Classifier: Topic :: System :: Installation/Setup Classifier: Topic :: System :: Networking Classifier: Topic :: System :: Systems Administration Classifier: Topic :: Utilities -Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.* +Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.* diff -Nru python-certbot-nginx-1.7.0/debian/changelog python-certbot-nginx-1.10.1/debian/changelog --- python-certbot-nginx-1.7.0/debian/changelog 2020-08-05 00:34:48.000000000 +0000 +++ python-certbot-nginx-1.10.1/debian/changelog 2020-12-05 03:50:08.000000000 +0000 @@ -1,3 +1,11 @@ +python-certbot-nginx (1.10.1-1) unstable; urgency=medium + + * New upstream version 1.10.1 + * Bump S-V; no changes needed + * Bump d/watch to v4 + + -- Harlan Lieberman-Berg Fri, 04 Dec 2020 22:50:08 -0500 + python-certbot-nginx (1.7.0-1) unstable; urgency=medium * New upstream version 1.7.0 diff -Nru python-certbot-nginx-1.7.0/debian/control python-certbot-nginx-1.10.1/debian/control --- python-certbot-nginx-1.7.0/debian/control 2020-07-07 21:46:00.000000000 +0000 +++ python-certbot-nginx-1.10.1/debian/control 2020-12-05 03:49:24.000000000 +0000 @@ -21,7 +21,7 @@ python3-tz, python3-zope.component, python3-zope.interface -Standards-Version: 4.5.0 +Standards-Version: 4.5.1 Vcs-Browser: https://salsa.debian.org/letsencrypt-team/certbot/certbot-nginx Vcs-Git: https://salsa.debian.org/letsencrypt-team/certbot/certbot-nginx.git Homepage: https://letsencrypt.org/ diff -Nru python-certbot-nginx-1.7.0/debian/watch python-certbot-nginx-1.10.1/debian/watch --- python-certbot-nginx-1.7.0/debian/watch 2018-05-29 02:44:24.000000000 +0000 +++ python-certbot-nginx-1.10.1/debian/watch 2020-12-05 03:49:42.000000000 +0000 @@ -1,3 +1,3 @@ -version=3 +version=4 opts=uversionmangle=s/(rc|a|b|c)/~$1/,pgpsigurlmangle=s/$/.asc/ \ https://pypi.debian.net/certbot-nginx/certbot-nginx-(.+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz))) diff -Nru python-certbot-nginx-1.7.0/PKG-INFO python-certbot-nginx-1.10.1/PKG-INFO --- python-certbot-nginx-1.7.0/PKG-INFO 2020-08-04 18:20:23.109773400 +0000 +++ python-certbot-nginx-1.10.1/PKG-INFO 2020-12-03 18:20:42.164106000 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: certbot-nginx -Version: 1.7.0 +Version: 1.10.1 Summary: Nginx plugin for Certbot Home-page: https://github.com/letsencrypt/letsencrypt Author: Certbot Project @@ -17,14 +17,14 @@ Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 +Classifier: Programming Language :: Python :: 3.9 Classifier: Topic :: Internet :: WWW/HTTP Classifier: Topic :: Security Classifier: Topic :: System :: Installation/Setup Classifier: Topic :: System :: Networking Classifier: Topic :: System :: Systems Administration Classifier: Topic :: Utilities -Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.* +Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.* diff -Nru python-certbot-nginx-1.7.0/setup.py python-certbot-nginx-1.10.1/setup.py --- python-certbot-nginx-1.7.0/setup.py 2020-08-04 18:20:16.000000000 +0000 +++ python-certbot-nginx-1.10.1/setup.py 2020-12-03 18:20:12.000000000 +0000 @@ -4,9 +4,8 @@ from setuptools import __version__ as setuptools_version from setuptools import find_packages from setuptools import setup -from setuptools.command.test import test as TestCommand -version = '1.7.0' +version = '1.10.1' # Remember to update local-oldest-requirements.txt when changing the minimum # acme/certbot version. @@ -28,22 +27,6 @@ elif sys.version_info < (3,3): install_requires.append('mock') - -class PyTest(TestCommand): - user_options = [] - - def initialize_options(self): - TestCommand.initialize_options(self) - self.pytest_args = '' - - def run_tests(self): - import shlex - # import here, cause outside the eggs aren't loaded - import pytest - errno = pytest.main(shlex.split(self.pytest_args)) - sys.exit(errno) - - setup( name='certbot-nginx', version=version, @@ -52,7 +35,7 @@ author="Certbot Project", author_email='client-dev@letsencrypt.org', license='Apache License 2.0', - python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*', + python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*', classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Plugins', @@ -63,10 +46,10 @@ 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Security', 'Topic :: System :: Installation/Setup', @@ -83,7 +66,4 @@ 'nginx = certbot_nginx._internal.configurator:NginxConfigurator', ], }, - test_suite='certbot_nginx', - tests_require=["pytest"], - cmdclass={"test": PyTest}, ) diff -Nru python-certbot-nginx-1.7.0/tests/configurator_test.py python-certbot-nginx-1.10.1/tests/configurator_test.py --- python-certbot-nginx-1.7.0/tests/configurator_test.py 2020-08-04 18:20:15.000000000 +0000 +++ python-certbot-nginx-1.10.1/tests/configurator_test.py 2020-12-03 18:20:10.000000000 +0000 @@ -466,14 +466,18 @@ mocked.communicate.return_value = ('', '') mocked.returncode = 0 self.config.restart() + self.assertEqual(mocked.communicate.call_count, 1) mock_time.sleep.assert_called_once_with(0.1234) @mock.patch("certbot_nginx._internal.configurator.subprocess.Popen") - def test_nginx_restart_fail(self, mock_popen): + @mock.patch("certbot_nginx._internal.configurator.logger.debug") + def test_nginx_restart_fail(self, mock_log_debug, mock_popen): mocked = mock_popen() mocked.communicate.return_value = ('', '') mocked.returncode = 1 self.assertRaises(errors.MisconfigurationError, self.config.restart) + self.assertEqual(mocked.communicate.call_count, 2) + mock_log_debug.assert_called_once_with("nginx reload failed:\n%s", "") @mock.patch("certbot_nginx._internal.configurator.subprocess.Popen") def test_no_nginx_start(self, mock_popen): @@ -838,7 +842,7 @@ self.config.recovery_routine() self.config.revert_challenge_config() self.config.rollback_checkpoints() - self.assertTrue(mock_parser_load.call_count == 3) + self.assertEqual(mock_parser_load.call_count, 3) def test_choose_vhosts_wildcard(self): # pylint: disable=protected-access diff -Nru python-certbot-nginx-1.7.0/tests/obj_test.py python-certbot-nginx-1.10.1/tests/obj_test.py --- python-certbot-nginx-1.7.0/tests/obj_test.py 2020-08-04 18:20:15.000000000 +0000 +++ python-certbot-nginx-1.10.1/tests/obj_test.py 2020-12-03 18:20:10.000000000 +0000 @@ -75,7 +75,7 @@ new_addr1 = Addr.fromstring("192.168.1.1 spdy") self.assertEqual(self.addr1, new_addr1) self.assertNotEqual(self.addr1, self.addr2) - self.assertFalse(self.addr1 == 3333) + self.assertNotEqual(self.addr1, 3333) def test_equivalent_any_addresses(self): from certbot_nginx._internal.obj import Addr @@ -168,7 +168,7 @@ self.assertEqual(vhost1b, self.vhost1) self.assertEqual(str(vhost1b), str(self.vhost1)) - self.assertFalse(vhost1b == 1234) + self.assertNotEqual(vhost1b, 1234) def test_str(self): stringified = '\n'.join(['file: filep', 'addrs: localhost', diff -Nru python-certbot-nginx-1.7.0/tests/parser_test.py python-certbot-nginx-1.10.1/tests/parser_test.py --- python-certbot-nginx-1.7.0/tests/parser_test.py 2020-08-04 18:20:15.000000000 +0000 +++ python-certbot-nginx-1.10.1/tests/parser_test.py 2020-12-03 18:20:10.000000000 +0000 @@ -340,7 +340,9 @@ {'*.www.eff.org', 'www.*'}, {'*.org'}, set(), - {'example.com'}] + {'example.com'}, + {'www.Eff.org'}, + {'.efF.org'}] winners = [('exact', 'www.eff.org'), (None, None), ('exact', '.www.eff.org'), @@ -353,7 +355,9 @@ ('wildcard_end', 'www.*'), ('wildcard_start', '*.org'), (None, None), - (None, None)] + (None, None), + ('exact', 'www.Eff.org'), + ('wildcard_start', '.efF.org')] for i, winner in enumerate(winners): self.assertEqual(winner, @@ -488,6 +492,14 @@ self.assertEqual(['server'], parsed[0][2][0]) self.assertEqual(['listen', '80'], parsed[0][2][1][3]) + def test_valid_unicode_roundtrip(self): + """This tests the parser's ability to load and save a config containing Unicode""" + nparser = parser.NginxParser(self.config_path) + nparser._parse_files( + nparser.abs_path('valid_unicode_comments.conf') + ) # pylint: disable=protected-access + nparser.filedump(lazy=False) + def test_invalid_unicode_characters(self): with self.assertLogs() as log: nparser = parser.NginxParser(self.config_path)