diff options
| author | tkikuchi | 2006-10-02 01:01:35 +0000 |
|---|---|---|
| committer | tkikuchi | 2006-10-02 01:01:35 +0000 |
| commit | 8d4311293a6c5b95cca67275aae417ffb124e181 (patch) | |
| tree | 1e54d8147a2281926678248dac6126459070373a | |
| parent | 24226cea7c8de34af54715c7f62a9161a51f896f (diff) | |
| download | mailman-8d4311293a6c5b95cca67275aae417ffb124e181.tar.gz mailman-8d4311293a6c5b95cca67275aae417ffb124e181.tar.zst mailman-8d4311293a6c5b95cca67275aae417ffb124e181.zip | |
| -rw-r--r-- | Mailman/Defaults.py.in | 21 | ||||
| -rw-r--r-- | Mailman/MTA/Postfix.py | 54 |
2 files changed, 74 insertions, 1 deletions
diff --git a/Mailman/Defaults.py.in b/Mailman/Defaults.py.in index 9319277c2..9c441e4ac 100644 --- a/Mailman/Defaults.py.in +++ b/Mailman/Defaults.py.in @@ -705,6 +705,27 @@ USE_MAILDIR = No # file (uncommented of course!) # QRUNNERS.append(('MaildirRunner', 1)) +# Set this to Yes to use the `LMTP' delivery option. If you change this +# you will need to re-run bin/genaliases for MTAs that don't use list +# auto-detection. +# +# You have to set following line in postfix main.cf: +# transport_maps = hash:<prefix>/data/transport +# Also needed is following line if your list is in $mydestination: +# alias_maps = hash:/etc/aliases, hash:<prefix>/data/aliases +# +# NOTE: LMTP delivery is experimental for Mailman 2.2. +USE_LMTP = No +# NOTE: If you set USE_LMTP = Yes, add the following line to your mailman.cfg +# file (uncommented of course!) +# QRUNNERS.append(('LMTPRunner', 1)) + +# Change LMTP_HOST and LMTP_PORT for your convenience. +# You should be careful enough to use firewall if you +# open your port on global address interface. +LMTP_HOST = 'localhost' +LMTP_PORT = 8025 + # After processing every file in the qrunner's slice, how long should the # runner sleep for before checking the queue directory again for new files? # This can be a fraction of a second, or zero to check immediately diff --git a/Mailman/MTA/Postfix.py b/Mailman/MTA/Postfix.py index ebf934871..124c18999 100644 --- a/Mailman/MTA/Postfix.py +++ b/Mailman/MTA/Postfix.py @@ -35,6 +35,7 @@ from Mailman.i18n import _ LOCKFILE = os.path.join(config.LOCK_DIR, 'creator') ALIASFILE = os.path.join(config.DATA_DIR, 'aliases') VIRTFILE = os.path.join(config.DATA_DIR, 'virtual-mailman') +TRPTFILE = os.path.join(config.DATA_DIR, 'transport') log = logging.getLogger('mailman.error') @@ -42,6 +43,13 @@ log = logging.getLogger('mailman.error') def _update_maps(): msg = 'command failed: %s (status: %s, %s)' + if config.USE_LMTP: + tcmd = config.POSTFIX_MAP_CMD + ' ' + TRPTFILE + status = (os.system(tcmd) >> 8) & 0xff + if status: + errstr = os.strerror(status) + log.error(msg, tcmd, status, errstr) + raise RuntimeError(msg % (tcmd, status, errstr)) acmd = config.POSTFIX_ALIAS_CMD + ' ' + ALIASFILE status = (os.system(acmd) >> 8) & 0xff if status: @@ -73,6 +81,7 @@ def _zapfile(filename): def clear(): _zapfile(ALIASFILE) _zapfile(VIRTFILE) + _zapfile(TRPTFILE) @@ -202,6 +211,35 @@ def _check_for_virtual_loopaddr(mlist, filename): +def _addtransport(mlist, fp): + # create/add postfix transport file for mailman + fp.seek(0, 2) + if not fp.tell(): + print >> fp, """\ +# This file is generated by Mailman, and is kept in sync with the +# binary hash file transport.db. YOU SHOULD NOT MANUALLY EDIT THIS FILE +# unless you know what you're doing, and can keep the two files properly +# in sync. If you screw it up, you're on your own. +""" + if mlist is None: + return + listname = mlist.internal_name() + hostname = mlist.host_name + fieldsz = len(listname) + len(hostname) + len('-unsubscribe') + 1 + # The text file entries get a little extra info + print >> fp, '# STANZA START:', listname + '@' + hostname + print >> fp, '# CREATED:', time.ctime(time.time()) + # Now add transport entries + for k, v in makealiases(mlist): + l = len(k + hostname) + 1 + print >> fp, '%s@%s' % (k, hostname), ((fieldsz - l) * ' ')\ + + 'lmtp:%s:%s' % (config.LMTP_HOST, config.LMTP_PORT) + # + print >> fp, '# STANZA END:', '%s@%s' % (listname, hostname) + print >> fp + + + def _do_create(mlist, textfile, func): # Crack open the plain text file try: @@ -228,6 +266,14 @@ def create(mlist, cgi=False, nolock=False, quiet=False): if not nolock: lock = makelock() lock.lock() + # Create transport file if USE_LMTP + if config.USE_LMTP: + try: + _do_create(mlist, TRPTFILE, _addtransport) + _update_maps() + finally: + if lock: + lock.unlock(unconditionally=True) # Do the aliases file, which need to be done in any case try: _do_create(mlist, ALIASFILE, _addlist) @@ -292,6 +338,12 @@ def remove(mlist, cgi=False): # Acquire the global list database lock lock = makelock() lock.lock() + if config.USE_LMTP: + try: + _do_remove(mlist, TRPTFILE, False) + _update_maps() + finally: + lock.unlock(unconditionally=True) try: _do_remove(mlist, ALIASFILE, False) if mlist.host_name in config.POSTFIX_STYLE_VIRTUAL_DOMAINS: @@ -305,7 +357,7 @@ def remove(mlist, cgi=False): def checkperms(state): targetmode = S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP - for file in ALIASFILE, VIRTFILE: + for file in ALIASFILE, VIRTFILE, TRPTFILE: if state.VERBOSE: print _('checking permissions on %(file)s') stat = None |
