[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tmda-cvs
Subject:    CVS: tmda/bin ChangeLog,1.58,1.59 tmda-filter,1.47,1.48
From:       "Jason R. Mastaler" <jasonrm () users ! sourceforge ! net>
Date:       2001-08-24 22:01:25
[Download RAW message or body]

Update of /cvsroot/tmda/tmda/bin
In directory usw-pr-cvs1:/tmp/cvs-serv28783/bin

Modified Files:
	ChangeLog tmda-filter 
Log Message:
For a message sent to local@domain, confirm-*.HMAC is now just
appended to local so that when the confirmed message is released, it
will be processed by the same dot-qmail file that called tmda-filter
in the first place.

Code was also added to use the address that the message was originally
sent to (original envelope recipient) as a base instead of RECIPIENT
from the environment (which is munged under a qmail virtualdomain).
Unfortunately, qmail provides no easy method of obtaining this
information, so the control/virtualdomains file has to be parsed.

The templates were also modified to send confirmation messages with a
"From:" header that matches the original recipient for added
flexibility.


Index: ChangeLog
===================================================================
RCS file: /cvsroot/tmda/tmda/bin/ChangeLog,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- ChangeLog	2001/08/24 00:20:35	1.58
+++ ChangeLog	2001/08/24 22:01:23	1.59
@@ -1,3 +1,10 @@
+2001-08-24  Jason R. Mastaler  <jasonrm@nightshade.la.mastaler.com>
+
+	* tmda-filter (original_recipient): original_recipient is the
+	original address the message was sent to, not qmail-send's
+	rewritten interpretation.  This is now used in the code and
+	templates instead of envelope_recipient.
+
 2001-08-23  Jason R. Mastaler  <jasonrm@nightshade.la.mastaler.com>
 
 	* tmda-filter (bouncegen): Add support for Debian Linux packages

Index: tmda-filter
===================================================================
RCS file: /cvsroot/tmda/tmda/bin/tmda-filter,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- tmda-filter	2001/08/24 00:22:52	1.47
+++ tmda-filter	2001/08/24 22:01:23	1.48
@@ -105,19 +105,40 @@
 envelope_recipient = (message_headers.getheader('x-originally-to') or
                       os.environ.get('RECIPIENT'))
 
+# original_recipient is the original address the message was sent to,
+# not qmail-send's rewritten interpretation.  This will be the same as
+# envelope_recipient if we are not running under a virtualdomain.
+original_recipient = envelope_recipient
+if Defaults.QMAILVIRTUALDOMAINS:
+    (ousername, odomain) = string.split(envelope_recipient,'@')
+    for line in fileinput.input(Defaults.VIRTUALDOMAINS):
+        line = string.lower(string.strip(line))
+        # Comment or blank line?
+        if line == '' or line[0] in '#':
+            continue
+        else:
+            (vdomain, prepend) = string.split(line,':')
+            if vdomain == string.lower(odomain):
+                # strip off the prepend
+                if prepend:
+                    nusername = string.replace(ousername,prepend + '-','')
+                    original_recipient = nusername + '@' + odomain
+                    fileinput.close()
+                    break
+
 # Collect the message's Subject: for later use.
 subject = message_headers.getheader('subject', 'None')
 
 
 def logit(action_msg,date):
     """Write delivery statistics to the LOGFILE if enabled."""
-    if Defaults.LOGFILE and envelope_recipient:
+    if Defaults.LOGFILE and original_recipient:
         try:
             logfile = open(Defaults.LOGFILE, 'a') # append to the file
             Date = time.asctime(time.localtime(date))
             From = message_headers.getheader('from')
             if not From:From = envelope_sender
-            To = envelope_recipient
+            To = original_recipient
             Subject = subject
             Action = action_msg
             actionstr = 'Actn: ' + Action
@@ -168,10 +189,15 @@
 
 def inject_pending(pathname,timestamp,pid):
     """Reinject then unlink a sucessfully confirmed message."""
+    (username, hostname) = string.split(original_recipient,'@')
+    # Strip off the '-confirm-accept.TIMESTAMP.PID.HMAC' from username.
+    base_username = string.join((string.split(username,'-')[:-2]),'-')
+    base_recipient = base_username + '@' + hostname
     # Create the `confirm-done' address
-    confirm_done_cookie = Cookie.make_confirm_cookie(timestamp,pid,'done')
-    confirm_done_address = Defaults.USERNAME + '-confirm-done.' + \
-                           confirm_done_cookie + '@' + Defaults.HOSTNAME
+    confirm_done_address = Cookie.make_confirm_address(base_recipient,
+                                                       timestamp,
+                                                       pid,
+                                                       'done')
     curdate = time.strftime('%a, %d %b %Y %X -0000', time.gmtime(time.time()))
     try:
         fileobj = open(pathname,'r')
@@ -289,7 +315,7 @@
     """Bounce a message back to sender."""
     # Common variables.
     now = time.time()
-    envelope_recipient = globals().get('envelope_recipient')
+    original_recipient = globals().get('original_recipient')
     envelope_sender = globals().get('envelope_sender')
     subject = globals().get('subject')
     original_message = globals().get('message')
@@ -319,9 +345,10 @@
         pkg_template = pkg_template_dir + 'confirm_request.txt'
         timestamp = str('%d' %now)
         pid = str(os.getpid())
-        confirm_cookie = Cookie.make_confirm_cookie(timestamp,pid,'accept')
-        confirm_accept_address = Defaults.USERNAME + '-confirm-accept.' + \
-                                 confirm_cookie + '@' + Defaults.HOSTNAME
+        confirm_accept_address = Cookie.make_confirm_address(original_recipient,
+                                                             timestamp,
+                                                             pid,
+                                                             'accept')
         pendingdir = Defaults.DATADIR + 'pending'
         pending_message = timestamp + '.' + pid + '.msg'
         # Create ~/.tmda/ and friends if necessary.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic