CVS: tmda/bin tmda-inject,1.96,1.97
"Jason R. Mastaler" <[email protected]> Thu, 19 Feb 2004 10:42:05 -0800
| Newsgroups | gmane.mail.spam.tmda.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/tmda/tmda/bin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23297/bin
Modified Files:
tmda-inject
Log Message:
New feature from David Bremner. Add 'shell=' and 'python=' tag
actions to the outgoing filter.
This allows you to add dynamic/shell escaped headers from the outgoing
filter file (think per-recipient, or with '*' at the end for all
recipients).
This differs from the ADDED_HEADERS_CLIENT feature in that the headers
can be added selectively per-recipient or to all recipients with '*'
at the end, rather than only to all recipients. Also, you have access
to the message recipient address in the $TMDA_RECIPIENT variable. An
example:
# Add X-Hashcash headers
to * tag
x-hashcash shell="hashcash -q -m -b20 ${TMDA_RECIPIENT}"
The python= feature is incomplete at this time. Also, I refrain from
documenting these features until they are complete.
Index: tmda-inject
===================================================================
RCS file: /cvsroot/tmda/tmda/bin/tmda-inject,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -r1.96 -r1.97
--- tmda-inject 12 Feb 2004 00:39:18 -0000 1.96
+++ tmda-inject 19 Feb 2004 18:42:01 -0000 1.97
@@ -201,6 +201,16 @@
elif cookie_type in ('kw','keyword') and cookie_option:
# Send a message with a tagged (keyword) address.
field = Cookie.make_keyword_address(from_address, cookie_option)
+ elif cookie_type == 'python':
+ # this is currently broken, and needs more work
+ field = str(eval(cookie_option))
+ elif cookie_type == 'shell':
+ import commands
+ shell_stat, shell_out = commands.getstatusoutput(cookie_option)
+ if shell_stat == 0:
+ field = shell_out
+ else:
+ raise IOError, shell_out
elif not cookie_type:
# cookie_type == None means field is a text string
field = cookie_option
@@ -280,7 +290,7 @@
for header in custom_headers:
(cookie_type, cookie_option) = actions[header]
field = make_field(cookie_type, cookie_option, from_address, to_address)
- if cookie_type:
+ if not (cookie_type in ('python','shell', None)):
field = message_format(field, full_name,
Defaults.MESSAGE_TAG_HEADER_STYLE)
nice_header = string.capwords(header.replace('-', ' ')).replace(' ', '-')