From 58c7de8d66bfa2b7fe25a8ea8163cab271ae257d Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Sat, 7 Sep 2024 10:05:37 -0400 Subject: [PATCH] letsencrypt: Handle both standard and custom repairs Pass remaining failed checks to super. Tests: - Remove /etc/letsencrypt/renewal-hooks/deploy/50-freedombox so that the diagnostic fails. Running repair causes the file to be re-created. - Set domain name to non-existing domain so that the diagnostic fails. Running repair attempts to obtain the certificate. - Have both diagnostics failing. Running repair will attempt to repair both. Signed-off-by: James Valleroy Reviewed-by: Sunil Mohan Adapa --- plinth/modules/letsencrypt/__init__.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/plinth/modules/letsencrypt/__init__.py b/plinth/modules/letsencrypt/__init__.py index 39c7014af..0066385cf 100644 --- a/plinth/modules/letsencrypt/__init__.py +++ b/plinth/modules/letsencrypt/__init__.py @@ -104,18 +104,16 @@ class LetsEncryptApp(app_module.App): return results def repair(self, failed_checks: list) -> bool: - """Try to repair failed diagnostics. - - Returns whether the app setup should be re-run. - """ + """Handle repair for custom diagnostic.""" status = get_status() - - # Obtain/re-obtain certificates for failing domains - for failed_check in failed_checks: - if not failed_check.check_id.startswith('letsencrypt-domain'): + remaining_checks = [] + for check in failed_checks: + if not check.check_id.startswith('letsencrypt-domain'): + remaining_checks.append(check) continue - domain = failed_check.parameters['domain'] + # Obtain/re-obtain certificates for failing domains + domain = check.parameters['domain'] try: domain_status = status['domains'][domain] if domain_status.get('certificate_available', False): @@ -128,7 +126,7 @@ class LetsEncryptApp(app_module.App): # Add the error message to thread local storage store_error_message(str(error)) - return False + return super().repair(remaining_checks) def setup(self, old_version): """Install and configure the app."""