Commit Graph

131 Commits

Author SHA1 Message Date
Martin Weinelt 31c7607ef4 Rename extraVirtualAliases to aliases and update description
The extra and virtual parts are redundant and Postfix specific and not
at all required. Compare forwards for example.
2026-03-23 16:26:32 +01:00
Martin Weinelt 23364b04e8 ldap: allow local accounts and aliases with ldap enabled
In conflicts between local addresses and LDAP addresses the local one
will always take priority in mail routing.

This is something we now document and guarantee through tests.
2026-03-23 16:25:50 +01:00
Martin Weinelt 59eae7f3d0 tests/ldap: remove redundant settings
All of thsese are already option defaults.
2026-03-21 22:34:50 +01:00
Martin Weinelt 762f553643 ldap: make uid the default account name
I fail to understand how mail became the uidAttribute way back when LDAP
support was introduced, but it was unintentional and clearly a mistake.

The uid attribute is the standard system login name per RFC4519 2.39 and
what we default to going forward.
2026-03-21 01:38:04 +01:00
Martin Weinelt a87d01ea79 ldap: reorganize and regroup options
Now that we have more experience with how we use the LDAP module options
we can make smarter decisions in how to organize them. We can also
explain much better what these options imply, which results in more
extensive option documentation.
2026-03-21 01:38:04 +01:00
Martin Weinelt 091eda1ed2 ldap: migrate to UUID based Dovecot home directories
The LDAP support was not in a good shape when it was merged. This is a
breaking change and course correction to apply best practices going
forward.

This fixes various issues experienced with the Dovecot LDAP home
directory.

The gravest issue is that the `homeDirectory` attribute from
the `posixAccount` schema would overwrite the Dovecot home directory and
cause permission errors. This was possible because we defined the home
variable in `default_fields` that is inherently mutable and just a preset
if no other value gets transmitted from LDAP. This did not surface in
tests, because our LDAP schema was too minimal compared to a common
production dataset.

The most annoying issue and the actual breaking change is that we now
default to UUID based home directories. Every entry in an IDM that
supports LDAP comes with a unique identifier that does not change upon
account name changes. We want those to enable simple account name
migrations that don't require any manual data migration.

To migrate existing dovecot home directories a migration script is
included, which will be backported to the 25.11 release, so the migration
can already be started from the previous release version.
2026-03-21 00:47:59 +01:00
Martin Weinelt fa0d5c9694 tests/ldap: fail fast if openldap schema is broken
This helps so much during development as it tells me openldap failed and
doesn't require me to do a root cause analysis on a postmap failure much
later in during the test.
2026-03-21 00:47:59 +01:00
Martin Weinelt 06cc71c76e treewide: add language annotations for inline code
Instruct editors to correctly highlight and evaluate inline code blocks.
2026-03-12 12:59:03 +01:00
Martin Weinelt 6ff4a50f02 Add support for DKIM key management
After bumping the generation of new DKIM keys to RSA 2048 in NixOS 25.11
key rotation for existing users could not be done safely.

To resolve this situation we now support multiple generations of
selectors per domain to enable proper DKIM key transitions as described
in RFC6376 3.1. The added documentation introduces and motivates DKIM
and guides the user through a DKIM key rotation.

Additionally, DKIM key material can now also be treated as a managed
secrets when autogenerated state on the mail server host is undesirable.

This change is fully backwards compatible in behavior and will continue
to use the previously generated DKIM key without any additional
configuration up until the point when DKIM selectors are configured
explicitly.
2026-03-11 22:37:49 +01:00
Martin Weinelt 1c57aab586 treewide: fix typos and other minor issues 2026-03-11 01:50:14 +01:00
Ryan Gibb 12ae5dd89b support unhashed password files 2026-03-05 11:06:01 +00:00
Martin Weinelt e1afec5b08 tests: wait for rspamd-milter.sock in ldap and internal tests
I've hit more races in these tests recently while running the test suite
on a much faster host system.
2026-03-04 16:02:47 +01:00
Martin Weinelt 25eae48a09 tests: fix eicar test string escape
This fixes a warning issued by the Lix evaluator:

> warning: \P is an ill-defined escape. You can drop the \ and simply
> write P instead. Use --extra-deprecated-features broken-string-escape
> to silence this warning.
2026-03-04 15:53:30 +01:00
Martin Weinelt e437760341 treewide: replace/remove dovecot2 service name
The unit name is now dovecot.service.
2025-12-19 02:52:55 +01:00
Martin Weinelt ff9b046f0f Stop recommending bcrypt everywhere
By passing no method to mkpasswd we make it select the strongest cipher
that libxcrypt recommends.

Replaces the example hashes with yescrypt hashes, which is the current
default.
2025-12-19 02:36:28 +01:00
Martin Weinelt 33ba1ff52b Switch to NixOS ACME module for certificate management
Drop most of the existing certificate handling, because we're effectively
duplicating functionality that NixOS offers for free with better
design, testing and maintainance than what we could provide downstream.

The remaining two options are to reference an
existing `security.acme.certs` configuration through
`mailserver.x509.useACMEHost` or to provide existing key material via
`mailserver.x509.certificateFile` and `mailserver.x509.privateKeyFile`.

