diff options
| author | tkikuchi | 2006-09-28 07:54:21 +0000 |
|---|---|---|
| committer | tkikuchi | 2006-09-28 07:54:21 +0000 |
| commit | b23ef654c9772fc42fad032899076631bed63e67 (patch) | |
| tree | 398293967679e5843f7e88ffcf3629825ba43eaa /Mailman | |
| parent | 0e32ec8acb43a6be1622fef7efd759e0cfc4cdf7 (diff) | |
| download | mailman-b23ef654c9772fc42fad032899076631bed63e67.tar.gz mailman-b23ef654c9772fc42fad032899076631bed63e67.tar.zst mailman-b23ef654c9772fc42fad032899076631bed63e67.zip | |
Here are the patches needed in order to create new lists on my test
installation. I've tested four cases of combination of
POSTFIX_STYLE_VIRTUAL_DOMAINS (Any/None) and USE_MAIL_DIR (Yes/No).
Also, I've added POSTFIX_VIRTUAL_SEPARATOR = '_at_' for unique mapping of
local part in the virtual-mailman/aliases files.
Diffstat (limited to 'Mailman')
| -rw-r--r-- | Mailman/Defaults.py.in | 4 | ||||
| -rw-r--r-- | Mailman/MTA/Postfix.py | 12 | ||||
| -rw-r--r-- | Mailman/MailList.py | 17 | ||||
| -rw-r--r-- | Mailman/Queue/MaildirRunner.py | 39 |
4 files changed, 46 insertions, 26 deletions
diff --git a/Mailman/Defaults.py.in b/Mailman/Defaults.py.in index 8bcc59ecd..9319277c2 100644 --- a/Mailman/Defaults.py.in +++ b/Mailman/Defaults.py.in @@ -389,6 +389,10 @@ MTA = 'Manual' # of the mailing lists. See README.POSTFIX for details. POSTFIX_STYLE_VIRTUAL_DOMAINS = [] +# We should use a separator in place of '@' for list-etc@dom2.ain in both +# aliases and mailman-virtual files. +POSTFIX_VIRTUAL_SEPARATOR = '_at_' + # These variables describe the program to use for regenerating the aliases.db # and virtual-mailman.db files, respectively, from the associated plain text # files. The file being updated will be appended to this string (with a diff --git a/Mailman/MTA/Postfix.py b/Mailman/MTA/Postfix.py index 51634ddf4..ebf934871 100644 --- a/Mailman/MTA/Postfix.py +++ b/Mailman/MTA/Postfix.py @@ -99,14 +99,18 @@ def _addlist(mlist, fp): if mlist is None: return listname = mlist.internal_name() + hostname = mlist.host_name fieldsz = len(listname) + len('-unsubscribe') # The text file entries get a little extra info print >> fp, '# STANZA START:', listname print >> fp, '# CREATED:', time.ctime(time.time()) # Now add all the standard alias entries for k, v in makealiases(mlist): + l = len(k) + if hostname in config.POSTFIX_STYLE_VIRTUAL_DOMAINS: + k += config.POSTFIX_VIRTUAL_SEPARATOR + hostname # Format the text file nicely - print >> fp, k + ':', ((fieldsz - len(k)) * ' ') + v + print >> fp, k + ':', ((fieldsz - l) * ' ') + v # Finish the text file stanza print >> fp, '# STANZA END:', listname print >> fp @@ -142,8 +146,12 @@ def _addvirtual(mlist, fp): print >> fp, '# CREATED:', time.ctime(time.time()) # Now add all the standard alias entries for k, v in makealiases(mlist): + fqdnaddr = '%s@%s' % (k, hostname) + l = len(k) # Format the text file nicely - print >> fp, mlist.fqdn_listname, ((fieldsz - len(k)) * ' '), k + if hostname in config.POSTFIX_STYLE_VIRTUAL_DOMAINS: + k += config.POSTFIX_VIRTUAL_SEPARATOR + hostname + print >> fp, fqdnaddr, ((fieldsz - l) * ' '), k # Finish the text file stanza print >> fp, '# STANZA END:', listname print >> fp diff --git a/Mailman/MailList.py b/Mailman/MailList.py index 710ec1bd4..17dce5666 100644 --- a/Mailman/MailList.py +++ b/Mailman/MailList.py @@ -287,14 +287,17 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin, os.path.join(config.LOCK_DIR, name or '<site>') + '.lock', lifetime=config.LIST_LOCK_LIFETIME) # XXX FIXME Sometimes name is fully qualified, sometimes it's not. - if '@' in name: - self._internal_name, self.host_name = name.split('@', 1) - self._full_path = os.path.join(config.LIST_DATA_DIR, name) + if name: + if '@' in name: + self._internal_name, self.host_name = name.split('@', 1) + self._full_path = os.path.join(config.LIST_DATA_DIR, name) + else: + self._internal_name = name + self.host_name = config.DEFAULT_EMAIL_HOST + self._full_path = os.path.join(config.LIST_DATA_DIR, + self.host_name + '@' + name) else: - self._internal_name = name - self.host_name = config.DEFAULT_EMAIL_HOST - self._full_path = os.path.join(config.LIST_DATA_DIR, - self.host_name + '@' + name) + self._full_path = '' # Only one level of mixin inheritance allowed for baseclass in self.__class__.__bases__: if hasattr(baseclass, 'InitTempVars'): diff --git a/Mailman/Queue/MaildirRunner.py b/Mailman/Queue/MaildirRunner.py index e253f3506..210ffb8e8 100644 --- a/Mailman/Queue/MaildirRunner.py +++ b/Mailman/Queue/MaildirRunner.py @@ -50,7 +50,6 @@ mechanism. # NOTE: Maildir delivery is experimental in Mailman 2.1. import os -import re import errno import logging @@ -63,19 +62,28 @@ from Mailman.Queue.Runner import Runner from Mailman.Queue.sbcache import get_switchboard from Mailman.configuration import config +log = logging.getLogger('mailman.error') + # We only care about the listname and the subq as in listname@ or # listname-request@ -lre = re.compile(r""" - ^ # start of string - (?P<listname>[^-@]+) # listname@ or listname-subq@ - (?: # non-grouping - - # dash separator - (?P<subq>[^-+@]+) # everything up to + or - or @ - )? # if it exists - """, re.VERBOSE | re.IGNORECASE) - -log = logging.getLogger('mailman.error') +subqnames = ('admin','bounces','confirm','join','leave', + 'owner','request','subscribe','unsubscribe') +def getlistq(address): + localpart, domain = address.split('@', 1) + # TK: FIXME I only know configs of Postfix. + if config.POSTFIX_STYLE_VIRTUAL_DOMAINS: + p = localpart.split(config.POSTFIX_VIRTUAL_SEPARATOR,1) + if len(p) == 2: + localpart, domain = p + l = localpart.split('-') + if l[-1] in subqnames: + listname = '-'.join(l[:-1]) + subq = l[-1] + else: + listname = localpart + subq = None + return listname, subq, domain class MaildirRunner(Runner): @@ -129,14 +137,11 @@ class MaildirRunner(Runner): for header in ('delivered-to', 'envelope-to', 'apparently-to'): vals.extend(msg.get_all(header, [])) for field in vals: - to = parseaddr(field)[1] + to = parseaddr(field)[1].lower() if not to: continue - mo = lre.match(to) - if not mo: - # This isn't an address we care about - continue - listname, subq = mo.group('listname', 'subq') + listname, subq, domain = getlistq(to) + listname = listname + '@' + domain if listname in listnames: break else: |
