Re: Keyword based filtering

Corey Halpin <[email protected]>
Newsgroups gmane.mail.spam.tmda.user
Message-ID <[email protected]>
On 2007-04-07, Nils Vogels wrote:
> I'm trying to get TMDA to behave differently on a per-keyword basis.
> 
> Specifically, I would like TMDA to accept gpg-signed messages to the
> "signed" keyword, and if not send out a specific template. How would I
> go about that in the config file?
> 
> Offcourse, accepting the "signed" part is easy:
> 
> pipe "/usr/local/bin/gpg -q" accept
 
  I don't think it's quite so easy as that.
  In particular, the above solution will only work for messages that have an 
'inline' signature.  The newer-style (and, at least according to the Mutt 
people, preferred) messages with a detached signature will be missed by this 
one.
  I've attached a perl script that I use for this purpose.

> But, how do I make this dependant on a certain keyword address, and
> how do I perform multiple actions on a single address?
 
  I'm not sure if there's a way to do this directly from within TMDA.  I'm 
sure someone more knowledgeable will jump in here if there is.
  If you're calling TMDA from procmail, then you could do something like:

:0
* to: REGEXP_FOR_YOUR_KEYWORD_ADDRESS
| tmda-filter -c CONFIG_FOR_KEYWORD

:0
| tmda-filter

  That would use a separate config file for general messages vs keyworded 
ones, which would let you specify different templates to send.
  
crh
check_gpg (text/plain, 609 B)
#!/usr/bin/perl
# check_gpg - examine a message for a valid PGP signature
# by Corey Halpin <[email protected]>
# Expects the message on stdin.

use MIME::Parser;
use Mail::GnuPG;

# chdir to a temp
mkdir "/tmp/$$",0700;
chdir "/tmp/$$";

my $parser = new MIME::Parser;
$entity = $parser->parse(\*STDIN) or die "parse failed\n";
my $mg = new Mail::GnuPG();

$rc=1;
if( $mg->is_signed($entity) ){
  my ($code, $keyid, $email) = $mg->verify($entity);
  $rc = $code;
} elsif( $mg->is_encrypted($entity) ){
  $rc = 0;  # encrypted messages are assumed good.
}

# Delete the tempdir
`rm -rf /tmp/$$`;

exit $rc;
signature.asc (application/pgp-signature, 186 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (Darwin)

iD8DBQFGF6mbWBjzOA9cliERAq6PAJ0Q8FZ8w9uZ53ByXbNbu4SKmcwx6gCffoim
i5VZbuZCcVvP+/vC6AlBU8E=
=a9Z8
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.