Support for automatic creation of self-signed certificates has been
removed, because it is undesirable in public mail setups.

The updated setup guide now displays the recommended configuration that
relies on the NixOS ACME module, but requires further customization to
select a suitable challenge.

Co-Authored-By: Emily <git@emilylange.de>
2025-12-19 02:36:28 +01:00
Martin Weinelt 0812ca1e48 Use postfix-tlspol for DANE/MTA-STS policy lookups
Postfix with plain DANE only secures domains that configure DNSSEC and
publish TLSA records. With postfix-tlspol we support MTA-STS protected
connections and get caching for its policy results.

Finally, we use this as a stepping stone to build TLSRPT support on top.
2025-11-08 15:49:34 +01:00
Martin Weinelt 1337e2eece Disable submission with explicit STARTTLS by default
Deprecated, but not yet scheduled for removal pending user feedback.
2025-11-08 12:50:50 +01:00
Martin Weinelt 1a2d7a4bf5 rspamd: restrict addresses we disable checks for to localhost
By default this includes private network subnets, but those should really
use authentication instead, if they want to skip checks.

Closes: #326
2025-08-25 04:12:30 +02:00
emilylange 63b8e1615f tests: also test client submission over smtps://
instead of just smtp:// with STARTTLS.

Opted to call the flag --ssl and not --tls to keep it consistent with
the module option (mailserver.enableSubmissionSsl), dovecot internals
and smtplib in mail-check.py.
2025-08-24 02:29:30 +02:00
Martin Weinelt b76a547bec treewide: reformat with nixfmt 1.0.0 2025-08-02 02:19:15 +02:00
Martin Weinelt 2b240501e0 Introduce system name and domain options
Bring them up from the DMARC reporting section to the mailserver toplevel
so they become reusable for the upcoming TLSRPT integration.

We default to the first domain in the domains option, if not set
explicitly, so that `systemDomain` doesn't become a blocker for existing
setups. We still encourage picking out the intended one, which is likely
the one used for the MX hostname.

This also simplifies the DMARC reporting configuration, which doesn't
need to be so fine-grained.

Co-Authored-By: Emily <git@emilylange.de>
2025-07-09 01:44:10 +02:00
Martin Weinelt 47786932cb tests: fix deprecate machine config access 2025-07-08 03:58:37 +02:00
Martin Weinelt d6d2053b80 dovecot: use marker option as unit name migration indicator
In nixpkgs we expose `services.dovecot.hasNewUnitName` option that can be
safely inspected to understand that whether to use the `dovecot` systemd
service name instead of `dovecot2`.
2025-07-07 01:10:19 +02:00
Martin Weinelt 3c1cff431c tests: test for the expected maildir and index dir locations
These are not ideal yet, but we should make them a fixture, so that we
are always aware what they are for the different supported setups.
2025-06-21 10:28:43 +02:00
Martin Weinelt 601b33d2a7 tests/minimal: drop
We have other tests that are minimal, e.g. the multiple test. And this
test wasn't even hooked up in flake.nix, so I'm doubtful that we really
need it.
2025-06-19 01:04:56 +02:00
Martin Weinelt 0774c93ae6 tests: make rspamd not block on dns queries
These will never suceed while running the tests in the Nix sandbox, and
skipping them leads to very noticable (~51%) speedups.

Before:
```
Benchmark 1: nix build .#hydraJobs.x86_64-linux.external-unstable --rebuild
  Time (mean ± σ):     151.737 s ±  1.074 s    [User: 0.310 s, System: 0.289 s]
  Range (min … max):   150.321 s … 153.512 s    10 runs
```

After:
```
Benchmark 1: nix build .#hydraJobs.x86_64-linux.external-unstable --rebuild
  Time (mean ± σ):     74.010 s ±  0.746 s    [User: 0.269 s, System: 0.266 s]
  Range (min … max):   72.814 s … 75.190 s    10 runs
```
2025-06-17 22:04:46 +02:00
Martin Weinelt f08ee8da38 tests: provide a second cpu core
Provides a small (~7.5%) reduction in the test runtime measured for the external
test:

Before:
```
Benchmark 1: nix build .#hydraJobs.x86_64-linux.external-unstable --rebuild
  Time (mean ± σ):     151.737 s ±  1.074 s    [User: 0.310 s, System: 0.289 s]
  Range (min … max):   150.321 s … 153.512 s    10 runs
```

After:
```
Benchmark 1: nix build .#hydraJobs.x86_64-linux.external-unstable --rebuild
  Time (mean ± σ):     140.647 s ±  1.092 s    [User: 0.331 s, System: 0.296 s]
  Range (min … max):   138.536 s … 142.298 s    10 runs
```
2025-06-17 22:04:08 +02:00
Martin Weinelt cf6ef5e9ca Create per service debug logging toggles
Enabling the rspamd debug log drowns out everything else and should be
selected explicitly as needed.

The external test does not require it and removing it makes it much
(~40.5%) faster, since it now does not block on terminal output anymore.

