Hi Everyone,

I finally got around to setting up tmda-ofmipd and upgrading to 1.1.8 and when testing to ensure it would work with non-tmda users I ran into some problems: When turning on the pure-proxy mode ('-P'), the tofmipd user needs to have execute permission on the tmda user's .tmda directory, or the check for the ~/.tmda/config file will fail and the tmda user's outgoing mail will be routed thru sendmail. I decided in the end that that wasn't to onerous a requirement, so the patch doesn't address that, but we might want to document it, or someone else might want to look at creating patch to do the check as the target user.

I also noticed that the mail that went thru sendmail didn't have the envelope sender set properly, so I added " '-f', mailfrom," to the args when running sendmail in pure-proxy mode.

I added the patch to catch the exceptions around self.__server.process_message(), and noticed that the server would then emit my error message (451), then a '250 ok'. I think the error handling for 'Outgoing mail quota exceeded' was wrong as well, so I cleaned that up.

While I was at it, I added the '-l' (ell) option that someone else talked about for intermediate logging between nothing (the default) and -d. Basically, it logs everything that -d does, except the data coming from the client (so I don't have to worry about logging whole messages or passwords).

I hope this is useful to someone.

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!

--- 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,17 @@ 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)
+               except:
+                   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')
_________________________________________________
tmda-workers mailing list ([email protected])
http://tmda.net/lists/listinfo/tmda-workers

Reply via email to