Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pymilter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
misc
pymilter
Commits
eda8680b
Commit
eda8680b
authored
19 years ago
by
Stuart Gathman
Browse files
Options
Downloads
Patches
Plain Diff
Don't require SPF pass for white/black listing mail from trusted relay.
Support localpart wildcard for white and black lists.
parent
afd3e0f0
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bms.py
+31
-10
31 additions, 10 deletions
bms.py
with
31 additions
and
10 deletions
bms.py
+
31
−
10
View file @
eda8680b
#!/usr/bin/env python
#!/usr/bin/env python
# A simple milter that has grown quite a bit.
# A simple milter that has grown quite a bit.
# $Log$
# $Log$
# Revision 1.59 2006/04/06 18:14:17 customdesigned
# Check whitelist/blacklist even when not checking SPF (e.g. trusted relay).
#
# Revision 1.58 2006/03/10 20:52:49 customdesigned
# Revision 1.58 2006/03/10 20:52:49 customdesigned
# Use re to recognize failure DSNs.
# Use re to recognize failure DSNs.
#
#
...
@@ -235,6 +238,7 @@ subjpats = (
...
@@ -235,6 +238,7 @@ subjpats = (
r
'
^delivery\b.*\bfailure
'
,
r
'
^delivery\b.*\bfailure
'
,
r
'
^delivery problem
'
,
r
'
^delivery problem
'
,
r
'
\buser unknown\b
'
,
r
'
\buser unknown\b
'
,
r
'
^failed
'
)
)
refaildsn
=
re
.
compile
(
'
|
'
.
join
(
subjpats
),
re
.
IGNORECASE
)
refaildsn
=
re
.
compile
(
'
|
'
.
join
(
subjpats
),
re
.
IGNORECASE
)
import
logging
import
logging
...
@@ -660,17 +664,33 @@ class AddrCache(object):
...
@@ -660,17 +664,33 @@ class AddrCache(object):
if
ts
>
too_old
:
if
ts
>
too_old
:
return
True
return
True
del
self
.
cache
[
sender
.
lower
()]
del
self
.
cache
[
sender
.
lower
()]
try
:
user
,
host
=
sender
.
split
(
'
@
'
,
1
)
return
self
.
has_key
(
host
)
except
ValueError
:
pass
except
KeyError
:
except
KeyError
:
try
:
user
,
host
=
sender
.
split
(
'
@
'
,
1
)
return
self
.
has_key
(
host
)
except
ValueError
:
pass
pass
return
False
return
False
def
__getitem__
(
self
,
sender
):
def
__getitem__
(
self
,
sender
):
try
:
ts
,
res
=
self
.
cache
[
sender
.
lower
()]
ts
,
res
=
self
.
cache
[
sender
.
lower
()]
too_old
=
time
.
time
()
-
self
.
age
*
24
*
60
*
60
# max age in days
too_old
=
time
.
time
()
-
self
.
age
*
24
*
60
*
60
# max age in days
if
ts
>
too_old
:
if
ts
>
too_old
:
return
res
return
res
del
self
.
cache
[
sender
.
lower
()]
del
self
.
cache
[
sender
.
lower
()]
raise
KeyError
,
sender
raise
KeyError
,
sender
except
KeyError
,
x
:
try
:
user
,
host
=
sender
.
split
(
'
@
'
,
1
)
return
self
.
__getitem__
(
host
)
except
ValueError
:
raise
x
def
__setitem__
(
self
,
sender
,
res
):
def
__setitem__
(
self
,
sender
,
res
):
lsender
=
sender
.
lower
()
lsender
=
sender
.
lower
()
...
@@ -906,16 +926,17 @@ class bmsMilter(Milter.Milter):
...
@@ -906,16 +926,17 @@ class bmsMilter(Milter.Milter):
self
.
setreply
(
'
550
'
,
'
5.7.1
'
,
"
It
'
s polite to say HELO first.
"
)
self
.
setreply
(
'
550
'
,
'
5.7.1
'
,
"
It
'
s polite to say HELO first.
"
)
return
Milter
.
REJECT
return
Milter
.
REJECT
self
.
umis
=
None
self
.
umis
=
None
self
.
spf
=
None
if
not
(
self
.
internal_connection
or
self
.
trusted_relay
)
\
if
not
(
self
.
internal_connection
or
self
.
trusted_relay
)
\
and
self
.
connectip
and
spf
:
and
self
.
connectip
and
spf
:
rc
=
self
.
check_spf
()
rc
=
self
.
check_spf
()
else
:
else
:
self
.
spf
=
None
rc
=
Milter
.
CONTINUE
rc
=
Milter
.
CONTINUE
#
Check whitelist and blacklis
t
#
FIXME: parse Received-SPF from trusted_relay for SPF resul
t
res
=
self
.
spf
and
self
.
spf
.
guess
res
=
self
.
spf
and
self
.
spf
.
guess
# Check whitelist and blacklist
if
auto_whitelist
.
has_key
(
self
.
canon_from
):
if
auto_whitelist
.
has_key
(
self
.
canon_from
):
if
res
==
'
pass
'
:
if
res
==
'
pass
'
or
self
.
trusted_relay
:
self
.
whitelist
=
True
self
.
whitelist
=
True
self
.
log
(
"
WHITELIST
"
,
self
.
canon_from
)
self
.
log
(
"
WHITELIST
"
,
self
.
canon_from
)
else
:
else
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment