113 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 08b3cf3bb2 breaking(networking): replace PERMIT_DOCKER with DMS_TRUSTED_NETWORKS (#4848)
`_setup_docker_permit` always parsed an IPv4 address from
`NETWORK_INTERFACE` and aborted startup when there was none, even for the
default `PERMIT_DOCKER=none`, which does not need it. DMS therefore
failed to start in IPv6-only networks.

Replace `PERMIT_DOCKER` with `DMS_TRUSTED_NETWORKS`, which no longer
implies Docker, carries the `DMS_` prefix and supports IPv6:

- `none` (default): trust no client
- `host`, `subnet`: delegate to Postfix `mynetworks_style`, so no
  `ip addr` parsing is needed
- a list of CIDR ranges (IPv4 and IPv6, separated by spaces or commas)

The ranges Postfix derives or the user provides are normalized (lower
case, compressed IPv6, host bits masked) before they are added to the
OpenDKIM and OpenDMARC trust lists, as both only match that text form.
An invalid value now stops the startup instead of being cleared with a
warning.

`NETWORK_INTERFACE` is removed together with `helpers/network.sh`.
`PERMIT_DOCKER` and `NETWORK_INTERFACE` log an error when still set and
are ignored, so no client is trusted until the user migrates:

- `container` => `host`
- `host`, `connected-networks` => `subnet`
- `network` => `172.16.0.0/12` (or the exact range of the network)

- docs: document `DMS_TRUSTED_NETWORKS` with a migration table and update
  all pages and demo setups that used the old variables
- tests: add `trusted_networks.bats` (no IPv4 address, `host`, CIDR list,
  invalid value, legacy variables), rename `permit_docker.bats` and
  migrate all tests to the new variable
- changelog: add `Breaking` and `Fixed` entries

Closes #4634
Closes #3478
2026-11-11 19:50:14 +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 f0c78f94dc fix(dovecot): use a sed delimiter that does not collide with mail_home (#4846) 2026-11-10 13:54:27 +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
893454258b feat: add IMAP IDLE support for getmail (#4675)
Signed-off-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
Co-authored-by: Brainkiller <brainkiller@boven.xyz>
Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2026-10-04 22:40:14 +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 Lauterbach 198ccc8f8a feat: re-enable Dovecot's stats-writer (#4807)
Signed-off-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2026-09-25 17:12:02 +02:00
Georg Lauterbach a3276b0fdf fix: update Dovecot LDAP configuration (#4770)
Signed-off-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2026-08-31 12:07:40 +02:00
Georg LauterbachandBrennan Kinney c41d2de2be remove: Diffie-Hellman parameters for Postfix & Dovecot (#4562)
Signed-off-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2026-08-28 10:30:31 +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
Brennan Kinney 5e5e005162 chore: Revise inline docs for Fetchmail (#4587) 2025-10-08 10:33:26 +13:00
Lars K.W. Gohlke 9eb3fa73e5 fix: Prevent logs leaking into config files (FETCHMAIL_PARALLEL=1) (#4586) 2025-10-06 20:25:13 +02: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
23bb1c8e50 refactor: setup CLI open-dkim (#4375)
Refactoring this `setup` CLI command as part of the effort to unify our DKIM feature support between OpenDKIM + Rspamd:
- Adds a `main()` method similar to other setup CLI commands.
- Help text more aligned with equivalent rspamd DKIM setup CLI command.
- DRY some repetition such as hard-coded paths to use variables.
- OpenDKIM config files are created / initialized early on now with `_create_opendkim_configs()`. `while` loop only needs to append entries, so is easier to grok.
- `_create_dkim_key()` to scope just the logic (_and additional notes_) to key generation via `opendkim-genkey`
- Now overall logic with the `while` loop of the script occurs in `_generate_dkim_keys()`:
  - Ownership fixes are now applied after the `while` loop as that seems more appropriate than per iteration.
  - Temporary VHOST config is now removed since it's no longer useful after running.
- Tests adjusted for one new log for adding of default trusted hosts content.

Overall this should be nicer to grok/maintain. Some of this logic will be reused for the unified DKIM generation command in future, which is more likely to shift towards all domains using the same keypair by default with rspamd/opendkim config generated at runtime rather than reliant upon DMS config volume to provide that (_still expected for private key_).

---------

Co-authored-by: Casper <casperklein@users.noreply.github.com>
Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2025-03-31 11:27:28 +02:00
Brennan Kinney a3571a88c1 fix: DMS state volume must ensure o+x permission (#4420) 2025-03-18 23:48:12 +01:00
Brennan Kinney 02f068b2b2 fix: Use correct Postfix parameter for postfix-receive-access.cf (#4399) 2025-03-05 11:00:06 +13:00
Brennan KinneyandGeorg Lauterbach 5686a4097a fix: setup email restrict configs should only prepend once (#4379)
* fix: `setup email restrict` configs should only prepend once

* chore: Prepend to our custom parameter variant to retain applying to all `smtpd` ports

---------

Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2025-03-01 13:55:13 +01:00
Brennan Kinney d2d74a29a7 fix: Ensure /var/log/mail permissions + ownership are correct (#4374) 2025-02-18 09:02:35 +13:00
Georg Lauterbach 0294294755 fix: revert __declare_readonly overcomplication (#4372)
* fix: revert `__declare_readonly` overcomplication
* chore: remove redundant checks

Signed-off-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2025-02-17 00:14:18 +00:00
Brennan Kinney 83bfe72d48 chore: Migrate dovecot config from Dockerfile (#4350) 2025-02-12 11:56:51 +13:00
59a379aed7 scripts: restructure container restart behavior (#4323)
Signed-off-by: georglauterbach <44545919+georglauterbach@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-09 10:23:06 +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
Brennan Kinney 025a38d736 chore: Add maintenance note for LMTP (#4199) 2024-09-26 20:01:35 +12:00
b2978fd760 breaking: Refactor getmail support (#4156)
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2024-08-17 12:14:59 +02:00
Brennan Kinney 2f8ad142ec fix: Prevent stderr being written to /etc/postfix/main.cf (#4147)
`stderr` is filtered by `grep` to discard unwanted (expected) log noise when appending the override `postfix-main.cf` content (_updated settings did not replace earlier defined instances_).

That `grep` filter introduced a regression into DMS v14 release, since any other `stderr` content not being excluded was now blended into `stdout` and redirected with the original `stdout` output for the `postconf -n` command.

The fix is to ensure the `grep` output is redirect to `stderr` to avoid that mishap.
2024-08-02 09:42:39 +12:00
Brennan Kinney ed669bd314 fix: /var/mail-state should not symlink non-existing directories (#4018)
Fixes an issue with the Getmail service, view PR thread for additional details.
- Log an error when the expected service state directory doesn't exist.
- The location `/var/lib/getmail/` doesn't seem like it should have been introduced. Drop it in favor of `/tmp/docker-mailserver/getmail`. It appears to be for storing remote mail that was retrieved if not configured to send to Dovecot like our docs advise. This location was never valid anyway (_as referenced issue covers_).
2024-05-19 22:32:53 +12:00
Brennan Kinney e2c2a22dcf fix: postfix-main.cf may depend upon postfix-master.cf (#3880)
Custom parameters must be referenced to be retained when `postconf -n` is run. If those parameters are referenced by `postfix-master.cf` this needs to update `master.cf` before updating `main.cf`.
2024-05-03 11:12:34 +12: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
Robbert Klarenbeek a815bf5ab4 fix: Apply SELinux security context after moving to mail-state (#3890)
* fix: Apply SELinux security context after moving to mail-state
* fix: Ignore failing chcon on non-SELinux systems
2024-02-16 20:24:39 +13: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
Brennan KinneyandGeorg Lauterbach 47f8d50beb fix: Ensure configs are sanitized for parsing (#3819)
* chore: Detect missing final newline in configs read

These lines will be not be processed by `read`, emit a warning to raise awareness.

* fix: Ensure parsed config has final newline appended (when possible)

This functionality was handled in `accounts.sh` via a similar sed command (that the linked references also offer).

`printf` is better for this, no shellcheck comment required either.

We additionally don't attempt to modify files that are read-only.

* fix: Ensure parsed configs have CRLF to LF corrected (where possible)

Likewise, this runtime fix was only covering two config files. It now applies to all callers of this method.

* fix: Sanitize `postfix-master.cf` via helper

This feature should have been using the helper to avoid user error from their config updates accidentally introducing subtle breakage implicitly (due to CRLF or missing final newline).

* tests: Add test cases for new helpers

* tests:  `rm` is redundant when using `BATS_TEST_TMPDIR`

This temporary directory is created and removed implicitly. Even after a test failure.

* chore: Remove old `postfix-virtual.cf` migration logic

This was introduced in 2018, there should be no one needing to rely on this anymore?

* tests: Remove comment on sed failure concern

* chore: Add entry to `CHANGELOG.md`

* Apply suggestions from code review

Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>

---------

Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2024-01-26 10:28:26 +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
Joerg SonnenbergerandBrennan Kinney e3331b0f44 feat: Add MTA-STS support for outbound mail (#3592)
* feat: add support for MTA-STS for outgoing mails

* Hook-up mta-sts-daemon into basic process handling test

* fix: Call python script directly

The python3 shebang will run it, which will now meet the expectations of the process testing via pgrep. fail2ban has the same approach.

---------

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2024-01-13 21:37:20 +13:00