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
a418f344
Commit
a418f344
authored
Nov 7, 2005
by
Stuart Gathman
Browse files
Options
Downloads
Patches
Plain Diff
GOSSiP support, local database only.
parent
ba5854fc
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
+36
-6
36 additions, 6 deletions
bms.py
with
36 additions
and
6 deletions
bms.py
+
36
−
6
View file @
a418f344
#!/usr/bin/env python
# A simple milter that has grown quite a bit.
# $Log$
# Revision 1.39 2005/10/31 00:04:58 customdesigned
# Simple implementation of trusted_forwarder list. Inefficient for
# more than 1 or 2 entries.
#
# Revision 1.38 2005/10/28 19:36:54 customdesigned
# Don't check internal_domains for trusted_relay.
#
...
...
@@ -317,6 +321,12 @@ from Milter.dynip import is_dynip as dynip
from
fnmatch
import
fnmatchcase
from
email.Header
import
decode_header
# Import gossip if available
try
:
import
gossip
from
gossip.server
import
Gossip
except
:
gossip
=
None
# Import pysrs if available
try
:
import
SRS
...
...
@@ -391,6 +401,9 @@ logging.basicConfig(
)
milter_log
=
logging
.
getLogger
(
'
milter
'
)
if
gossip
:
gossip_node
=
Gossip
(
'
gossip4.db
'
,
30
)
class
MilterConfigParser
(
ConfigParser
.
ConfigParser
):
def
getlist
(
self
,
sect
,
opt
):
...
...
@@ -762,7 +775,8 @@ class bmsMilter(Milter.Milter):
def
connect
(
self
,
hostname
,
unused
,
hostaddr
):
self
.
internal_connection
=
False
self
.
trusted_relay
=
False
self
.
receiver
=
self
.
getsymval
(
'
j
'
)
# sometimes people put extra space in sendmail config, so we strip
self
.
receiver
=
self
.
getsymval
(
'
j
'
).
strip
()
if
hostaddr
and
len
(
hostaddr
)
>
0
:
ipaddr
=
hostaddr
[
0
]
for
pat
in
internal_connect
:
...
...
@@ -922,13 +936,24 @@ class bmsMilter(Milter.Milter):
self
.
dspam
=
False
else
:
self
.
rejectvirus
=
False
domain
=
None
if
not
self
.
hello_name
:
self
.
log
(
"
REJECT: missing HELO
"
)
self
.
setreply
(
'
550
'
,
'
5.7.1
'
,
"
It
'
s polite to say HELO first.
"
)
return
Milter
.
REJECT
self
.
umis
=
None
if
not
(
self
.
internal_connection
or
self
.
trusted_relay
)
\
and
self
.
connectip
and
spf
:
return
self
.
check_spf
()
rc
=
self
.
check_spf
()
if
rc
!=
Milter
.
CONTINUE
or
not
domain
or
not
gossip
:
return
rc
if
self
.
spf
.
result
==
'
pass
'
:
qual
=
'
SPF
'
else
:
qual
=
self
.
connectip
self
.
umis
=
gossip
.
umis
(
domain
+
qual
,
self
.
id
+
time
.
time
())
res
,
hdr
,
val
=
gossip_node
.
query
(
self
.
umis
,
domain
,
qual
,
1
)
self
.
add_header
(
hdr
,
val
,
idx
=
0
)
else
:
self
.
spf
=
None
return
Milter
.
CONTINUE
...
...
@@ -1359,8 +1384,8 @@ class bmsMilter(Milter.Milter):
ds
.
headerchange
=
self
.
_headerChange
modified
=
False
for
rcpt
in
self
.
recipients
:
if
dspam_users
.
has_key
(
rcpt
):
user
=
dspam_users
.
get
(
rcpt
)
if
dspam_users
.
has_key
(
rcpt
.
lower
()
):
user
=
dspam_users
.
get
(
rcpt
.
lower
()
)
if
user
:
try
:
self
.
fp
.
seek
(
0
)
...
...
@@ -1476,6 +1501,8 @@ class bmsMilter(Milter.Milter):
# analyze external mail for spam
spam_checked
=
self
.
check_spam
()
# tag or quarantine for spam
if
not
self
.
fp
:
if
gossip
and
self
.
umis
:
gossip_node
.
feedback
(
self
.
umis
,
1
)
return
spam_checked
# analyze all mail for dangerous attachments and scripts
...
...
@@ -1581,7 +1608,10 @@ class bmsMilter(Milter.Milter):
buf
=
out
.
read
(
8192
)
if
len
(
buf
)
==
0
:
break
self
.
replacebody
(
buf
)
# feed modified message to sendmail
if
spam_checked
:
self
.
log
(
"
dspam
"
)
if
spam_checked
:
if
gossip
and
self
.
umis
:
gossip_node
.
feedback
(
self
.
umis
,
0
)
self
.
log
(
"
dspam
"
)
return
rc
finally
:
out
.
close
()
...
...
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
sign in
to comment