https://bugzilla.novell.com/show_bug.cgi?id=414666
User gerberb@zenez.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=414666#c10
--- Comment #10 from Boyd Gerber 2008-08-07 17:17:46 MDT ---
pysrs and the following for our purposes, we could configure postfix to use a
proxy as a mail relay
(say at address 127.0.0.2). It reads lines, and echoes lines to the real
mail relay (and reads lines from the real mail relay and echoes to
postfix). A useful python smtp proxy has hooks to call a function when
postfix sends HELO, MAIL FROM, RCPT TO, and maybe even data (except an
SMTP proxy has to keep processing to a minimum to avoid triggering
incorrect timeouts). For our purposes, just keeping track of when SMTP is
in DATA state and triggering on MAIL FROM is sufficient.
There is even a proxy class already provided in the smtpd module.
Just derive from smtpd.PureProxy and override process_message().
Since SMTPServer collects the entire HELO+MFROM+RCPTs+DATA before
calling process_message, I'm not sure about timing for large messages.
But it may do the trick for you.
Untested code:
import asyncore
import smtpd
import SRS
from ConfigParser import ConfigParser
cp = ConfigParser({
'secret': 'shhhh!',
'maxage': '8',
'hashlength': '8',
'separator': '=',
'socket': '/var/run/milter/pysrs'
})
class SRSProxy(smtpd.PureProxy):
def __init__(self,listen,relay):
self.srs = SRS.new(
secret=cp.get('srs','secret'),
maxage=cp.getint('srs','maxage'),
hashlength=cp.getint('srs','hashlength'),
separator=cp.get('srs','separator'),
alwaysrewrite=True # skip calling us for local domains
)
self.fwdomain = cp.get('srs','fwdomain',None)
smtpd.PureProxy.__init__(self,listen,relay)
def process_message(self,helo,mfrom,rcpts,data):
# ... lots of special cases for no-srs, signonly, etc excluded
new_address = self.srs.forward(mfrom,self.fwdomain)
smtpd.PureProxy.process_message(self,helo,new_address,rcpts,data)
# prolly want to log stuff
cp.read(["/etc/mail/pysrs.cfg"])
proxy = SRSProxy('127.0.0.2','relay.fwdomain.com')
asyncore.loop()
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.