-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path99_virtualdomains.patch
180 lines (171 loc) · 8.15 KB
/
99_virtualdomains.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
Index: mailman-2.1.18/Mailman/Gui/General.py
===================================================================
--- mailman-2.1.18.orig/Mailman/Gui/General.py
+++ mailman-2.1.18/Mailman/Gui/General.py
@@ -516,7 +516,7 @@ class General(GUIBase):
def _setValue(self, mlist, property, val, doc):
if property == 'real_name' and \
- val.lower() <> mlist.internal_name().lower():
+ val.lower() <> mlist.real_name().lower():
# These values can't differ by other than case
doc.addError(_("""<b>real_name</b> attribute not
changed! It must differ from the list's name by case
Index: mailman-2.1.18/Mailman/Handlers/CookHeaders.py
===================================================================
--- mailman-2.1.18.orig/Mailman/Handlers/CookHeaders.py
+++ mailman-2.1.18/Mailman/Handlers/CookHeaders.py
@@ -231,7 +231,9 @@ def process(mlist, msg, msgdata):
if msgdata.get('_nolist') or not mlist.include_rfc2369_headers:
return
# This will act like an email address for purposes of formataddr()
- listid = '%s.%s' % (mlist.internal_name(), mlist.host_name)
+ #listid = '%s.%s' % (mlist.internal_name(), mlist.host_name)
+ # internal_name already contains the hostname with the vhost patch
+ listid = mlist.internal_name()
cset = Utils.GetCharSet(mlist.preferred_language)
if mlist.description:
# Don't wrap the header since here we just want to get it properly RFC
Index: mailman-2.1.18/Mailman/MTA/Postfix.py
===================================================================
--- mailman-2.1.18.orig/Mailman/MTA/Postfix.py
+++ mailman-2.1.18/Mailman/MTA/Postfix.py
@@ -29,6 +29,7 @@ from Mailman import Utils
from Mailman import LockFile
from Mailman.i18n import _
from Mailman.MTA.Utils import makealiases
+from Mailman.MTA.Utils import makevirtualaliases
from Mailman.Logging.Syslog import syslog
LOCKFILE = os.path.join(mm_cfg.LOCK_DIR, 'creator')
@@ -150,12 +151,14 @@ def _addvirtual(mlist, fp):
print >> fp, '# STANZA START:', listname
print >> fp, '# CREATED:', time.ctime(time.time())
# Now add all the standard alias entries
- for k, v in makealiases(listname):
- fqdnaddr = '%s@%s' % (k, hostname)
+ #for k, v in makealiases(listname):
+ # fqdnaddr = '%s@%s' % (k, hostname)
+ for k, v in makevirtualaliases():
+ fqdnaddr = '%s%s@%s' % (mlist.real_name, k, hostname)
if mm_cfg.VIRTUAL_MAILMAN_LOCAL_DOMAIN:
- localaddr = '%s@%s' % (k, mm_cfg.VIRTUAL_MAILMAN_LOCAL_DOMAIN)
+ localaddr = '%s%s@%s' % (listname, k, mm_cfg.VIRTUAL_MAILMAN_LOCAL_DOMAIN)
else:
- localaddr = k
+ localaddr = '%s%s' % (listname, k)
# Format the text file nicely
print >> fp, fqdnaddr, ((fieldsz - len(k)) * ' '), localaddr
# Finish the text file stanza
Index: mailman-2.1.18/Mailman/MTA/Utils.py
===================================================================
--- mailman-2.1.18.orig/Mailman/MTA/Utils.py
+++ mailman-2.1.18/Mailman/MTA/Utils.py
@@ -76,6 +76,15 @@ def _makealiases_maildir(listname):
aliases.append(('%s-%s' % (listname, ext), maildir))
return aliases
+def makevirtualaliases():
+ maildir = mm_cfg.MAILDIR_DIR
+ if not maildir.endswith('/'):
+ maildir += '/'
+ aliases = [('', maildir)]
+ for ext in ('admin', 'bounces', 'confirm', 'join', 'leave', 'owner',
+ 'request', 'subscribe', 'unsubscribe'):
+ aliases.append(('-%s' % (ext), maildir))
+ return aliases
if mm_cfg.USE_MAILDIR:
Index: mailman-2.1.18/Mailman/MailList.py
===================================================================
--- mailman-2.1.18.orig/Mailman/MailList.py
+++ mailman-2.1.18/Mailman/MailList.py
@@ -185,9 +185,14 @@ class MailList(HTMLFormatter, Deliverer,
return self._full_path
def getListAddress(self, extra=None):
+ posting_addr = self.internal_name()
+ try:
+ posting_addr = self.real_name.lower()
+ except:
+ pass
if extra is None:
- return '%s@%s' % (self.internal_name(), self.host_name)
- return '%s-%s@%s' % (self.internal_name(), extra, self.host_name)
+ return '%s@%s' % (posting_addr, self.host_name)
+ return '%s-%s@%s' % (posting_addr, extra, self.host_name)
# For backwards compatibility
def GetBouncesEmail(self):
@@ -481,8 +486,8 @@ class MailList(HTMLFormatter, Deliverer,
def Create(self, name, admin, crypted_password,
langs=None, emailhost=None, urlhost=None):
assert name == name.lower(), 'List name must be all lower case.'
- if Utils.list_exists(name):
- raise Errors.MMListAlreadyExistsError, name
+ #if Utils.list_exists(name):
+ # raise Errors.MMListAlreadyExistsError, name
# Problems and potential attacks can occur if the list name in the
# pipe to the wrapper in an MTA alias or other delivery process
# contains shell special characters so allow only defined characters
@@ -496,19 +501,33 @@ class MailList(HTMLFormatter, Deliverer,
# the admin's email address, so transform the exception.
if emailhost is None:
emailhost = mm_cfg.DEFAULT_EMAIL_HOST
- postingaddr = '%s@%s' % (name, emailhost)
+ #postingaddr = '%s@%s' % (name, emailhost)
+ # default, for when no domain is given
+ firstname = name
+ # we set a special name for virtual hosted lists
+ if '@' in name:
+ firstname, emailhost = name.split('@', 1)
+ name = "%s-%s" % (firstname, emailhost)
+ # but we keep a sensible posting address
+ postingaddr = '%s@%s' % (firstname, emailhost)
try:
Utils.ValidateEmail(postingaddr)
except Errors.EmailAddressError:
raise Errors.BadListNameError, postingaddr
# Validate the admin's email address
Utils.ValidateEmail(admin)
+ if Utils.list_exists(name):
+ raise Errors.MMListAlreadyExistsError, name
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
self.__lock.lock()
self.InitVars(name, admin, crypted_password, urlhost=urlhost)
self.CheckValues()
+ # this is for getListAddress
+ self.list_address = postingaddr
+ self.real_name = firstname
+ self.subject_prefix = mm_cfg.DEFAULT_SUBJECT_PREFIX % self.__dict__
if langs is None:
self.available_languages = [self.preferred_language]
else:
@@ -1371,7 +1390,8 @@ class MailList(HTMLFormatter, Deliverer,
addresses in the recipient headers.
"""
# This is the list's full address.
- listfullname = '%s@%s' % (self.internal_name(), self.host_name)
+ #listfullname = '%s@%s' % (self.internal_name(), self.host_name)
+ listfullname = self.getListAddress()
recips = []
# Check all recipient addresses against the list's explicit addresses,
# specifically To: Cc: and Resent-to:
@@ -1386,7 +1406,8 @@ class MailList(HTMLFormatter, Deliverer,
addr = addr.lower()
localpart = addr.split('@')[0]
if (# TBD: backwards compatibility: deprecated
- localpart == self.internal_name() or
+ #localpart == self.internal_name() or
+ localpart == self.real_name.lower() or
# exact match against the complete list address
addr == listfullname):
return True
Index: mailman-2.1.18/bin/newlist
===================================================================
--- mailman-2.1.18.orig/bin/newlist
+++ mailman-2.1.18/bin/newlist
@@ -157,7 +157,8 @@ def main():
if '@' in listname:
# note that --urlhost and --emailhost have precedence
- listname, domain = listname.split('@', 1)
+ #listname, domain = listname.split('@', 1)
+ firstname, domain = listname.split('@', 1)
urlhost = urlhost or domain
emailhost = emailhost or mm_cfg.VIRTUAL_HOSTS.get(domain, domain)