mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-06-10 11:00:22 +00:00
The latest version of radicale calendar server's configuration file does not parse with augeas. This is because it contains the following entry in [headers] section: Content-Security-Policy = default-src 'self'; object-src 'none' The semicolon is treated as comment by the lens which is not correct. Fix this by overriding comment_re in the lens. Tests: - Updated test case works when using augparse. - With the patch, latest upstream configuration file parses without errors. - Functional tests work for radicale in testing distribution. Without patch radicale fails to install. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
81 lines
2.0 KiB
Python
81 lines
2.0 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""Configure Radicale."""
|
|
|
|
import os
|
|
import shutil
|
|
|
|
import augeas
|
|
|
|
from plinth import action_utils
|
|
from plinth.actions import privileged
|
|
|
|
CONFIG_FILE = '/etc/radicale/config'
|
|
LOG_PATH = '/var/log/radicale'
|
|
SERVICE_NAME = 'uwsgi-app@radicale.service'
|
|
|
|
|
|
@privileged
|
|
def setup():
|
|
"""Configure authentication to Apache remote user.
|
|
|
|
For radicale < 3.5 (bookworm), this was set by configuration shipped with
|
|
Debian. For radicale >= 3.5 (trixie), this needs to be explicitly. For
|
|
simplicity, set is unconditionally.
|
|
"""
|
|
aug = load_augeas()
|
|
aug.set('auth/type', 'remote_user')
|
|
aug.set('auth/lc_username', 'True')
|
|
aug.save()
|
|
# Service is started again by socket.
|
|
action_utils.service_stop(SERVICE_NAME)
|
|
|
|
|
|
@privileged
|
|
def configure(rights_type: str):
|
|
"""Set the radicale rights type to a particular value."""
|
|
if rights_type == 'owner_only':
|
|
# Default rights file is equivalent to owner_only.
|
|
rights_type = 'from_file'
|
|
|
|
aug = load_augeas()
|
|
aug.set('rights/type', rights_type)
|
|
aug.save()
|
|
action_utils.service_stop(SERVICE_NAME)
|
|
|
|
|
|
@privileged
|
|
def fix_paths():
|
|
"""Fix log path to work around a bug."""
|
|
# Workaround for bug in radicale's uwsgi script (#931201)
|
|
if not os.path.exists(LOG_PATH):
|
|
os.makedirs(LOG_PATH)
|
|
|
|
|
|
def load_augeas():
|
|
"""Initialize Augeas."""
|
|
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
|
augeas.Augeas.NO_MODL_AUTOLOAD)
|
|
# INI file lens
|
|
aug.transform('Radicale', CONFIG_FILE)
|
|
aug.set('/augeas/context', '/files' + CONFIG_FILE)
|
|
aug.load()
|
|
return aug
|
|
|
|
|
|
def get_rights_value():
|
|
"""Returns the current Rights value."""
|
|
aug = load_augeas()
|
|
value = aug.get('rights/type')
|
|
|
|
if value == 'from_file':
|
|
# Default rights file is equivalent to owner_only.
|
|
value = 'owner_only'
|
|
|
|
return value
|
|
|
|
|
|
@privileged
|
|
def uninstall():
|
|
"""Remove all radicale collections."""
|
|
shutil.rmtree('/var/lib/private/radicale/', ignore_errors=True)
|