Subject: patch for true virtual list hosting

From: martin f krafft <[email-masked]>
Date: Wed, 29 Aug 2007 10:32:08 +0200

Package: mailman
Version: 2.1.9-1
Severity: wishlist
Tags: patch

Please consider the patch at
http://nxsy.org/files/mailman-true-virtual.patch, which basically
encodes the urlhost in the lists' internal names and thus allows
lists with identical names on different virtual hosts. This patch
augments #351431 and likely obsoletes #345051 (on debbugs-cc).

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.22-1-amd64 (SMP w/1 CPU core)
Locale: LANG=en_GB, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

-- 
 .''`.   martin f. krafft <[email-masked]>
: :'  :  proud Debian developer, author, administrator, and user
`. `'`   http://people.debian.org/~madduck - http://debiansystem.info
  `-  Debian - when you have better things to do than fixing systems

---

From: martin f krafft <[email-masked]>
Date: Thu, 30 Aug 2007 13:47:28 +0200

I ended up having to rewrite the patch, and it's currently being
tested. This will be a while...

-- 
 .''`.   martin f. krafft <[email-masked]>
: :'  :  proud Debian developer, author, administrator, and user
`. `'`   http://people.debian.org/~madduck - http://debiansystem.info
  `-  Debian - when you have better things to do than fixing systems
diff --git a/Mailman/Defaults.py.in b/Mailman/Defaults.py.in
index 142f5d8..c49fd01 100644
--- a/Mailman/Defaults.py.in
+++ b/Mailman/Defaults.py.in
@@ -115,6 +115,13 @@ HTML_TO_PLAIN_TEXT_COMMAND = '/usr/bin/lynx -dump %(filename)s'
 # Virtual domains
 #####
 
+# In true virtual mode, Mailman uses the email hostname as part of the list's
+# internal name and thus allows lists with identical local names (before the
+# @) to exist in different email domains serviced by the same Mailman
+# instance.
+# THIS FEATURE IS EXPERIMENTAL
+TRUE_VIRTUAL = False
+
 # Set up your virtual host mappings here.  This is primarily used for the
 # thru-the-web list creation, so its effects are currently fairly limited.
 # Use add_virtualhost() call to add new mappings.  The keys are strings as
diff --git a/Mailman/MailList.py b/Mailman/MailList.py
index e07e23a..a62b6e3 100644
--- a/Mailman/MailList.py
+++ b/Mailman/MailList.py
@@ -185,9 +185,13 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
         return self._full_path
 
     def getListAddress(self, extra=None):
+        addr = None
         if extra is None:
-            return '%s@%s' % (self.internal_name(), self.host_name)
-        return '%s-%s@%s' % (self.internal_name(), extra, self.host_name)
+            addr = self.internal_name()
+        addr = self.internal_name() + '-' + extra
+        if not mm_cfg.TRUE_VIRTUAL:
+            addr += self.host_name
+        return addr
 
     # For backwards compatibility
     def GetBouncesEmail(self):
@@ -344,8 +348,12 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
                 mm_cfg.DEFAULT_BOUNCE_MATCHING_HEADERS
         self.header_filter_rules = []
         self.anonymous_list = mm_cfg.DEFAULT_ANONYMOUS_LIST
-        internalname = self.internal_name()
-        self.real_name = internalname[0].upper() + internalname[1:]
+        if mm_cfg.TRUE_VIRTUAL:
+            localname = self.internal_name().split('@', 1)[0]
+            self.real_name = localname[0].upper() + localname[1:]
+        else:
+            internalname = self.internal_name()
+            self.real_name = internalname[0].upper() + internalname[1:]
         self.description = ''
         self.info = ''
         self.welcome_msg = ''
@@ -470,8 +478,6 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
     #
     def Create(self, name, admin, crypted_password,
                langs=None, emailhost=None):
-        if Utils.list_exists(name):
-            raise Errors.MMListAlreadyExistsError, name
         # Validate what will be the list's posting address.  If that's
         # invalid, we don't want to create the mailing list.  The hostname
         # part doesn't really matter, since that better already be valid.
@@ -484,8 +490,12 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
             Utils.ValidateEmail(postingaddr)
         except Errors.MMBadEmailError:
             raise Errors.BadListNameError, postingaddr
+        if Utils.list_exists(postingaddr):
+            raise Errors.MMListAlreadyExistsError, postingaddr
         # Validate the admin's email address
         Utils.ValidateEmail(admin)
+        if mm_cfg.TRUE_VIRTUAL:
+            name = postingaddr
         self._internal_name = name
         self._full_path = Site.get_listpath(name, create=1)
         # Don't use Lock() since that tries to load the non-existant config.pck
diff --git a/debian/changelog b/debian/changelog
index 9a52e2c..e251140 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+mailman (1:2.1.9-8+truevirtual) unstable; urgency=low
+
+  * Add TRUE_VIRTUAL configuration option to allow true virtual hosting of
+    mailing lists, meaning that lists with identical names can coexist in
+    different domains inside the same Mailman instance (closes: #440016).
+
+ -- martin f. krafft <[email-masked]>  Thu, 30 Aug 2007 13:08:22 +0200
+
 mailman (1:2.1.9-8) unstable; urgency=low
 
   [ Thijs Kinkhorst ]