-
Notifications
You must be signed in to change notification settings - Fork 3
/
pysrs.m4
78 lines (66 loc) · 1.87 KB
/
pysrs.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
divert(-1)
#
# Copyright (c) 2004 Alain Knaff (derived from work by asarian-host.net)
# All rights reserved.
# Copyright (c) 1988, 1993
# The Regents of the University of California. All rights reserved.
# Portions Copyright (c) 2004-2009
# Business Management Systems, Inc All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
#
divert(0)
VERSIONID(`$Id$')
ifdef(`_MAILER_DEFINED_',,`errprint(`*** WARNING: MAILER() should be before HACK(pysrs)
')')
ifdef(`_ARG_',,`errprint(`*** WARNING: HACK(pysrs,sockname) requires sockname
')')
ifelse(defn(`_ARG_'),`',,`define(`SRS_SOCKET',_ARG_)')
LOCAL_CONFIG
# Forward SRS map
Kmake_srs socket SRS_SOCKET
# Reverse SRS map
Kreverse_srs socket SRS_SOCKET
# "To" address is SRS
Kis_srs regex ^<?(SRS[01]|SES)[+=-].*
ifdef(`NO_SRS_FILE', `dnl
# Class of destination mailers not needing SRS
F{noSrsMailers}-o NO_SRS_FILE %[^\#]
')dnl
MAILER_DEFINITIONS
SEnvFromSMTP
R$+ $: $>MakeSrs $1 make SRS
LOCAL_RULESETS
SIsSrs
# Answers YES or NO whether the address in parameter is srs or not
R$* $: $( is_srs $1 $)
R$@ $@ YES
R$* $@ NO
SMakeSrs
ifdef(`NO_SRS_FROM_LOCAL',`dnl
#
# Prevent SRS encapsulation if "From" address is local
# (With a local from address, the forwarder mail will pass any SPF checks
# anyways, so why bother with SRS?)
R$* < @ $=w > $* $@ $1 < @ $2 > $3
R$* < @ $=w . > $* $@ $1 < @ $2 . > $3
')dnl
R$* $: $&h $| $1
ifdef(`NO_SRS_FILE',`dnl
#
# If destination mailer is in non-SRS list, do not apply SRS
# This is intended for handling communication between secondary MX and
# primary MX
R$={noSrsMailers} $| $* $@ $2
')dnl
#R$* $| $* $: $2
R$* $: $(make_srs $1 $)
SReverseSrs
R$* $: $1 $>IsSrs $1
R$* NO $@ $1
R$* YES $@ $(reverse_srs $1 $)
LOCAL_RULE_0
R$* $: $>ReverseSrs $1