From 305ebe1c16772ae42f7bdc4927aecd3c73f8ae58 Mon Sep 17 00:00:00 2001 From: Will Greenberg Date: Wed, 10 Dec 2025 08:35:35 -0800 Subject: [PATCH] Fix --webroot-path action (#10509) (#10510) Cherry-picks #10509 which fixes #10506. This will eventually make its way into the 5.2.2 point release Co-authored-by: Jacob Hoffman-Andrews --- certbot/src/certbot/_internal/plugins/webroot.py | 2 +- certbot/src/certbot/_internal/tests/plugins/webroot_test.py | 4 ++-- newsfragments/10509.fixed | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 newsfragments/10509.fixed diff --git a/certbot/src/certbot/_internal/plugins/webroot.py b/certbot/src/certbot/_internal/plugins/webroot.py index 717a08212..8f2d6c9de 100644 --- a/certbot/src/certbot/_internal/plugins/webroot.py +++ b/certbot/src/certbot/_internal/plugins/webroot.py @@ -320,7 +320,7 @@ class _WebrootPathAction(argparse.Action): # domains before setting the new webroot path prev_webroot = namespace.webroot_path[-1] for domain in namespace.domains: - namespace.webroot_map.setdefault(domain, prev_webroot) + namespace.webroot_map.setdefault(domain.dns_name, prev_webroot) elif namespace.domains: self._domain_before_webroot = True diff --git a/certbot/src/certbot/_internal/tests/plugins/webroot_test.py b/certbot/src/certbot/_internal/tests/plugins/webroot_test.py index 713f47043..892cd7400 100644 --- a/certbot/src/certbot/_internal/tests/plugins/webroot_test.py +++ b/certbot/src/certbot/_internal/tests/plugins/webroot_test.py @@ -20,6 +20,7 @@ from certbot import errors from certbot.compat import filesystem from certbot.compat import os from certbot.display import util as display_util +from certbot._internal import cli from certbot.tests import acme_util from certbot.tests import util as test_util @@ -302,7 +303,6 @@ class AuthenticatorTest(unittest.TestCase): assert not os.path.exists(self.validation_path) assert os.path.exists(self.root_challenge_path) - class WebrootActionTest(unittest.TestCase): """Tests for webroot argparse actions.""" @@ -314,7 +314,7 @@ class WebrootActionTest(unittest.TestCase): self.path = tempfile.mkdtemp() self.parser = argparse.ArgumentParser() self.parser.add_argument("-d", "--domains", - action="append", default=[]) + action=cli._DomainsAction, default=[]) Authenticator.inject_parser_options(self.parser, "webroot") def test_webroot_map_action(self): diff --git a/newsfragments/10509.fixed b/newsfragments/10509.fixed new file mode 100644 index 000000000..4842fe710 --- /dev/null +++ b/newsfragments/10509.fixed @@ -0,0 +1 @@ +Fixed a regression that caused certbot to crash if multiple --webroot-path values were set on the command line.