From 1b5e99c56e7fcba5c3cd765550b780bc90b079f9 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 16 Feb 2022 09:33:35 -0800 Subject: [PATCH] email: Rename audit module to privileged The module does not interact with kernel audit system or is not related to security logging. The 'privileged' makes us pay more attension. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- actions/email | 8 ++++---- plinth/modules/email/__init__.py | 14 +++++++------- plinth/modules/email/dns.py | 6 +++--- .../email/{audit => privileged}/__init__.py | 0 .../modules/email/{audit => privileged}/aliases.py | 0 plinth/modules/email/{audit => privileged}/dkim.py | 0 .../modules/email/{audit => privileged}/domain.py | 0 plinth/modules/email/{audit => privileged}/home.py | 0 plinth/modules/email/{audit => privileged}/ldap.py | 0 plinth/modules/email/{audit => privileged}/spam.py | 0 plinth/modules/email/{audit => privileged}/tls.py | 0 plinth/modules/email/views.py | 6 +++--- 12 files changed, 17 insertions(+), 17 deletions(-) rename plinth/modules/email/{audit => privileged}/__init__.py (100%) rename plinth/modules/email/{audit => privileged}/aliases.py (100%) rename plinth/modules/email/{audit => privileged}/dkim.py (100%) rename plinth/modules/email/{audit => privileged}/domain.py (100%) rename plinth/modules/email/{audit => privileged}/home.py (100%) rename plinth/modules/email/{audit => privileged}/ldap.py (100%) rename plinth/modules/email/{audit => privileged}/spam.py (100%) rename plinth/modules/email/{audit => privileged}/tls.py (100%) diff --git a/actions/email b/actions/email index 8bf68630c..28704472b 100755 --- a/actions/email +++ b/actions/email @@ -10,7 +10,7 @@ import os import sys import plinth.log -from plinth.modules.email import audit +from plinth.modules.email import privileged EXIT_SYNTAX = 10 EXIT_PERM = 20 @@ -42,12 +42,12 @@ def _call(module_name, action_name, arguments): logger.critical('This action is reserved for root') sys.exit(EXIT_PERM) - # We only run actions defined in the audit module - if module_name not in audit.__all__: + # We only run actions defined in the privileged module + if module_name not in privileged.__all__: logger.critical('Bad module name: %r', module_name) sys.exit(EXIT_SYNTAX) - module = getattr(audit, module_name) + module = getattr(privileged, module_name) try: action = getattr(module, 'action_' + action_name) except AttributeError: diff --git a/plinth/modules/email/__init__.py b/plinth/modules/email/__init__.py index 1a743a27c..73226dfea 100644 --- a/plinth/modules/email/__init__.py +++ b/plinth/modules/email/__init__.py @@ -19,7 +19,7 @@ from plinth.modules.letsencrypt.components import LetsEncrypt from plinth.package import Packages, remove from plinth.signals import domain_added, domain_removed -from . import audit, manifest +from . import manifest, privileged _description = [ _('This is a complete email server solution using Postfix, Dovecot, ' @@ -176,12 +176,12 @@ def setup(helper, old_version=None): app.setup(old_version) # Setup - helper.call('post', audit.home.repair) + helper.call('post', privileged.home.repair) app.get_component('letsencrypt-email-postfix').setup_certificates() app.get_component('letsencrypt-email-dovecot').setup_certificates() - helper.call('post', audit.domain.set_domains) - helper.call('post', audit.ldap.repair) - helper.call('post', audit.spam.repair) + helper.call('post', privileged.domain.set_domains) + helper.call('post', privileged.ldap.repair) + helper.call('post', privileged.spam.repair) # Reload actions.superuser_run('service', ['reload', 'postfix']) @@ -198,7 +198,7 @@ def on_domain_added(sender, domain_type, name, description='', services=None, if app.needs_setup(): return - audit.domain.set_domains() + privileged.domain.set_domains() def on_domain_removed(sender, domain_type, name='', **kwargs): @@ -206,4 +206,4 @@ def on_domain_removed(sender, domain_type, name='', **kwargs): if app.needs_setup(): return - audit.domain.set_domains() + privileged.domain.set_domains() diff --git a/plinth/modules/email/dns.py b/plinth/modules/email/dns.py index 0b0a19fd1..c84c59051 100644 --- a/plinth/modules/email/dns.py +++ b/plinth/modules/email/dns.py @@ -37,9 +37,9 @@ class Entry: # pylint: disable=too-many-instance-attributes def get_entries(): """Return the list of DNS entries to make.""" - from . import audit + from . import privileged - domain = audit.domain.get_domains()['primary_domain'] + domain = privileged.domain.get_domains()['primary_domain'] mx_spam_entries = [ Entry(type_='MX', value=f'{domain}.'), Entry(type_='TXT', value='v=spf1 mx a ~all'), @@ -49,7 +49,7 @@ def get_entries(): f'rua=mailto:postmaster@{domain}; ') ] try: - dkim_public_key = audit.dkim.get_public_key(domain) + dkim_public_key = privileged.dkim.get_public_key(domain) dkim_entries = [ Entry(domain='dkim._domainkey', type_='TXT', value=f'v=DKIM1; k=rsa; p={dkim_public_key}') diff --git a/plinth/modules/email/audit/__init__.py b/plinth/modules/email/privileged/__init__.py similarity index 100% rename from plinth/modules/email/audit/__init__.py rename to plinth/modules/email/privileged/__init__.py diff --git a/plinth/modules/email/audit/aliases.py b/plinth/modules/email/privileged/aliases.py similarity index 100% rename from plinth/modules/email/audit/aliases.py rename to plinth/modules/email/privileged/aliases.py diff --git a/plinth/modules/email/audit/dkim.py b/plinth/modules/email/privileged/dkim.py similarity index 100% rename from plinth/modules/email/audit/dkim.py rename to plinth/modules/email/privileged/dkim.py diff --git a/plinth/modules/email/audit/domain.py b/plinth/modules/email/privileged/domain.py similarity index 100% rename from plinth/modules/email/audit/domain.py rename to plinth/modules/email/privileged/domain.py diff --git a/plinth/modules/email/audit/home.py b/plinth/modules/email/privileged/home.py similarity index 100% rename from plinth/modules/email/audit/home.py rename to plinth/modules/email/privileged/home.py diff --git a/plinth/modules/email/audit/ldap.py b/plinth/modules/email/privileged/ldap.py similarity index 100% rename from plinth/modules/email/audit/ldap.py rename to plinth/modules/email/privileged/ldap.py diff --git a/plinth/modules/email/audit/spam.py b/plinth/modules/email/privileged/spam.py similarity index 100% rename from plinth/modules/email/audit/spam.py rename to plinth/modules/email/privileged/spam.py diff --git a/plinth/modules/email/audit/tls.py b/plinth/modules/email/privileged/tls.py similarity index 100% rename from plinth/modules/email/audit/tls.py rename to plinth/modules/email/privileged/tls.py diff --git a/plinth/modules/email/views.py b/plinth/modules/email/views.py index 3a8446c94..70d8b4dd2 100644 --- a/plinth/modules/email/views.py +++ b/plinth/modules/email/views.py @@ -13,7 +13,7 @@ from plinth.modules.email import dns from plinth.views import AppView from . import aliases as aliases_module -from . import audit, forms +from . import forms, privileged class EmailAppView(AppView): @@ -31,7 +31,7 @@ class EmailAppView(AppView): def get_initial(self): """Return the initial values to populate in the form.""" initial = super().get_initial() - domains = audit.domain.get_domains() + domains = privileged.domain.get_domains() initial['primary_domain'] = domains['primary_domain'] return initial @@ -41,7 +41,7 @@ class EmailAppView(AppView): new_data = form.cleaned_data if old_data['primary_domain'] != new_data['primary_domain']: try: - audit.domain.set_domains(new_data['primary_domain']) + privileged.domain.set_domains(new_data['primary_domain']) messages.success(self.request, _('Configuration updated')) except Exception: messages.error(self.request,