From 83cca81192fd5f814360d8c0c8474839c3c6c480 Mon Sep 17 00:00:00 2001 From: Joel Gerber Date: Thu, 20 Jul 2017 22:54:56 -0400 Subject: [PATCH] Fix bug with passed PATH in environment Since we're now passing the environment in, we also have to pass the PATH. Might want to write up a system test for this type of thing in the future. --- lets_do_dns/acme_dns_auth/authenticate.py | 5 ++++- tests/unit/acme_dns_auth/authenticate/test_cleanup_stage.py | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lets_do_dns/acme_dns_auth/authenticate.py b/lets_do_dns/acme_dns_auth/authenticate.py index 3b75e87..7e915af 100644 --- a/lets_do_dns/acme_dns_auth/authenticate.py +++ b/lets_do_dns/acme_dns_auth/authenticate.py @@ -40,7 +40,10 @@ def _delete_resource(self): def _run_post_cmd(self): if self._env.post_cmd: run(self._env.post_cmd, - env={'CERTBOT_HOSTNAME': self._env.fqdn}) + env={'CERTBOT_HOSTNAME': self._env.fqdn, + 'PATH': ["/bin", "/sbin", + "/usr/bin", "/usr/sbin", + "/usr/local/bin", "/usr/local/sbin"]}) def _create_resource(self): self._resource.create() diff --git a/tests/unit/acme_dns_auth/authenticate/test_cleanup_stage.py b/tests/unit/acme_dns_auth/authenticate/test_cleanup_stage.py index 1281b6d..3601713 100644 --- a/tests/unit/acme_dns_auth/authenticate/test_cleanup_stage.py +++ b/tests/unit/acme_dns_auth/authenticate/test_cleanup_stage.py @@ -73,4 +73,8 @@ def test_passes_postcmd_to_run(mocker, fqdn): authentication.perform() mock_run.assert_called_once_with( - 'test-program --help', env={'CERTBOT_HOSTNAME': fqdn}) + 'test-program --help', + env={'CERTBOT_HOSTNAME': fqdn, + 'PATH': ["/bin", "/sbin", + "/usr/bin", "/usr/sbin", + "/usr/local/bin", "/usr/local/sbin"]})