`ENABLE_RSPAMD` now defaults to `1`, while `ENABLE_AMAVIS`,
`ENABLE_OPENDKIM`, `ENABLE_OPENDMARC` and `ENABLE_POLICYD_SPF` default
to `0`. `ENABLE_RSPAMD_VALKEY` follows `ENABLE_RSPAMD`.
DMS refuses to start when OpenDKIM keys exist in the config volume and
`ENABLE_OPENDKIM` is unset, so an upgrade does not silently stop signing
outbound mail.
Tests that relied on the old defaults now set the legacy ENV
explicitly. `default_security_stack.bats` covers the new defaults and
the startup refusal.
Closes#4364
* 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
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>
`_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#4634Closes#3478
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
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>
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>
* 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>
- 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.
`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.
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_).
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`.