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 <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
James Valleroy 2024-12-30 08:55:46 -05:00 committed by Sunil Mohan Adapa
parent 2274711c19
commit 79999a9090
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 24 additions and 0 deletions

View File

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

View File

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