apache: Use privileged decorator for actions

Tests:

- Initial setup works when a new container is created
- When transmission is enabled/disabled, the web configuration for it is
  enabled/disabled.
- When radicale is enabled/disabled, the uwsgi configuration for it is
  enabled/disabled.
- Sharing web configuration is disabled during backup and re-enabled.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2022-10-08 18:51:15 -04:00
1 parent fdbe537529
commit 3e2900b48b
6 files changed
+66 -120

No files matched your search

+8 -13
View File
@@ -1,7 +1,5 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
App component for other apps to use Apache configuration functionality.
"""
"""App component for other apps to use Apache configuration functionality."""
import re
import subprocess
@@ -9,7 +7,9 @@ import subprocess
from django.utils.text import format_lazy
from django.utils.translation import gettext_lazy
from plinth import action_utils, actions, app
from plinth import action_utils, app
from . import privileged
class Webserver(app.LeaderComponent):
@@ -47,14 +47,11 @@ class Webserver(app.LeaderComponent):
def enable(self):
"""Enable the Apache configuration."""
actions.superuser_run(
'apache', ['enable', '--name', self.web_name, '--kind', self.kind])
privileged.enable(self.web_name, self.kind)
def disable(self):
"""Disable the Apache configuration."""
actions.superuser_run(
'apache',
['disable', '--name', self.web_name, '--kind', self.kind])
privileged.disable(self.web_name, self.kind)
def diagnose(self):
"""Check if the web path is accessible by clients.
@@ -99,13 +96,11 @@ class Uwsgi(app.LeaderComponent):
def enable(self):
"""Enable the uWSGI configuration."""
actions.superuser_run('apache',
['uwsgi-enable', '--name', self.uwsgi_name])
privileged.uwsgi_enable(self.uwsgi_name)
def disable(self):
"""Disable the uWSGI configuration."""
actions.superuser_run('apache',
['uwsgi-disable', '--name', self.uwsgi_name])
privileged.uwsgi_disable(self.uwsgi_name)
def is_running(self):
"""Return whether the uWSGI daemon is running with configuration."""