From 79999a90909d7a028d7d3b9fa2aa7dd47f646597 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Mon, 30 Dec 2024 08:55:46 -0500 Subject: [PATCH] mumble: Add diagnostic for setup config changes Tests: - Modify or remove the sslCert/sslKey lines in mumble-server.ini. The diagnostic is failed. After repair, the expected lines are restored, and the diagnostic is passed. Signed-off-by: James Valleroy Reviewed-by: Sunil Mohan Adapa --- plinth/modules/mumble/__init__.py | 15 +++++++++++++++ plinth/modules/mumble/privileged.py | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/plinth/modules/mumble/__init__.py b/plinth/modules/mumble/__init__.py index 3d07a120c..39427e6e1 100644 --- a/plinth/modules/mumble/__init__.py +++ b/plinth/modules/mumble/__init__.py @@ -7,10 +7,12 @@ import pathlib from django.urls import reverse_lazy from django.utils.translation import gettext_lazy as _ +from django.utils.translation import gettext_noop from plinth import app as app_module from plinth import frontpage, menu from plinth.daemon import Daemon +from plinth.diagnostic_check import DiagnosticCheck, Result from plinth.modules import names from plinth.modules.backups.components import BackupRestore from plinth.modules.firewall.components import Firewall @@ -113,6 +115,12 @@ class MumbleApp(app_module.App): privileged.setup() return True + def diagnose(self) -> list[DiagnosticCheck]: + """Run diagnostics and return the results.""" + results = super().diagnose() + results.append(_diagnose_config()) + return results + def get_available_domains(): """Return an iterator with all domains able to have a certificate.""" @@ -140,3 +148,10 @@ def get_domains(): return [domain] return [] + + +def _diagnose_config() -> DiagnosticCheck: + """Check that configuration changes made during setup are in place.""" + result = Result.PASSED if privileged.check_setup() else Result.FAILED + return DiagnosticCheck('mumble-config', + gettext_noop('Mumble server is configured'), result) diff --git a/plinth/modules/mumble/privileged.py b/plinth/modules/mumble/privileged.py index a36a4583a..759c0eab3 100644 --- a/plinth/modules/mumble/privileged.py +++ b/plinth/modules/mumble/privileged.py @@ -25,6 +25,15 @@ def setup(): aug.save() +@privileged +def check_setup() -> bool: + """Check that setup configuration is retained.""" + aug = _load_augeas() + ssl_cert_matches = aug.get('.anon/sslCert') == DATA_DIR + '/fullchain.pem' + ssl_key_matches = aug.get('.anon/sslKey') == DATA_DIR + '/privkey.pem' + return ssl_cert_matches and ssl_key_matches + + @privileged def set_super_user_password(password: secret_str): """Set the superuser password with murmurd command."""