fix(mail): scope outbound-relay TLS to the relay transport - #423
Open
santhiprakash wants to merge 1 commit into
Open
fix(mail): scope outbound-relay TLS to the relay transport#423santhiprakash wants to merge 1 commit into
santhiprakash wants to merge 1 commit into
Conversation
`configureOutboundRelay` was setting `smtp_tls_security_level=encrypt` globally, which forced TLS on Postfix's local `smtp-amavis` delivery to 127.0.0.1:10024 and silently deferred all inbound mail. Change to a per-destination model: - keep `smtp_tls_security_level=may` as the global default - use `smtp_tls_policy_maps` to require `encrypt` only for the relay nexthop - pin `smtp-amavis/unix` to `smtp_tls_security_level=none` and `smtp_tls_wrappermode=no` via `postconf -P` - add the same overrides to the sample `master.cf` amavis transport - write/hash a per-destination `/etc/postfix/tls_policy` map - remove the map and reset `smtp_tls_security_level=may` on disable Added/updated unit tests to prove the relay gets `may` + `tls_policy`, Amavis gets explicit overrides, and disable cleans up the new map. Fixes oblien#392
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stop setting
smtp_tls_security_level=encryptglobally inconfigureOutboundRelay; that forces TLS on the localsmtp-amavisdelivery to127.0.0.1:10024, which does not speak TLS, causing all inbound mail to be silently deferred.Motivation
Reported in #392.
apps/api/src/modules/mail/admin/outbound-relay.service.tsusespostconf -e smtp_tls_security_level=encryptwhenever an outbound relay is enabled.smtp_tls_security_levelis a global Postfix client directive, so it also applies to thesmtp-amavistransport and any other local SMTP client delivery. Amavis on127.0.0.1:10024does not offer STARTTLS, so Postfix logsstatus=deferred (TLS is required, but was not offered by host 127.0.0.1...)and inbound mail never arrives.Related issue
Fixes #392
Changes
outbound-relay.service.ts:/etc/postfix/tls_policymap ([<host>]:<port> encrypt) and reference it viasmtp_tls_policy_maps.smtp_tls_security_levelfromencrypttomay.smtp_tls_wrappermode=yesglobally, but pin thesmtp-amavis/unixtransport tosmtp_tls_wrappermode=noviapostconf -P.smtp-amavis/unixtosmtp_tls_security_level=noneviapostconf -P.disableOutboundRelay, removesmtp_tls_policy_mapsandsmtp_tls_wrappermode, resetsmtp_tls_security_level=may, and delete thetls_policymap files.outbound-relay.service.test.ts: add/extend assertions for thetls_policymap, themaysecurity level, the Amavis per-transport overrides, the port-465 wrapper-mode split, and disable cleanup.-o smtp_tls_security_level=noneand-o smtp_tls_wrappermode=noto thesmtp-amavistransport so the sample config matches the runtime override.Verification
The targeted test includes new assertions that fail against the original code (which emits
smtp_tls_security_level=encryptand nosmtp_tls_policy_maps/ no Amavis override).Screenshots
N/A — backend Postfix config change only.
Checklist
bun run test,bun run --cwd <workspace> lint, andbun formatall pass locallyNote on the unchecked box:
bunx prettier --checkon the two touchedapps/apifiles reports pre-existing formatting issues (long lines) unrelated to this change; runningbun formatwould reformat many lines I didn't touch, so I scoped the diff to the functional change.bun run --cwd apps/api lintand the targeted test pass.