CVS: tmda/TMDA MTA.py,1.15,1.16 Util.py,1.94,1.95 ChangeLog,1.270,1.271
Timothy Legant <[email protected]>
| Newsgroups | gmane.mail.spam.tmda.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/tmda/tmda/TMDA
In directory sc8-pr-cvs1:/tmp/cvs-serv20319
Modified Files:
MTA.py Util.py ChangeLog
Log Message:
Moved getvdomainprepend from MTA to Util in preparation for changes to
Deliver. MTA imports Deliver, which needs Defaults. MTA was imported by
tmda-ofmipd, which cannot reference Defaults, even indirectly. Moving
getvdomainprepend to Util removes the tmda-ofmipd dependency on MTA.
Added add_headers and purge_headers functions to Util. Now all of the loops
that were formerly in AutoResponse and tmda-inject are now just calls to
these functions in Util. Additionally, the new code in Deliver also uses
the purge_headers function.
Index: MTA.py
===================================================================
RCS file: /cvsroot/tmda/tmda/TMDA/MTA.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- MTA.py 27 Apr 2003 07:58:17 -0000 1.15
+++ MTA.py 25 May 2003 02:09:19 -0000 1.16
@@ -57,9 +57,6 @@
msg.deliver()
self.stop()
- def getvdomainprepend(self, address, vdomainsfile):
- raise NotImplementedError
-
class Exim(MTA):
"""Exim-specific methods and instance variables."""
@@ -102,42 +99,6 @@
msg = Deliver.Deliver(msg, instruction)
msg.deliver()
self.stop()
-
- def getvdomainprepend(self, address, vdomainsfile):
- ret_prepend = ''
- if os.path.exists(vdomainsfile):
- fp = open(vdomainsfile, 'r')
- # Parse the virtualdomains control file; see qmail-send(8) for
- # syntax rules. All this because qmail doesn't store the original
- # envelope recipient in the environment.
- u, d = address.split('@', 1)
- ousername = u.lower()
- odomain = d.lower()
- for line in fp.readlines():
- vdomain_match = 0
- line = line.strip().lower()
- # Comment or blank line?
- if line == '' or line[0] in '#':
- continue
- vdomain, prepend = line.split(':', 1)
- # domain:prepend
- if vdomain == odomain:
- vdomain_match = 1
- # .domain:prepend (wildcard)
- elif vdomain[:1] == '.' and odomain.find(vdomain) != -1:
- vdomain_match = 1
- # user@domain:prepend
- else:
- try:
- if vdomain.split('@', 1)[1] == odomain:
- vdomain_match = 1
- except IndexError:
- pass
- if vdomain_match:
- ret_prepend = prepend
- break
- fp.close()
- return ret_prepend
class Sendmail(MTA):
Index: Util.py
===================================================================
RCS file: /cvsroot/tmda/tmda/TMDA/Util.py,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -r1.94 -r1.95
--- Util.py 22 May 2003 22:28:07 -0000 1.94
+++ Util.py 25 May 2003 02:09:19 -0000 1.95
@@ -128,6 +128,43 @@
return statinfo[stat.ST_UID]
+def getvdomainprepend(address, vdomainsfile):
+ ret_prepend = ''
+ if os.path.exists(vdomainsfile):
+ fp = open(vdomainsfile, 'r')
+ # Parse the virtualdomains control file; see qmail-send(8) for
+ # syntax rules. All this because qmail doesn't store the original
+ # envelope recipient in the environment.
+ u, d = address.split('@', 1)
+ ousername = u.lower()
+ odomain = d.lower()
+ for line in fp.readlines():
+ vdomain_match = 0
+ line = line.strip().lower()
+ # Comment or blank line?
+ if line == '' or line[0] in '#':
+ continue
+ vdomain, prepend = line.split(':', 1)
+ # domain:prepend
+ if vdomain == odomain:
+ vdomain_match = 1
+ # .domain:prepend (wildcard)
+ elif vdomain[:1] == '.' and odomain.find(vdomain) != -1:
+ vdomain_match = 1
+ # user@domain:prepend
+ else:
+ try:
+ if vdomain.split('@', 1)[1] == odomain:
+ vdomain_match = 1
+ except IndexError:
+ pass
+ if vdomain_match:
+ ret_prepend = prepend
+ break
+ fp.close()
+ return ret_prepend
+
+
def getvuserhomedir(user, domain, script):
"""Return the home directory of a qmail virtual domain user."""
cmd = "%s %s %s" % (script, user, domain)
@@ -594,6 +631,33 @@
if pair[0].lower() == old.lower():
index = msg._headers.index(pair)
msg._headers[index] = (new, '%s' % pair[1])
+
+
+def add_headers(msg, headers):
+ """Add headers to a Message object.
+
+ msg is an email.Message.Message object.
+
+ headers is a dictionary of headers and values.
+ """
+ if headers:
+ keys = headers.keys()
+ keys.sort()
+ for k in keys:
+ del msg[k]
+ msg[k] = headers[k]
+
+
+def purge_headers(msg, headers):
+ """Purge headers from a Message object.
+
+ msg is an email.Message.Message object.
+
+ headers is a list of headers.
+ """
+ if headers:
+ for h in headers:
+ del msg[h]
def build_cdb(filename):
Index: ChangeLog
===================================================================
RCS file: /cvsroot/tmda/tmda/TMDA/ChangeLog,v
retrieving revision 1.270
retrieving revision 1.271
diff -u -r1.270 -r1.271
--- ChangeLog 22 May 2003 21:06:34 -0000 1.270
+++ ChangeLog 25 May 2003 02:09:20 -0000 1.271
@@ -1,3 +1,12 @@
+2003-05-24 Tim Legant <[email protected]>
+
+ * MTA.py (MTA.getvdomainprepend): Removed function.
+ (Qmail.getvdomainprepend): Moved function to Util.py.
+
+ * Util.py (getvdomainprepend): New function, moved from MTA.py.
+ (add_headers): New function.
+ (purge_headers): New function.
+
2003-05-22 Jason R. Mastaler <[email protected]>
* Version.py (ALL): Add CODENAME.
_______________________________________
tmda-cvs mailing list
http://tmda.net/lists/listinfo/tmda-cvs