From fa15146aafe1fd393280cffd013f85365d8623b3 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 17 Jun 2023 11:45:11 -0400 Subject: fix up some more mailu config --- modules/mail/files/learn_spam | 28 ------ modules/mail/files/milter_headers.conf | 4 - modules/mail/files/patch/dovecot.conf | 159 --------------------------------- modules/mail/files/patch/ham | 5 -- modules/mail/files/patch/learn.sieve | 23 ----- modules/mail/files/patch/spam | 5 -- modules/mail/manifests/mailu.pp | 24 ++--- 7 files changed, 14 insertions(+), 234 deletions(-) delete mode 100644 modules/mail/files/learn_spam delete mode 100644 modules/mail/files/patch/dovecot.conf delete mode 100755 modules/mail/files/patch/ham delete mode 100644 modules/mail/files/patch/learn.sieve delete mode 100755 modules/mail/files/patch/spam (limited to 'modules/mail') diff --git a/modules/mail/files/learn_spam b/modules/mail/files/learn_spam deleted file mode 100644 index ccdc999..0000000 --- a/modules/mail/files/learn_spam +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -set -eu -set -o pipefail - -cd /media/persistent -mkdir -p mail/tmp -dir=$(mktemp -d -p /media/persistent/mail/tmp learnspam.XXXXXXXX) -trap 'rm -rf $dir' EXIT - -ham="${dir}/ham" -spam="${dir}/spam" -mkdir "$ham" "$spam" - -container_dir="${dir#/media/persistent}" -container_ham="${container_dir}/ham" -container_spam="${container_dir}/spam" - -find /media/persistent/mail -type f -mtime -30 | grep /cur/ | grep -v Sent | grep -v Junk | xargs -i ln {} "${dir}/ham" -find /media/persistent/mail -type f -mtime -30 | grep /cur/ | grep -v Sent | grep Junk | xargs -i ln {} "${dir}/spam" - -docker-compose exec imap rspamc -h antispam:11334 -P mailu learn_ham "$container_ham" > /dev/null || true -docker-compose exec imap rspamc -h antispam:11334 -P mailu learn_spam "$container_spam" > /dev/null || true - -docker-compose exec imap rspamc -h antispam:11334 -P mailu -f 13 fuzzy_add "$container_ham" > /dev/null || true -docker-compose exec imap rspamc -h antispam:11334 -P mailu -f 11 fuzzy_del "$container_ham" > /dev/null || true - -docker-compose exec imap rspamc -h antispam:11334 -P mailu -f 11 fuzzy_add "$container_spam" > /dev/null || true -docker-compose exec imap rspamc -h antispam:11334 -P mailu -f 13 fuzzy_del "$container_spam" > /dev/null || true diff --git a/modules/mail/files/milter_headers.conf b/modules/mail/files/milter_headers.conf index 9ff81da..f9e8b50 100644 --- a/modules/mail/files/milter_headers.conf +++ b/modules/mail/files/milter_headers.conf @@ -1,5 +1 @@ -authenticated_headers = ["authentication-results"]; -skip_local = false; -skip_authenticated = false; - use = ["x-spamd-result", "x-spam-status", "authentication-results"]; diff --git a/modules/mail/files/patch/dovecot.conf b/modules/mail/files/patch/dovecot.conf deleted file mode 100644 index e0b0728..0000000 --- a/modules/mail/files/patch/dovecot.conf +++ /dev/null @@ -1,159 +0,0 @@ -############### -# General -############### -log_path = /dev/stderr -protocols = imap pop3 lmtp sieve -postmaster_address = {{ POSTMASTER }}@{{ DOMAIN }} -hostname = {{ HOSTNAMES.split(",")[0] }} -submission_host = {{ FRONT_ADDRESS }} - -############### -# Mailboxes -############### -first_valid_gid = 8 -first_valid_uid = 8 -mail_location = maildir:/mail/%u -mail_home = /mail/%u -mail_uid = mail -mail_gid = mail -mail_privileged_group = mail -mail_access_groups = mail -maildir_stat_dirs = yes -mailbox_list_index = yes -mail_vsize_bg_after_count = 100 -mail_plugins = $mail_plugins quota quota_clone zlib - -namespace inbox { - inbox = yes - {% for mailbox in ("Trash", "Drafts", "Sent", "Junk") %} - mailbox {{ mailbox }} { - auto = subscribe - special_use = \{{ mailbox }} - } - {% endfor %} -} - -plugin { - quota = count:User quota - quota_vsizes = yes - quota_clone_dict = proxy:/tmp/podop.socket:quota - - {% if COMPRESSION in [ 'gz', 'bz2' ] %} - zlib_save = {{ COMPRESSION }} - {% endif %} - - {% if COMPRESSION_LEVEL %} - zlib_save_level = {{ COMPRESSION_LEVEL }} - {% endif %} -} - -############### -# Authentication -############### -auth_username_chars = -auth_mechanisms = plain login -disable_plaintext_auth = no - -passdb { - driver = dict - args = /etc/dovecot/auth.conf -} - -userdb { - driver = dict - args = /etc/dovecot/auth.conf -} - -service auth { - user = dovecot - unix_listener auth-userdb { - } -} - -service auth-worker { - unix_listener auth-worker { - user = dovecot - group = mail - mode = 0660 - } - user = mail -} - -############### -# IMAP & POP -############### -protocol imap { - mail_plugins = $mail_plugins imap_quota imap_sieve - mail_max_userip_connections = 20 -} - -protocol pop3 { - -} - -service imap-login { - inet_listener imap { - port = 143 - } -} - -############### -# Delivery -############### -protocol lmtp { - mail_plugins = $mail_plugins sieve - recipient_delimiter = {{ RECIPIENT_DELIMITER }} -} - -service lmtp { - inet_listener lmtp { - port = 2525 - } -} - -############### -# Filtering -############### -service managesieve-login { - inet_listener sieve { - port = 4190 - } -} - -service managesieve { -} - -plugin { - sieve = file:~/sieve;active=~/.dovecot.sieve - sieve_before = dict:proxy:/tmp/podop.socket:sieve - sieve_plugins = sieve_imapsieve sieve_extprograms - sieve_extensions = +spamtest +spamtestplus +editheader - sieve_global_extensions = +vnd.dovecot.execute - - # Sieve execute - sieve_execute_bin_dir = /conf/bin - - # Send vacation replies even for aliases - # See the Pigeonhole documentation about warnings: http://wiki2.dovecot.org/Pigeonhole/Sieve/Extensions/Vacation - # It appears that our implemntation of mail delivery meets criteria of section 4.5 - # from RFC 5230 and that disabling the recipient checks is not an issue here. - sieve_vacation_dont_check_recipient = yes - - # Include the recipient in vacation replies so that DKIM applies - sieve_vacation_send_from_recipient = yes - - # extract spam score from headers - sieve_spamtest_status_type = strlen - sieve_spamtest_status_header = X-Spam-Level - sieve_spamtest_max_value = 15 - - # Learn from spam - imapsieve_mailbox1_name = * - imapsieve_mailbox1_before = file:/conf/learn.sieve -} - -############### -# Extensions -############### - -!include_try /overrides/dovecot.conf diff --git a/modules/mail/files/patch/ham b/modules/mail/files/patch/ham deleted file mode 100755 index 815e538..0000000 --- a/modules/mail/files/patch/ham +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -tee >(rspamc -h antispam:11334 -P mailu learn_ham /dev/stdin) \ - >(rspamc -h antispam:11334 -P mailu -f 11 fuzzy_del /dev/stdin) \ - >(rspamc -h antispam:11334 -P mailu -f 13 fuzzy_add /dev/stdin) diff --git a/modules/mail/files/patch/learn.sieve b/modules/mail/files/patch/learn.sieve deleted file mode 100644 index eb952ad..0000000 --- a/modules/mail/files/patch/learn.sieve +++ /dev/null @@ -1,23 +0,0 @@ -require ["vnd.dovecot.execute", "vnd.dovecot.debug", "imap4flags", "imapsieve", "environment", "variables"]; - -if environment :matches "imap.mailbox" "*" { - set "mailbox" "${1}"; - debug_log "running for mailbox ${mailbox}"; -} - -if string "${mailbox}" "Junk" { - debug_log "categorizing as spam"; - setflag "\\seen"; - execute :pipe "spam"; -} -else { - if string "${mailbox}" "Trash" { - debug_log "categorizing as trash"; - stop; - } - - debug_log "categorizing as ham"; - execute :pipe "ham"; -} - -debug_log "done"; diff --git a/modules/mail/files/patch/spam b/modules/mail/files/patch/spam deleted file mode 100755 index a2421ba..0000000 --- a/modules/mail/files/patch/spam +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -tee >(rspamc -h antispam:11334 -P mailu learn_spam /dev/stdin) \ - >(rspamc -h antispam:11334 -P mailu -f 13 fuzzy_del /dev/stdin) \ - >(rspamc -h antispam:11334 -P mailu -f 11 fuzzy_add /dev/stdin) diff --git a/modules/mail/manifests/mailu.pp b/modules/mail/manifests/mailu.pp index 5a9a40f..de4ee69 100644 --- a/modules/mail/manifests/mailu.pp +++ b/modules/mail/manifests/mailu.pp @@ -19,9 +19,7 @@ class mail::mailu { } cron::job { "learn_spam": - frequency => "daily", - source => 'puppet:///modules/mail/learn_spam', - require => Service['mailu']; + ensure => absent; } exec { "generate mailu secret key": @@ -65,12 +63,13 @@ class mail::mailu { "/media/persistent/overrides": ensure => directory, require => Class["mail::persistent"]; + "/media/persistent/overrides/dovecot": + ensure => directory, + require => Class["mail::persistent"]; "/media/persistent/overrides/dovecot/dovecot.conf": source => "puppet:///modules/mail/dovecot.conf", - require => File["/media/persistent/overrides"], + require => File["/media/persistent/overrides/dovecot"], notify => Service["mailu"]; - "/media/persistent/overrides/dovecot.conf": - ensure => absent; "/media/persistent/overrides/rspamd": ensure => directory, require => File["/media/persistent/overrides"]; @@ -79,22 +78,27 @@ class mail::mailu { require => File["/media/persistent/overrides/rspamd"], notify => Service["mailu"]; "/media/persistent/overrides/sieve": + ensure => absent; + "/media/persistent/overrides/dovecot/sieve": ensure => directory, owner => 'mail', group => 'mail', - require => File["/media/persistent/overrides"]; + require => File["/media/persistent/overrides/dovecot"]; } - secret { "/media/persistent/overrides/sieve/filters.sieve": + secret { "/media/persistent/overrides/dovecot/sieve/filters.sieve": owner => 'mail', group => 'mail', source => 'sieve', - require => File["/media/persistent/overrides/sieve"], + require => File["/media/persistent/overrides/dovecot/sieve"], notify => Exec["compile sieve scripts"]; } + secret { "/media/persistent/overrides/sieve/filters.sieve": + ensure => absent; + } exec { "compile sieve scripts": - command => "/usr/bin/docker-compose exec -T -u mail imap sievec /overrides/sieve/filters.sieve", + command => "/usr/bin/docker-compose exec -T -u mail imap sievec /overrides/dovecot/sieve/filters.sieve", cwd => "/media/persistent", refreshonly => true, tries => 12, -- cgit v1.2.3-54-g00ecf