Revision: 8049
          http://svn.sourceforge.net/mailman/?rev=8049&view=rev
Author:   tkikuchi
Date:     2006-10-01 18:01:35 -0700 (Sun, 01 Oct 2006)

Log Message:
-----------
Postfix support functions for LMTP and configurations.

Modified Paths:
--------------
    trunk/mailman/Mailman/Defaults.py.in
    trunk/mailman/Mailman/MTA/Postfix.py

Modified: trunk/mailman/Mailman/Defaults.py.in
===================================================================
--- trunk/mailman/Mailman/Defaults.py.in        2006-10-02 00:53:00 UTC (rev 
8048)
+++ trunk/mailman/Mailman/Defaults.py.in        2006-10-02 01:01:35 UTC (rev 
8049)
@@ -705,6 +705,27 @@
 # 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

Modified: trunk/mailman/Mailman/MTA/Postfix.py
===================================================================
--- trunk/mailman/Mailman/MTA/Postfix.py        2006-10-02 00:53:00 UTC (rev 
8048)
+++ trunk/mailman/Mailman/MTA/Postfix.py        2006-10-02 01:01:35 UTC (rev 
8049)
@@ -35,6 +35,7 @@
 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 @@
 
 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 clear():
     _zapfile(ALIASFILE)
     _zapfile(VIRTFILE)
+    _zapfile(TRPTFILE)
 
 
 
@@ -202,6 +211,35 @@
 
 
 
+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, '[EMAIL PROTECTED]' % (k, hostname), ((fieldsz - l) * ' ')\
+                    + 'lmtp:%s:%s' % (config.LMTP_HOST, config.LMTP_PORT)
+    #
+    print >> fp, '# STANZA END:', '[EMAIL PROTECTED]' % (listname, hostname)
+    print >> fp
+
+
+
 def _do_create(mlist, textfile, func):
     # Crack open the plain text file
     try:
@@ -228,6 +266,14 @@
     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 @@
     # 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 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


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to