From 156434b9524b2b0d09cccf9bb66b76ac9b51ca27 Mon Sep 17 00:00:00 2001 From: missytake Date: Mon, 11 Dec 2023 18:47:53 +0100 Subject: [PATCH] cmdeploy: move max_mailbox_size + delete_mails_after to chatmail.ini --- chatmaild/src/chatmaild/config.py | 2 ++ chatmaild/src/chatmaild/ini/chatmail.ini.f | 21 +++++++++++++++++++ cmdeploy/src/cmdeploy/__init__.py | 13 ++++++------ cmdeploy/src/cmdeploy/dovecot/dovecot.conf.j2 | 6 +++--- cmdeploy/src/cmdeploy/dovecot/expunge.cron | 4 ---- cmdeploy/src/cmdeploy/dovecot/expunge.cron.j2 | 4 ++++ 6 files changed, 36 insertions(+), 14 deletions(-) delete mode 100644 cmdeploy/src/cmdeploy/dovecot/expunge.cron create mode 100644 cmdeploy/src/cmdeploy/dovecot/expunge.cron.j2 diff --git a/chatmaild/src/chatmaild/config.py b/chatmaild/src/chatmaild/config.py index 16bb14a8..7781c4d8 100644 --- a/chatmaild/src/chatmaild/config.py +++ b/chatmaild/src/chatmaild/config.py @@ -11,6 +11,8 @@ class Config: self._inipath = inipath self.mail_domain = params["mail_domain"] self.max_user_send_per_minute = int(params["max_user_send_per_minute"]) + self.max_mailbox_size = params["max_mailbox_size"] + self.delete_mails_after = params["delete_mails_after"] self.filtermail_smtp_port = int(params["filtermail_smtp_port"]) self.postfix_reinject_port = int(params["postfix_reinject_port"]) self.passthrough_recipients = params["passthrough_recipients"].split() diff --git a/chatmaild/src/chatmaild/ini/chatmail.ini.f b/chatmaild/src/chatmaild/ini/chatmail.ini.f index ba578c73..2ca0e23f 100644 --- a/chatmaild/src/chatmaild/ini/chatmail.ini.f +++ b/chatmaild/src/chatmaild/ini/chatmail.ini.f @@ -7,18 +7,39 @@ mail_domain = {mail_domain} # If you only do private test deploys, you don't need to modify any settings below # +# +# Account Restrictions +# + # how many mails a user can send out per minute max_user_send_per_minute = 60 +# maximum mailbox size of a chatmail account +max_mailbox_size = 100M + +# time after which seen mails are deleted +delete_mails_after = 40d + +# list of chatmail accounts which can send unencrypted mail +#passthrough_senders (not implemented yet) + # list of e-mail recipients for which to accept outbound un-encrypted mails passthrough_recipients = +# +# Deployment Details +# + # where the filtermail SMTP service listens filtermail_smtp_port = 10080 # postfix accepts on the localhost reinject SMTP port postfix_reinject_port = 10025 +# +# Privacy Policy +# + # postal address of privacy contact privacy_postal = diff --git a/cmdeploy/src/cmdeploy/__init__.py b/cmdeploy/src/cmdeploy/__init__.py index f8d39886..766edfd1 100644 --- a/cmdeploy/src/cmdeploy/__init__.py +++ b/cmdeploy/src/cmdeploy/__init__.py @@ -243,7 +243,7 @@ def _configure_postfix(config: Config, debug: bool = False) -> bool: return need_restart -def _configure_dovecot(mail_server: str, debug: bool = False) -> bool: +def _configure_dovecot(config: Config, debug: bool = False) -> bool: """Configures Dovecot IMAP server.""" need_restart = False @@ -253,7 +253,7 @@ def _configure_dovecot(mail_server: str, debug: bool = False) -> bool: user="root", group="root", mode="644", - config={"hostname": mail_server}, + config=config, debug=debug, ) need_restart |= main_config.changed @@ -266,14 +266,13 @@ def _configure_dovecot(mail_server: str, debug: bool = False) -> bool: ) need_restart |= auth_config.changed - files.put( - src=importlib.resources.files(__package__) - .joinpath("dovecot/expunge.cron") - .open("rb"), + files.template( + src=importlib.resources.files(__package__).joinpath("dovecot/expunge.cron.j2"), dest="/etc/cron.d/expunge", user="root", group="root", mode="644", + config=config, ) # as per https://doc.dovecot.org/configuration_manual/os/ @@ -423,7 +422,7 @@ def deploy_chatmail(mail_domain: str, mail_server: str, dkim_selector: str) -> N _install_remote_venv_with_chatmaild(config) debug = False - dovecot_need_restart = _configure_dovecot(mail_server, debug=debug) + dovecot_need_restart = _configure_dovecot(config, debug=debug) postfix_need_restart = _configure_postfix(config, debug=debug) opendkim_need_restart = _configure_opendkim(mail_domain, dkim_selector) mta_sts_need_restart = _install_mta_sts_daemon() diff --git a/cmdeploy/src/cmdeploy/dovecot/dovecot.conf.j2 b/cmdeploy/src/cmdeploy/dovecot/dovecot.conf.j2 index b2d3ccb1..97cd27e3 100644 --- a/cmdeploy/src/cmdeploy/dovecot/dovecot.conf.j2 +++ b/cmdeploy/src/cmdeploy/dovecot/dovecot.conf.j2 @@ -86,7 +86,7 @@ plugin { plugin { # for now we define static quota-rules for all users quota = maildir:User quota - quota_rule = *:storage=100M + quota_rule = *:storage={{ config.max_mailbox_size }} quota_max_mail_size=30M quota_grace = 0 # quota_over_flag_value = TRUE @@ -137,8 +137,8 @@ service imap-login { } ssl = required -ssl_cert =