SF.net SVN: tmda: [2075] trunk/tmda

[email protected] Thu, 05 Oct 2006 13:56:51 -0700
Newsgroups gmane.mail.spam.tmda.cvs
Message-ID <[email protected]>
Revision: 2075
          http://svn.sourceforge.net/tmda/?rev=2075&view=rev
Author:   jasonrm
Date:     2006-10-05 13:56:50 -0700 (Thu, 05 Oct 2006)

Log Message:
-----------
A new command-line option, '-e/--environ' which you can use to add a VAR=value 
pair to the environment.  One example use of this is to allow TMDA to be setup 
as a Postfix transport. Contributed by Bernard Johnson.

Modified Paths:
--------------
    trunk/tmda/NEWS
    trunk/tmda/bin/ChangeLog
    trunk/tmda/bin/tmda-rfilter

Modified: trunk/tmda/NEWS
===================================================================
--- trunk/tmda/NEWS	2006-10-05 20:06:10 UTC (rev 2074)
+++ trunk/tmda/NEWS	2006-10-05 20:56:50 UTC (rev 2075)
@@ -16,6 +16,11 @@
   For more infomation on how to enable and use this feature, please
   see http://wiki.tmda.net/TmdaPendingAsMaildir
 
+* tmda-filter has a new command-line option, '-e/--environ' which you
+  can use to add a VAR=value pair to the environment.  One example use
+  of this is to allow TMDA to be setup as a Postfix transport.
+  Contributed by Bernard Johnson.
+
 ======================================================================
 
 TMDA 1.1.6 "Glen Albyn" --

Modified: trunk/tmda/bin/ChangeLog
===================================================================
--- trunk/tmda/bin/ChangeLog	2006-10-05 20:06:10 UTC (rev 2074)
+++ trunk/tmda/bin/ChangeLog	2006-10-05 20:56:50 UTC (rev 2075)
@@ -1,3 +1,8 @@
+2006-10-05  Jason R. Mastaler  <[email protected]>
+
+	* tmda-rfilter: Add -e/--environ option for setting of environment
+	variables from the command line.	
+
 2006-09-27  Jason R. Mastaler  <[email protected]>
 
 	* tmda-rfilter: Modified to use new TMDA.Queue interface.

Modified: trunk/tmda/bin/tmda-rfilter
===================================================================
--- trunk/tmda/bin/tmda-rfilter	2006-10-05 20:06:10 UTC (rev 2074)
+++ trunk/tmda/bin/tmda-rfilter	2006-10-05 20:56:50 UTC (rev 2075)
@@ -40,6 +40,10 @@
 	--discard
 	   Discard message if address is invalid instead of bouncing it.
 
+        -e
+        --environ <VAR=value>
+           Add the following var/value pair to the environment.
+
         -p
         --print
            Print the message to stdout.  This option is useful when TMDA is run
@@ -135,15 +139,16 @@
 
 try:
     opts, args = getopt.getopt(sys.argv[1:],
-                            'c:dpt:I:M:S:Vh', ['config-file=',
-                                               'discard',
-                                               'print',
-                                               'template-dir=',
-                                               'filter-incoming-file=',
-                                               'filter-match=',
-                                               'vhome-script=',
-                                               'version',
-                                               'help'])
+                            'c:de:pt:I:M:S:Vh', ['config-file=',
+						 'discard',
+						 'environ=',
+						 'print',
+						 'template-dir=',
+						 'filter-incoming-file=',
+						 'filter-match=',
+						 'vhome-script=',
+						 'version',
+						 'help'])
 except getopt.error, msg:
     usage(1, msg)
 
@@ -168,6 +173,12 @@
         act_as_filter = 1
     elif opt in ('-c', '--config-file'):
         os.environ['TMDARC'] = arg
+    elif opt in ('-e', '--environ'):
+        try:
+            key, value = arg.split('=',1)
+	    os.environ[key] = value
+        except KeyError:
+            usage(1, 'bad environment key-value pair %s' % arg)
     elif opt in ('-S', '--vhome-script'):
         if os.environ.has_key('EXT') and os.environ.has_key('HOST'):
             setvuserhomedir(arg)


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.