diff options
author | Erica Portnoy <ebportnoy@gmail.com> | 2017-02-28 00:35:29 +0300 |
---|---|---|
committer | Brad Warren <bmw@users.noreply.github.com> | 2017-02-28 00:35:29 +0300 |
commit | e5909d379c5e0144481c7c848ccf1c13b71c2a73 (patch) | |
tree | 09447807b6359f36ef0f5ce4a1cc836f18fc9432 /certbot-nginx | |
parent | 7d02e129f9e0fd9abed850621d78e91dd7684ff8 (diff) |
Don't crash on listen unix: (#4259)
Fixes #4225.
* don't crash on listen unix:
* correctly merge #4221
Diffstat (limited to 'certbot-nginx')
-rw-r--r-- | certbot-nginx/certbot_nginx/parser.py | 7 | ||||
-rw-r--r-- | certbot-nginx/certbot_nginx/tests/parser_test.py | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/certbot-nginx/certbot_nginx/parser.py b/certbot-nginx/certbot_nginx/parser.py index c586aa459..eddc7b9b0 100644 --- a/certbot-nginx/certbot_nginx/parser.py +++ b/certbot-nginx/certbot_nginx/parser.py @@ -586,9 +586,10 @@ def _parse_server_raw(server): continue if directive[0] == 'listen': addr = obj.Addr.fromstring(directive[1]) - parsed_server['addrs'].add(addr) - if addr.ssl: - parsed_server['ssl'] = True + if addr: + parsed_server['addrs'].add(addr) + if addr.ssl: + parsed_server['ssl'] = True elif directive[0] == 'server_name': parsed_server['names'].update( _get_servernames(directive[1])) diff --git a/certbot-nginx/certbot_nginx/tests/parser_test.py b/certbot-nginx/certbot_nginx/tests/parser_test.py index 921cc3c5a..6a3f2f1de 100644 --- a/certbot-nginx/certbot_nginx/tests/parser_test.py +++ b/certbot-nginx/certbot_nginx/tests/parser_test.py @@ -323,6 +323,12 @@ class NginxParserTest(util.NginxTest): ]) self.assertTrue(server['ssl']) + def test_parse_server_raw_unix(self): + server = parser._parse_server_raw([ #pylint: disable=protected-access + ['listen', 'unix:/var/run/nginx.sock'] + ]) + self.assertEqual(len(server['addrs']), 0) + def test_parse_server_global_ssl_applied(self): nparser = parser.NginxParser(self.config_path, self.ssl_options) server = nparser.parse_server([ |