Before:
```
Benchmark 1: nix build .#hydraJobs.x86_64-linux.external-unstable --rebuild
  Time (mean ± σ):     151.737 s ±  1.074 s    [User: 0.310 s, System: 0.289 s]
  Range (min … max):   150.321 s … 153.512 s    10 runs
```

After:
```
Benchmark 1: nix build .#hydraJobs.x86_64-linux.external-unstable --rebuild
  Time (mean ± σ):     90.531 s ±  0.557 s    [User: 0.054 s, System: 0.045 s]
  Range (min … max):   89.579 s … 91.278 s    10 runs
```
2025-06-17 22:02:31 +02:00
Martin Weinelt 1a7f3d718c treewide: reformat with nixfmt-rfc-style 2025-06-15 03:39:44 +02:00
Martin Weinelt 11bfdbf136 tests: drop dhparam default length configuration
This has been the default value since the option was introduced back in
2018[0].

[0] https://github.com/NixOS/nixpkgs/commit/81fc2c35097f81ecb29a576148486cc1ce5a5bcc
2025-05-29 08:49:37 +02:00
Martin Weinelt 792225e256 Introduce stateVersion concept
With upcoming changes to the dovecot home and maildirectories we need to
introduce a way to nudge users to inform themselves about manual
migration steps they might need to carry out.

The idea here is to allow us to safely make breaking changes and notify
the user of required migration steps at eval time, so they can make the
necessary changes in time.
2025-05-27 23:54:15 +02:00
euxane 826a3b2fcf tests/external: ignore time adjustments warnings
Seems to be happening randomly during tests:

    dovecot: master: Warning: Time moved forwards by 0.101534 seconds - adjusting timeouts.
2025-05-19 17:15:36 +02:00
euxane 2ed7a94782 dovecot/fts: switch to fts-flatcurve
This switches the full-text search plugin from fts-xapian to
fts-flatcurve, the now preferred indexer still powered by Xapian,
which will be integrated into Dovecot core 2.4.

This sets a sane minimal configuration for the plugin with
international language support.

The plugin options marked as "advanced" in Dovecot's documentation
aren't re-exposed for simplicity. They can nevertheless be overridden
by module consumers by directly setting keys with
`services.dovecot2.pluginSettings.fts_*`.

The `fullTextSearch.maintenance` option is removed as the index is now
incrementally optimised in the background.

GitLab: closes https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/issues/239
2025-05-19 16:45:09 +02:00
Martin Weinelt dd83a2c7ad dovecot: rename sieve bayes/ham learning script
Updates the spamassasin reference to talk about rspamd.
2025-05-15 16:16:17 +02:00
Martin Weinelt 235dba2d82 tests/external: ignore new xapian warnings
These looks harmless.

Closes: #322
2025-05-15 16:16:17 +02:00
Martin Weinelt ef1e02e555 flake.nix: run tests against pinned nixpkgs
and migrate to the new runTest, which evaluates much faster.
2025-05-10 02:43:35 +02:00
Martin Weinelt 86b48f368f tests: remove invalid escape sequences
>>> "\@"
<stdin>:1: SyntaxWarning: invalid escape sequence '\@'
'\\@'
2025-05-07 03:56:41 +02:00
Elian Doran b343c5e8fa assertions: Allow mailserver.forwards with LDAP set up 2025-05-06 05:32:45 +02:00
Martin Weinelt 2520e662f7 tests/external: make DKIM signing test more explicit 2025-05-06 01:05:10 +02:00
euxane 6b425d13f5 tests: fix renamed options warnings 2025-01-24 17:40:48 +01:00
Guillaume Girol ade37b2765 fts xapian: adapt to newer versions
fts xapian does not publish configuration changes in a changelog. As a
result, some options that nixos mailserver was setting for it have been
ignored for several years. New options (process_limit) are now
recommended. This adapts the module to these changes.

The default value of partial= is 2, but fts_xapian 1.8.3 now requires it
to be at least 3, and fails loudly in case it is 2. As a result, this
change is required to support fts_xapian 1.8.3 and later.
2025-01-18 12:00:00 +00:00
Guillaume Girol 0a801316cd tests: ignore debug message that looks like an error 2024-11-24 00:16:56 +01:00
Guillaume Girol e901c56849 services.dnsmasq.extraConfig was removed on nixos-unstable 2024-11-23 23:51:49 +01:00
Guillaume Girol 3a082011dc recent nixos-unstable requires larger dh params 2024-11-23 12:00:00 +00:00
Antoine Eiche 29916981e7 Release 24.05 2024-06-11 07:36:43 +02:00
Antoine Eiche e47f3719f1 Release 23.11 2024-01-25 22:52:54 +01:00
Jean-Baptiste Giraudeau 84783b661e Add tests for regex (PCRE) aliases 2023-09-28 16:13:00 +02:00
Antoine Eiche fb3210b932 ldap: do not write password to the Nix store 2023-07-11 19:31:20 +00:00
Antoine Eiche 33554e57ce Make the ldap test working
- The smtp/imap user name is now user@domain.tld
- Make the test_lookup function much more robust: it was now getting
  the correct file from the store.
2023-07-11 19:31:20 +00:00