63 Commits
Author SHA1 Message Date
Georg Lauterbach 79b66c8b89 config(dovecot)!: ship a self-reliant configuration (#4861)
* breaking(dovecot): ship a self-reliant Dovecot configuration

DMS imported the config files of Debian's Dovecot package at build time
and patched them with `sed` at startup. For the Dovecot Community Edition
(CE) it even downloaded Debian's packages only to extract their config.
The result depended on whatever the packages shipped, and every feature
toggle was an `!include` line that a script had to comment or uncomment.

Provide the complete configuration in the repository instead:

- `target/dovecot/dovecot.conf` replaces the `10-*`, `15-*`, `20-*` and
  `90-*` files as well as the `*.inc` files. Everything that is not set
  there uses Dovecot's built-in defaults.
- `target/dovecot/features/` holds the optional parts (passwd-file, LDAP
  and OAuth2 authentication, quotas, Rspamd learning). Startup copies the
  ones that are enabled into the empty `/etc/dovecot/conf.d/`, which
  `dovecot.conf` includes before `local.conf` (`dovecot.cf`).
- The scripts only substitute ENV-derived values now; the include
  toggling and the second `sed` per feature are gone.
- Drop the Debian config import and the CE-only download from the build.

Breaking: files that users replaced, bind-mounted or patched in
`/etc/dovecot/conf.d/` no longer exist (see the changelog for the
mapping). Debian's deprecated ManageSieve listener on port 2000 and its
`fts_autoindex*` defaults are gone as well.

Add tests for the removed port 2000 and for a valid `doveconf -n` with the
protocols enabled according to ENV, and adjust the existing tests and
fixtures to the new file layout. Rewrite the Dovecot override docs.

Closes #4841

* fix(dovecot): load enabled features before user supplied config

Features that DMS enables were copied to `conf.d/`, so Dovecot read them
in file name order together with user drop-ins. A user file such as
`90-custom.conf` was read before `quota.conf` or `auth-ldap.conf`, and the
feature silently overrode the user's settings.

- copy enabled features to `/etc/dovecot/features.d/` instead, which
  `dovecot.conf` includes before `conf.d/*.conf`
- include the master user passdb before `conf.d/*.conf` as well, so a
  drop-in can override `auth_master_user_separator`
- create `features.d/auth-ldap.conf` with mode 640 (group `dovecot`), as
  it contains the LDAP bind password
- link the changelog entries to the PR, document the always-active master
  passdb, and adjust docs and tests to the new layout
- test that a `conf.d/` file overrides the quota feature, and that
  `auth-ldap.conf` is not world-readable
2026-11-18 17:59:30 +01:00
Georg Lauterbach b22fa0b7c2 fix(rspamd): do not learn messages moved from Junk to Trash as ham (#4855)
Since the Dovecot 2.4 migration (v16), `imapsieve_from Junk` fires for
every copy out of `Junk`, and `learn-ham.sieve` piped each one to
`rspamc learn_ham`. Deleting a message from `Junk` therefore trained the
classifier to treat it as ham.

The script now stops when the destination is `Junk` itself or a mailbox
with the `\Trash` special-use attribute, as in the upstream Dovecot 2.4
spam reporting example. Ham is learned for moves to any other folder.

Fixes #4831

Signed-off-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2026-11-16 11:58:58 +01:00
Georg Lauterbach 9bcd3e1db9 fix(dovecot): run all scripts in the global Sieve before/after directories
Since the Dovecot 2.4 migration, DMS registered one `sieve_script` block
per script it generates. Any other script placed in
`/usr/lib/dovecot/sieve-global/{before,after}/` (e.g. via
`user-patches.sh`) compiled but was silently ignored, unlike up to v15
where `sieve_before` / `sieve_after` pointed at the directories.

Register both directories as `before` / `after` script storages in
`90-sieve.conf` instead. Pigeonhole runs every `*.sieve` file in them in
file name order, which matches the previous execution order of the
scripts DMS generates itself (`50-`, `60-` and `70-` prefixes). The
per-file `sieve_script` blocks are removed.

- docs: describe the drop-in directories in the Sieve page
- tests: add a regression test with a script added via `user-patches.sh`
- changelog: add a `Fixed` entry with upgrade notes

Closes #4847
2026-11-11 14:48:17 +01:00
Ask Bjørn Hansen d705e50081 fix: randomize the freshclam cron schedule (#4824) 2026-10-19 00:37:46 +02:00
Brennan KinneyandGeorg Lauterbach 45ae8a4c32 breaking: Generate Postfix LDAP configs from layered sources (#3524)
Postfix LDAP configs are now generated at startup to `/etc/postfix/ldap/<KIND>.cf`
(`users`, `groups`, `aliases`, `domains`, `senders`) from these sources, later ones take precedence:

1. Defaults (`version = 3`, `result_attribute = mail`, `senders`: `mail, uid`).
2. `LDAP_<SETTING>` ENV for all configs.
3. The custom config `ldap-<KIND>.cf` from the DMS config volume (now also supported for `senders`).
4. `POSTFIX_<KIND>_<SETTING>` ENV for a single config.

A config without `query_filter` is not generated and its lookup table is not configured
(including `smtpd_sender_login_maps` with `SPOOF_PROTECTION=1`). Previously all lookup
tables were always configured, as the default configs shipped by the image always existed.

Breaking:
- `LDAP_QUERY_FILTER_{USER,GROUP,ALIAS,DOMAIN,SENDERS}` are renamed to
  `POSTFIX_{USERS,GROUPS,ALIASES,DOMAINS,SENDERS}_QUERY_FILTER` (an error is logged when the old ENV is set).
- `/etc/postfix/ldap-*.cf` moved to `/etc/postfix/ldap/*.cf`, the default configs (with default query filters) were removed.

Reworked from the original "Config Templates" proposal: Dovecot (already reworked for Dovecot 2.4)
and SASLAuthd are unchanged, and no template files or additional dependencies (`zenv`, `envsubst`) are required.

Signed-off-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2026-10-17 18:49:36 +02:00
Georg Lauterbach c8a7dd08ad fix(rspamd): only migrate Redis if the version can be migrated
Valkey does not understand RDB version 12, hence we cannot always easily
migrate.

Signed-off-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2026-09-28 10:21:56 +02:00
Georg Lauterbach 46206aeb89 feat: replace Redis with Valkey (#4808) 2026-09-25 21:56:46 +02:00
Georg LauterbachandBrennan Kinney c9b015ddc8 chore: update base image from Debian 12 to Debian 13 (#4536)
Signed-off-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2026-08-19 22:32:02 +02:00
Georg Lauterbach b81e2b526f fix: remove expand_keys = true from Rspamd configuration (#4689) 2026-03-28 20:22:51 +01:00
lalalalaandGeorg Lauterbach f343f7d960 fix RSPAMD_LEARN with mbsync (#4569)
Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2025-09-11 19:03:01 +02:00
Jam BalayaandGeorg Lauterbach c1a5eabc94 chore: fix various typos across codebase (#4552)
Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2025-08-12 21:55:53 +00:00
Ivan FilonenkoandCasper fcd9909841 fix(fail2ban): configure logrotate only when Fail2Ban is enabled (#4523)
Co-authored-by: Casper <casperklein@users.noreply.github.com>
2025-07-11 17:02:42 +02:00
Brennan Kinney d2d74a29a7 fix: Ensure /var/log/mail permissions + ownership are correct (#4374) 2025-02-18 09:02:35 +13:00
Brennan Kinney d07e6d67d6 chore: Update jaq to 2.0.0 (#4277)
- Bump to [`jaq` v2 release](https://github.com/01mf02/jaq/releases/tag/v2.0.0), artifact naming convention changed.
- Tidied up the changelog a little bit unrelated to this `jaq` update.
- Fixed a typo with an `rspamd.sh` comment + minor revision to the comment.
2024-11-29 16:12:00 +13:00
Georg Lauterbach 3937e1e719 scripts: improve DKIM path scanning in Rspamd setup (#4201) 2024-09-29 12:18:43 +02:00
Casper 3125cad45a Enable spamassassin only, when amavis is enabled too. (#3943) 2024-03-21 00:53:04 +01:00
Casper 267fc552d2 getmail: remove temp file usage (#3920) 2024-03-09 14:21:02 +01:00
Kirill KirilenkoandBrennan Kinney 3649699197 fix: Move spam to mailbox associated to the \Junk special-use attribute (#3925)
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2024-03-07 11:13:22 +13:00
Georg Lauterbach e21e5e0490 Rspamd: update history key in Redis configuration (#3927) 2024-03-06 08:44:34 +01:00
Casper 83a48e8958 Fail2ban logrotate interval/count: substitute only when necessary (#3919) 2024-03-03 22:48:42 +01:00
Casper 736f2e44bc Fail2Ban: Align logrotate count & interval (#3915) 2024-03-01 01:00:23 +01:00
Dominic Germain 512f39c7eb feat: Configurable number of rotated log files (#3907) 2024-02-28 15:34:30 +01:00
45935f5fb8 rspamd: add neural module config (#3833)
Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2024-02-01 17:34:33 +01:00
Georg Lauterbach afb0093939 spam: use Sieve for rewriting subject with Rspamd & SA/Amavis (#3820) 2024-01-29 13:38:01 +01:00
Brennan Kinney 3b11a8305e docs: Remove ENV ONE_DIR (#3840)
* docs: Better document DMS volumes

* docs: Remove any mention of `ONE_DIR` ENV

* chore: Remove `ONE_DIR` ENV from scripts

Only `ONE_DIR=0` has any effect. As the actual feature is now dependent upon the `/var/mail-state` location existing.

It is advised not mounting anything there instead if wanting to avoid runtime state consolidation.

* docs: Adjust link ref convention

This is more search friendly / organized to find references to all DMS volumes.

* lint: Ensure final newline is present

VSCode by default excludes this if the last line rendered is removed (rendered as a separate blank line).

A separate setting can enforce adding the final newline upon save regardless.
2024-01-29 10:35:19 +13:00
00018e7e2b general: update base image to Debian 12 ("Bookworm") (#3403)
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
Co-authored-by: Casper <casperklein@users.noreply.github.com>
2024-01-24 17:05:55 +01:00
Brennan Kinney 2d59aac5a1 chore: Add maintenance comment for sed usage (#3789)
This is a more explicit reminder for any future contributors that get thrown off by the usage of `sed` here and may be inclined to change it.

Add a link to reference a comment where it's already been explored what the alternative `sed` invocations available are.
2024-01-17 20:54:27 +13:00
Brennan Kinney 5e28c17cf4 docs: SpamAssassin ENV docs refactor (#3756)
* chore: Log `SPAMASSASSIN_SPAM_TO_INBOX=1` ENV correctly

ENV name logged was incomplete.

* docs: Update SA related ENV docs

* fix: Log level `warning` should be `warn`

* docs: FAQ - Revise outdated SA entry

* chore: Antispam / Antivirus => Anti-spam / Anti-virus

* docs: ENV - Additional revisions to SA ENV

* docs: ENV - Move `ENABLE_SPAMASSASSIN_KAM`
2024-01-08 03:07:38 +01:00
Brennan Kinney c75975d59e chore: Postfix should integrate Dovecot at runtime (#3681)
* chore: Better establish startup scope

* chore: Configure `main.cf` for Dovecot at runtime
2023-12-05 17:16:39 +13:00
Georg LauterbachandBrennan Kinney a11951e398 hotfix: solve #3665 (#3669)
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2023-11-28 10:33:29 +01:00
Georg LauterbachandBrennan Kinney 5f2fb72c9c Rspamd: add check for DKIM private key files' permissions (#3627)
* added check for Rspamd DKIM on startup

The newly added function `__rspamd__check_dkim_permissions` performs a
check on DKIM private key files. This is useful to prevent issues
like #3621 in the future. The function is deliberately kept simple and
may not catch every single misconfiguration in terms of permissions and
ownership, but it should be quite accurate.

Please note that the Rspamd setup does NOT change at all, and the checks
will not abort the setup in case they fail. A simple warning is emmited.

* add more documentation to Rspamd functions

* Apply suggestions from code review

* improve `__do_as_rspamd_user`

* rework check similar to review suggestion

see https://github.com/docker-mailserver/docker-mailserver/pull/3627#discussion_r1388697547

---------

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2023-11-13 12:34:46 +01:00
Georg LauterbachandBrennan Kinney f674232f71 misc: final Rspamd adjustments for v13 (#3599)
* outsource Rspamd ENVs into explicit helper

This will allow us to uniformly source the helper and get the values
from everywhere consistently. This is more than desirable since we will
be using these values not only for the Rspamd setup, but also for DKIM
management and during change-detection.

* integrate Rspamd into changedetection

We outsource one more function to reside in the helper script for Rspamd
so that we can call this function from the Rspamd setup and from the
changedetection functionality too.

* realize deprecation of old commands file for Rspamd

THIS IS A BREAKING CHANGE!

This change realizes the log message: "Using old file location now
(deprecated) - this will prevent startup in v13.0.0" Startup will now
fail.

* added '--force' option to Rspamd DKIM script

* use new helper to get ENVs for Rspamd in DKIM script

* remove the need for linking directories

This was unnecessary, as explained in
https://github.com/docker-mailserver/docker-mailserver/pull/3597#discussion_r1369413599

* Apply suggestions from code review

review by @polarathene

* apply more review feedback from @polarathene

- <https://github.com/docker-mailserver/docker-mailserver/pull/3599#discussion_r1370885519>
- <https://github.com/docker-mailserver/docker-mailserver/pull/3599#discussion_r1370904201>

* update documentation

---------

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2023-10-30 10:20:37 +01:00
Georg Lauterbach cb62ce20e6 bugfix: change Rspamd DKIM default config location (#3597)
Instead of using `etc/rspamd/override.d/dkim_signing.conf`, we will now
be using `/tmp/docker-mailserver/rspamd/override.d/dkim_signing.conf`.
The new location is persisted (and linked again during startup) and
hence better suited.
2023-10-24 10:31:22 +02:00
Georg Lauterbach 128e6b4d1f chore: Add debug group (packages.sh) + more resilient rspamd setup (#3578) 2023-10-16 09:51:48 +02:00
Georg LauterbachandBrennan Kinney 894978ddd7 refactor: logrotate setup + rspamd log path + tests log helper fallback path (#3576)
* simplify `_setup_logrotate`

* adjust Rspamd's log file and improve it's management

* add information to docs about Rspamd log

* update log query helper to allow another file location

* bail in case `LOGROTATE_INTERVAL` is invalid

---------

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2023-10-14 17:14:10 +02:00
cf9eb8278a scripts: add wrapper to update Postfix configuration safely (#3484)
The new function can

1. update/append
2. update/prepend
3. initialize if non-existent

options in `/etc/postfix/main.cf` in a safe and secure manner. When the
container is improperly restarted, the option is not applied twice.

---

Co-authored-by: Casper <casperklein@users.noreply.github.com>
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2023-08-22 08:03:41 +00:00
H4R0andBrennan Kinney bb2038e8c6 feat: Allow marking spam as read via a sieve filter (ENV MARK_SPAM_AS_READ=1) (#3489)
* add MARK_SPAM_AS_READ environment variable

* review changes

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>

* update unit test

---------

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2023-08-21 10:32:26 +12:00
f28fce9cc4 rspamd: disable checks for authenticated users (#3440)
Co-authored-by: Casper <casperklein@users.noreply.github.com>
Co-authored-by: William Desportes <williamdes@wdes.fr>
2023-08-08 10:43:21 +02:00
Claude Brisson 2b400a9269 Fix sieve setup (#3397) 2023-06-20 13:37:31 +02:00
Casper 8bfe8424fc Change 'for' style (#3368) 2023-05-26 14:00:40 +02:00
Casper c2d0b748b2 Change 'while' style (#3365) 2023-05-26 01:39:39 +02:00
Casper 37ca0f9ba9 Change 'function' style (#3364) 2023-05-26 01:01:41 +02:00
Casper cf74127f78 change if style (#3361) 2023-05-24 09:06:59 +02:00
Casper 0e592aa911 SPAM_TO_INBOX=1; add info about SA_KILL (#3360) 2023-05-23 19:32:09 +02:00
Casper a72adc2731 Fix typos (#3344) 2023-05-15 19:11:36 +02:00
Andreas Perhab ec330a35a1 ClamAV: add a warning for the internal message size limit (#3341) 2023-05-15 15:46:13 +02:00
Georg Lauterbach 9fd00bd6ad Rspamd: adjust learning of ham (#3334)
* adjust learning of ham

See #3333

When moving a mail from the Junk folder to the Trash folder, the mail
previously classified as ham due to the wildcard match of `*`. Because
the syntax does not allow for negation, we can only change the behavior
in a way that mails are learned as ham when they are moved into `INBOX`
from `Junk`. This is reasonable though.

* adjust tests accordingly

* adjust docs accordingly
2023-05-13 13:59:16 +02:00
Georg Lauterbach 78b7f0cbea scripts: improve CLAMAV_MESSAGE_SIZE_LIMIT usage (#3332)
* add sanity check for Clam size & adjusted MaxScanSize

The second part is of special importance! See
<https://askubuntu.com/a/1448525>, which explains that the maximum scan
size is important as well. We previously just set the maximum file size,
which actually is pretty insecure as we silently not scan mile bigger
than `MaxScanSize`. This is corrected now.

* add SlamAV size configuration to Rspamd
2023-05-12 16:04:41 +02:00
Georg Lauterbach e4274ef113 docs: improve Rspamd docs about DKIM signing of multiple domains (#3329)
* improve Rspamd docs

See #3326 & #3328

* improve warning message

See #3328
2023-05-11 18:08:54 +02:00
Georg LauterbachandCasper bba72daedf scripts: add DKIM helper script for Rspamd (#3286)
Co-authored-by: Casper <casperklein@users.noreply.github.com>
2023-05-03 08:30:49 +02:00