summaryrefslogtreecommitdiff
path: root/mailman/pipeline
diff options
context:
space:
mode:
Diffstat (limited to 'mailman/pipeline')
-rw-r--r--mailman/pipeline/cleanse_dkim.py8
-rw-r--r--mailman/pipeline/scrubber.py13
-rw-r--r--mailman/pipeline/smtp_direct.py16
-rw-r--r--mailman/pipeline/to_digest.py14
-rw-r--r--mailman/pipeline/to_outgoing.py10
5 files changed, 31 insertions, 30 deletions
diff --git a/mailman/pipeline/cleanse_dkim.py b/mailman/pipeline/cleanse_dkim.py
index bd7de83dc..d4d8f38ae 100644
--- a/mailman/pipeline/cleanse_dkim.py
+++ b/mailman/pipeline/cleanse_dkim.py
@@ -26,12 +26,14 @@ originating at the Mailman server for the outgoing message.
"""
__metaclass__ = type
-__all__ = ['CleanseDKIM']
+__all__ = [
+ 'CleanseDKIM',
+ ]
+from lazr.config import as_boolean
from zope.interface import implements
-from mailman import Defaults
from mailman.i18n import _
from mailman.interfaces.handler import IHandler
@@ -47,7 +49,7 @@ class CleanseDKIM:
def process(self, mlist, msg, msgdata):
"""See `IHandler`."""
- if Defaults.REMOVE_DKIM_HEADERS:
+ if as_boolean(config.mta.remove_dkim_headers):
del msg['domainkey-signature']
del msg['dkim-signature']
del msg['authentication-results']
diff --git a/mailman/pipeline/scrubber.py b/mailman/pipeline/scrubber.py
index 7431cec27..f7ffd51e1 100644
--- a/mailman/pipeline/scrubber.py
+++ b/mailman/pipeline/scrubber.py
@@ -34,11 +34,12 @@ import binascii
from email.charset import Charset
from email.generator import Generator
from email.utils import make_msgid, parsedate
+from lazr.config import as_boolean
from locknix.lockfile import Lock
from mimetypes import guess_all_extensions
+from string import Template
from zope.interface import implements
-from mailman import Defaults
from mailman import Utils
from mailman.config import config
from mailman.core.errors import DiscardMessage
@@ -159,7 +160,7 @@ def replace_payload_by_text(msg, text, charset):
def process(mlist, msg, msgdata=None):
- sanitize = Defaults.ARCHIVE_HTML_SANITIZER
+ sanitize = int(config.scrubber.archive_html_sanitizer)
outer = True
if msgdata is None:
msgdata = {}
@@ -410,7 +411,7 @@ def save_attachment(mlist, msg, dir, filter_html=True):
filename, fnext = os.path.splitext(filename)
# For safety, we should confirm this is valid ext for content-type
# but we can use fnext if we introduce fnext filtering
- if Defaults.SCRUBBER_USE_ATTACHMENT_FILENAME_EXTENSION:
+ if as_boolean(config.scrubber.use_attachment_filename_extension):
# HTML message doesn't have filename :-(
ext = fnext or guess_extension(ctype, fnext)
else:
@@ -431,7 +432,8 @@ def save_attachment(mlist, msg, dir, filter_html=True):
with Lock(os.path.join(fsdir, 'attachments.lock')):
# Now base the filename on what's in the attachment, uniquifying it if
# necessary.
- if not filename or Defaults.SCRUBBER_DONT_USE_ATTACHMENT_FILENAME:
+ if (not filename or
+ not as_boolean(config.scrubber.use_attachment_filename)):
filebase = 'attachment'
else:
# Sanitize the filename given in the message headers
@@ -476,7 +478,8 @@ def save_attachment(mlist, msg, dir, filter_html=True):
try:
fp.write(decodedpayload)
fp.close()
- cmd = Defaults.ARCHIVE_HTML_SANITIZER % {'filename' : tmppath}
+ cmd = Template(config.mta.archive_html_sanitizer).safe_substitue(
+ filename=tmppath)
progfp = os.popen(cmd, 'r')
decodedpayload = progfp.read()
status = progfp.close()
diff --git a/mailman/pipeline/smtp_direct.py b/mailman/pipeline/smtp_direct.py
index 09b2223d6..b82fb9227 100644
--- a/mailman/pipeline/smtp_direct.py
+++ b/mailman/pipeline/smtp_direct.py
@@ -44,7 +44,6 @@ from email.Utils import formataddr
from string import Template
from zope.interface import implements
-from mailman import Defaults
from mailman import Utils
from mailman.config import config
from mailman.core import errors
@@ -70,7 +69,7 @@ class Connection:
port = int(config.mta.smtp_port)
log.debug('Connecting to %s:%s', host, port)
self.__conn.connect(host, port)
- self.__numsessions = Defaults.SMTP_MAX_SESSIONS_PER_CONNECTION
+ self.__numsessions = int(config.mta.max_sessions_per_connection)
def sendmail(self, envsender, recips, msgtext):
if self.__conn is None:
@@ -126,10 +125,10 @@ def process(mlist, msg, msgdata):
chunks = [[recip] for recip in recips]
msgdata['personalize'] = 1
deliveryfunc = verpdeliver
- elif Defaults.SMTP_MAX_RCPTS <= 0:
+ elif int(config.mta.max_recipients) <= 0:
chunks = [recips]
else:
- chunks = chunkify(recips, Defaults.SMTP_MAX_RCPTS)
+ chunks = chunkify(recips, int(config.mta.max_recipients))
# See if this is an unshunted message for which some were undelivered
if msgdata.has_key('undelivered'):
chunks = msgdata['undelivered']
@@ -316,12 +315,9 @@ def verpdeliver(mlist, msg, msgdata, envsender, failures, conn):
# this recipient.
log.info('Skipping VERP delivery to unqual recip: %s', recip)
continue
- d = {'bounces': bmailbox,
- 'mailbox': rmailbox,
- 'host' : DOT.join(rdomain),
- }
- envsender = '%s@%s' % ((Defaults.VERP_FORMAT % d),
- DOT.join(bdomain))
+ envsender = Template(config.mta.verp_format).safe_substitute(
+ bounces=bmailbox, mailbox=rmailbox,
+ host=DOT.join(rdomain)) + '@' + DOT.join(bdomain)
if mlist.personalize == Personalization.full:
# When fully personalizing, we want the To address to point to the
# recipient, not to the mailing list
diff --git a/mailman/pipeline/to_digest.py b/mailman/pipeline/to_digest.py
index d71bc71b0..e56c4a109 100644
--- a/mailman/pipeline/to_digest.py
+++ b/mailman/pipeline/to_digest.py
@@ -48,7 +48,6 @@ from email.parser import Parser
from email.utils import formatdate, getaddresses, make_msgid
from zope.interface import implements
-from mailman import Defaults
from mailman import Message
from mailman import Utils
from mailman import i18n
@@ -268,11 +267,10 @@ def send_i18n_digests(mlist, mboxfp):
# headers according to RFC 1153. Later, we'll strip out headers for
# for the specific MIME or plain digests.
keeper = {}
- all_keepers = {}
- for header in (Defaults.MIME_DIGEST_KEEP_HEADERS +
- Defaults.PLAIN_DIGEST_KEEP_HEADERS):
- all_keepers[header] = True
- all_keepers = all_keepers.keys()
+ all_keepers = set(
+ header for header in
+ config.digests.mime_digest_keep_headers.split() +
+ config.digests.plain_digest_keep_headers.split())
for keep in all_keepers:
keeper[keep] = msg.get_all(keep, [])
# Now remove all unkempt headers :)
@@ -283,7 +281,7 @@ def send_i18n_digests(mlist, mboxfp):
for field in keeper[keep]:
msg[keep] = field
# And a bit of extra stuff
- msg['Message'] = `msgcount`
+ msg['Message'] = repr(msgcount)
# Get the next message in the digest mailbox
msg = mbox.next()
# Now we're finished with all the messages in the digest. First do some
@@ -326,7 +324,7 @@ def send_i18n_digests(mlist, mboxfp):
print >> plainmsg, _('[Message discarded by content filter]')
continue
# Honor the default setting
- for h in Defaults.PLAIN_DIGEST_KEEP_HEADERS:
+ for h in config.digests.plain_digest_keep_headers.split():
if msg[h]:
uh = Utils.wrap('%s: %s' % (h, Utils.oneline(msg[h],
in_unicode=True)))
diff --git a/mailman/pipeline/to_outgoing.py b/mailman/pipeline/to_outgoing.py
index 7d56686b7..9ff7ab88a 100644
--- a/mailman/pipeline/to_outgoing.py
+++ b/mailman/pipeline/to_outgoing.py
@@ -23,12 +23,14 @@ recipient should just be placed in the out queue directly.
"""
__metaclass__ = type
-__all__ = ['ToOutgoing']
+__all__ = [
+ 'ToOutgoing',
+ ]
+from lazr.config import as_boolean
from zope.interface import implements
-from mailman import Defaults
from mailman.config import config
from mailman.i18n import _
from mailman.interfaces.handler import IHandler
@@ -46,7 +48,7 @@ class ToOutgoing:
def process(self, mlist, msg, msgdata):
"""See `IHandler`."""
- interval = Defaults.VERP_DELIVERY_INTERVAL
+ interval = int(config.mta.verp_delivery_interval)
# Should we VERP this message? If personalization is enabled for this
# list and VERP_PERSONALIZED_DELIVERIES is true, then yes we VERP it.
# Also, if personalization is /not/ enabled, but
@@ -58,7 +60,7 @@ class ToOutgoing:
if 'verp' in msgdata:
pass
elif mlist.personalize <> Personalization.none:
- if Defaults.VERP_PERSONALIZED_DELIVERIES:
+ if as_boolean(config.mta.verp_personalized_deliveries):
msgdata['verp'] = True
elif interval == 0:
# Never VERP