summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw1999-04-16 02:31:35 +0000
committerbwarsaw1999-04-16 02:31:35 +0000
commit10b780ffebd1c9589297a05e8ef7a7b2c11d082a (patch)
tree6438d509e9f66fda2e2d1d65f1f3882a6c66b37a
parent0bce3a95cb9e2deff06ffaace47664a18b0c50ed (diff)
downloadmailman-10b780ffebd1c9589297a05e8ef7a7b2c11d082a.tar.gz
mailman-10b780ffebd1c9589297a05e8ef7a7b2c11d082a.tar.zst
mailman-10b780ffebd1c9589297a05e8ef7a7b2c11d082a.zip
Post(): New policy for message loops (e.g. messages that show up at
the mailing list that have a matching X-BeenThere header). Instead of holding such messages for approval, an MMLoopingPost error is raised. This is caught by the post CGI script, which logs this occurance and sends a notice (containing the original message) to the list admin. This way, the admin knows there's a problem and can track the loop down, but isn't so inconvenienced to go the the Web page just to discard the message (the usual disposition).
-rw-r--r--Mailman/MailList.py5
-rwxr-xr-xscripts/post37
2 files changed, 25 insertions, 17 deletions
diff --git a/Mailman/MailList.py b/Mailman/MailList.py
index a6277c07b..40baffe8d 100644
--- a/Mailman/MailList.py
+++ b/Mailman/MailList.py
@@ -1118,9 +1118,8 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin,
beentheres = map(lambda x: string.split(x, ": ")[1][:-1],
msg.getallmatchingheaders('x-beenthere'))
if self.GetListEmail() in beentheres:
- self.AddRequest('post', Utils.SnarfMessage(msg),
- Errors.LOOPING_POST,
- msg.getheader('subject'))
+ # Exit from scripts/post - no longer held
+ raise Errors.MMLoopingPost
if len(self.forbidden_posters):
forbidden_posters = Utils.List2Dict(self.forbidden_posters)
addrs = Utils.FindMatchingAddresses(sender, forbidden_posters)
diff --git a/scripts/post b/scripts/post
index b180043d7..4939731a7 100755
--- a/scripts/post
+++ b/scripts/post
@@ -34,7 +34,7 @@ import paths
from Mailman import MailList
from Mailman import Message
from Mailman import Errors
-from Mailman.Utils import maketext
+from Mailman import Utils
from Mailman.Logging.Utils import LogStdErr
LogStdErr("error", "post")
@@ -42,14 +42,14 @@ LogStdErr("error", "post")
# Only let one program run at once per list.
# TODO: This can fail, and should send back an error message when it does.
-current_list = MailList.MailList(sys.argv[1])
+mlist = MailList.MailList(sys.argv[1])
if len(sys.argv) > 2:
# assert sys.argv[1] == 'fromusenet'
fromusenet = 1
else:
fromusenet = 0
try:
- prog = current_list.filter_prog
+ prog = mlist.filter_prog
if prog:
import os, __main__
file = os.path.join(paths.prefix, 'filters', prog)
@@ -70,28 +70,37 @@ try:
# more of a PITA for the list owner.
msg.fromusenet = fromusenet
try:
- current_list.Post(msg, approved=fromusenet)
+ mlist.Post(msg, approved=fromusenet)
+ except Errors.MMLoopingPost:
+ # let the list admin know this happened, but don't otherwise hold the
+ # message for approval.
+ sys.stderr.write('Message already came through this list\n')
+ map(sys.stderr.write, msg.headers)
+ sys.stderr.write('[body of message suppressed]\n')
+ mlist.SendTextToUser(
+ subject='Message loop detected [message discarded]',
+ text=Utils.SnarfMessage(msg)[1],
+ recipient=mlist.GetAdminEmail())
except Errors.MMNeedApproval, err_msg:
- if (current_list.dont_respond_to_post_requests
+ if (mlist.dont_respond_to_post_requests
or err_msg == Errors.MODERATED_LIST_MSG):
# Do not send hold-for-approval notices for moderated messages.
- current_list.Unlock()
+ mlist.Unlock()
sys.exit(0)
-
the_sender = msg.GetSender()
subj = msg.getheader('subject')
if not subj:
subj = '[no subject]'
- body = maketext(
+ body = Utils.maketext(
'postheld.txt',
- {'list_name': current_list.real_name,
+ {'list_name': mlist.real_name,
'subject' : subj,
'reason' : err_msg,
})
- current_list.SendTextToUser( subject = 'Mail sent to %s' %
- current_list.real_name,
- recipient = the_sender,
- text = body)
+ mlist.SendTextToUser(
+ subject = 'Mail sent to %s' % mlist.real_name,
+ recipient = the_sender,
+ text = body)
# Let another process run.
finally:
- current_list.Unlock()
+ mlist.Unlock()