Re: Patch for tmda-ofmipd...
"Robert P. Thille" <[email protected]> Mon, 13 Nov 2006 16:36:13 -0800
| Newsgroups | gmane.mail.spam.tmda.devel |
|---|---|
| Message-ID | <[email protected]> |
Jason R. Mastaler wrote: > Stephen Warren <[email protected]> writes: > >> I had one question about the exception handler code you added as >> described above. Specifically, do you have any way of easily >> reproducing the exceptions that your code catches. A long time ago, >> I wrote the original code for that exception handler that you >> included, but I can't work out how to trigger the problem I was >> trying to solve originally - any information would be greatly >> appreciated! You can generate an exception just by doing this in your outgoing filter: to [email protected] as [email protected] Note that it's difficult to see what I did wrong there... :-) > BTW, the poster of this patch is also a Thunderbird user. I think I'm > detecting a theme here. <wink> Actually, primarily I use Mail.app (on my home machine), but for work I use thunderbird... I think it's been fixed to do the right thing with a dropped connection, but I figured that returning a somewhat intelligible error was better than just dropping the connection. Unfortunately, I dropped the ball on my exception handling, and that raised a different exception. I've got an updated patch, which I'll append here. I should probably break it into 3 separate patches, since it does three things: adds the -l option, for 'some' debugging/logging output [only difference from -d is that it doesn't log the client data sent] Handles exceptions from __server.process_message() [ I really wanted to improve this to get the last bit of output from tmda-inject, which would show that the filter was broken, or whatever, but I'm a rank-newbie Python programmer] fix the only thing I consider a 'real' bug, which is not-invoking sendmail_program with '-f <mailfrom>' when in 'pure-proxy' mode. Robert -- Robert Thille 7575 Meadowlark Dr.; Sebastopol, CA 95472 Home: 707.824.9753 Office/VOIP: 707.780.1560 Cell: 707.217.7544 [email protected] YIM:rthille http://www.rangat.org/rthille Cyclist, Mountain Biker, Freediver, Kayaker, Rock Climber, Hiker, Geek May your spirit dive deep the blue, where the fish are many and large!
TMDA.patch
(text/plain, 3.6 KB)
$NetBSD$
--- bin/tmda-ofmipd.orig 2006-10-25 16:40:57.000000000 +0000
+++ bin/tmda-ofmipd
@@ -95,6 +95,10 @@ gengroup.add_option("-d", "--debug",
action="store_true", default=False, dest="debug",
help="Turn on debugging prints.")
+gengroup.add_option("-l", "--log",
+ action="store_true", default=False, dest="log",
+ help="Turn on logging prints.")
+
gengroup.add_option("-b", "--background",
action="store_false", dest="foreground",
help="Detach and run in the background (default).")
@@ -245,7 +249,7 @@ if opts.full_version:
sys.exit()
if opts.vhomescript and opts.configdir:
parser.error("options '--vhome-script' and '--configdir' are incompatible!")
-if opts.debug:
+if opts.debug or opts.log:
DEBUGSTREAM = sys.stderr
else:
DEBUGSTREAM = Devnull()
@@ -743,7 +747,8 @@ class SMTPChannel(asynchat.async_chat):
# Implementation of base class abstract method
def found_terminator(self):
line = EMPTYSTRING.join(self.__line)
- print >> DEBUGSTREAM, 'Data:', repr(line)
+ if opts.debug:
+ print >> DEBUGSTREAM, 'Data:', repr(line)
self.__line = []
if self.__state == self.COMMAND:
if not line:
@@ -776,13 +781,21 @@ class SMTPChannel(asynchat.async_chat):
if not opts.throttlescript or not os.system("%s %s" % (opts.throttlescript,
self.__auth_username)):
- status = self.__server.process_message(self.__peer,
- self.__mailfrom,
- self.__rcpttos,
- self.__data,
- self.__auth_username)
+ try:
+ status = self.__server.process_message(self.__peer,
+ self.__mailfrom,
+ self.__rcpttos,
+ self.__data,
+ self.__auth_username)
+ print >> DEBUGSTREAM, 'Message Complete.'
+ except IOError, err:
+ status = '451 Error injecting message'
+ print >> DEBUGSTREAM, 'Error:', err
+ except Exception, ex:
+ status = '451 Internal exception in tmda-ofmipd'
+ print >> DEBUGSTREAM, 'Error:', ex
else:
- status = self.push('450 Outgoing mail quota exceeded')
+ status = '450 Outgoing mail quota exceeded'
self.__rcpttos = []
self.__mailfrom = None
@@ -1112,7 +1120,7 @@ class VDomainProxy(PureProxy):
(vhomedir, '.tmda', 'config')):
sendmail_program = os.environ.get('TMDA_SENDMAIL_PROGRAM') \
or '/usr/sbin/sendmail'
- inject_cmd = [sendmail_program, '-i', '--'] + rcpttos
+ inject_cmd = [sendmail_program, '-f', mailfrom, '-i', '--'] + rcpttos
try:
Util.pipecmd(inject_cmd, data)
except Exception, err:
@@ -1139,7 +1147,7 @@ class TMDAProxy(PureProxy):
if opts.pure_proxy and not os.path.exists(tmda_configfile):
sendmail_program = os.environ.get('TMDA_SENDMAIL_PROGRAM') \
or '/usr/sbin/sendmail'
- inject_cmd = [sendmail_program, '-i', '--'] + rcpttos
+ inject_cmd = [sendmail_program, '-f', mailfrom, '-i', '--'] + rcpttos
else:
execdir = os.path.dirname(os.path.abspath(program))
inject_path = os.path.join(execdir, 'tmda-inject')