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 <github@hoffman-andrews.com>
This commit is contained in:
Will Greenberg 2025-12-10 08:35:35 -08:00 committed by GitHub
parent d3c30cfb2d
commit 305ebe1c16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 3 deletions

View file

@ -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

View file

@ -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):

View file

@ -0,0 +1 @@
Fixed a regression that caused certbot to crash if multiple --webroot-path values were set on the command line.