From 26b91862fcb8660f51711d00e8de42c5f046d0dc Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 2 Sep 2025 19:41:40 +0200 Subject: [PATCH] introduces a parameter `mta_dname` (default `\S+`) to allow more complex REs to match custom MTA daemon names (e.g. with spaces etc) --- config/filter.d/sendmail-reject.conf | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/config/filter.d/sendmail-reject.conf b/config/filter.d/sendmail-reject.conf index e8b2f9b4..cd7b51d1 100644 --- a/config/filter.d/sendmail-reject.conf +++ b/config/filter.d/sendmail-reject.conf @@ -22,6 +22,11 @@ before = common.conf _daemon = (?:(sm-(mta|acceptingconnections)|sendmail)) __prefix_line = %(known/__prefix_line)s(?:\w{14,20}: )? addr = (?:(?:IPv6:)?|) +# mta_dname -- matches name of MTA daemon (typically specified in DAEMON_OPTIONS), +# normally something without spaces like MTA-v4 or Deamon0, etc. If it'd contain spaces, one can +# rewrite it in jail using `filter = %(known/filter)s[mta_dname="[^,]+"]` or in .local overwrite +# of the filter. (we would not use catch-alls here to satisfy obscure artificial case). +mta_dname = \S+ prefregex = ^\s*(?:]+> )?%(__prefix_line)s.+$ @@ -30,14 +35,14 @@ cmnfailre = ^ruleset=check_rcpt, arg1=(?P<\S+@\S+>), relay=(\S+ )?\[%(add ^rejecting commands from (\S* )?\[%(addr)s\] due to pre-greeting traffic after \d+ seconds$ ^(?:\S+ )?\[%(addr)s\]: (?:(?i)expn|vrfy) \S+ \[rejected\]$ ^<[^@]+@[^>]+>\.\.\. (?:No such user here|User unknown)$ - ^from=<[^@]+@[^>]+>, size=\d+, class=\d+, nrcpts=\d+,(?: bodytype=\w+,)? proto=E?SMTP, daemon=\S+, relay=(?:\S+ )?\[%(addr)s\]$ + ^from=<[^@]+@[^>]+>, size=\d+, class=\d+, nrcpts=\d+,(?: bodytype=\w+,)? proto=E?SMTP, daemon=%(mta_dname)s, relay=(?:\S+ )?\[%(addr)s\]$ mdre-normal = mdre-extra = ^(?:\S+ )?\[%(addr)s\](?: \(may be forged\))? did not issue \S+ during connection mdre-aggressive = %(mdre-extra)s - ^lost input channel from (?:\S+ )?\[%(addr)s\] to .*? after rcpt$ + ^lost input channel from (?:\S+ )?\[%(addr)s\] to %(mta_dname)s after rcpt$ ^ruleset=check_rcpt, arg1=(?P<\S+@\S+>), relay=(?:\S+ )?\[%(addr)s\](?: \(may be forged\))?, reject=(?:450 4\.4\.0(?: (?P=email)\.\.\.)?(?: Relaying temporarily denied\.)?(?: Cannot resolve PTR record for (\d+\.){3}\d+))$ failregex = %(cmnfailre)s