Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't apply SRS to locally bound mail #534

Merged
merged 4 commits into from
Sep 3, 2024
Merged

Don't apply SRS to locally bound mail #534

merged 4 commits into from
Sep 3, 2024

Conversation

jb3
Copy link
Member

@jb3 jb3 commented Sep 3, 2024

In #528 changes were made to prevent mail from internal domains being rewritten
with the Sender Rewrite Scheme since we can correctly authenticate any mail sent
from our domains.

Similarly, if we are the last stop on an envelopes journey (i.e. the mail will
arrive to a local mailbox) there is no need for us to apply sender rewriting as
we have no further mailservers to pass the message onto (and so the message is
fully received and validated at this point).

This PR introduces a new SMTP daemon which we set as the default_transport
which conditionally rewrites with SRS only when the expanded destination address
is not a locally handled inbox.

This allows for mail heading for an external server such as Google or Outlook to
be rewritten and remain valid under SPF but mail that lands in our inboxes not
be rewritten (you can validate this by checking that the Return-Path doesn't
have SRS in it for local mail).

@github-actions github-actions bot added group: ansible Issues and pull requests related to the Ansible setup component: email Issues relating to our email forwarding system, hosted on our netcup machines. labels Sep 3, 2024
Comment on lines 51 to 57
# Handle SRS
default_transport = smtp:127.0.0.1:10027
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment could do with some improvement. How does it handle SRS?

-o sender_canonical_maps=pcre:/etc/postfix/sender-canonical-maps,tcp:127.0.0.1:10001
-o sender_canonical_classes=envelope_sender

127.0.0.1:10027 inet n - - - - smtpd
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a regular service name (e.g. smtpd-optional-srs) and a unix socket for this, please?

-o sender_canonical_classes=envelope_sender

127.0.0.1:10027 inet n - - - - smtpd
-o syslog_name=postfix/srs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-o syslog_name=postfix/srs
-o syslog_name=postfix/smtpd/optional-srs

@@ -187,6 +197,19 @@
-o smtpd_sasl_type=dovecot
-o smtpd_sasl_path=private/auth

cleanup-srs unix n - - - 0 cleanup
-o syslog_name=postfix/srs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-o syslog_name=postfix/srs
-o syslog_name=postfix/cleanup/optional-srs

@jchristgit
Copy link
Member

Pretty smart implementation. I have to admit the intermingling of Postfix daemons is a bit hard to see through at first but it's pretty genius. Turns out that that configuration file format is very, very flexible.

@jchristgit
Copy link
Member

Btw, we should probably contribute docs for this upstream. It seems useful.

@jchristgit
Copy link
Member

Nevermind, I see, you've copied this from upstream yourself. roehling/postsrsd#76

This template returns the address verbatim if it's a local domain else
it returns nothing. Based on this, we can use these addresses for SRS,
it will either use the verbatim address or pass onto SRSd for a rewrite.
@jb3 jb3 merged commit eb79092 into main Sep 3, 2024
6 checks passed
@jb3 jb3 deleted the jb3/mail/conditional-srs branch September 3, 2024 18:47
Copy link

github-actions bot commented Sep 3, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: email Issues relating to our email forwarding system, hosted on our netcup machines. group: ansible Issues and pull requests related to the Ansible setup
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants