[Mimedefang] Operating on attachments - choosing which attachment to operate on

Steffen Kaiser skmimedefang at smail.inf.fh-bonn-rhein-sieg.de
Fri Apr 25 02:14:33 EDT 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 24 Apr 2014, Michael Lazar wrote:

> I am having difficulty preserving the original attachment.
>
> sub filter{
> if (lc($type) eq 'application/zip' ) {
>
> action_add_entity($entity,-1);
>
> my $cmd = 'zipc -silent -extract -directories FILTERINPUT extractf
> -keypass=xxxxxxxx; zipc -silent -add FILTEROUTPUT ./extractf/*.*';
>
>    action_external_filter($entity, $cmd);
>
> my $name=Œclear.zip';
>     my $fname=Œclear.zip';
>     my $type='application/zip';
>     action_defang($entity, $name, $fname, $type);
>
>     #undocumented hack to preserve body
>     pop(@Warnings);
>
> }

Hmm, I would actually try this way:

1) in sub filter() detect encrypted files and spool them into 
$CWD/my_spool. Make sure, you use a different name per attachment of the 
message

2) in filter_end(), if there are spooled files:
my $e = action_add_part($entity, "text/plain", "-suggest",
   "Unencrypted attachments", "Unencrypted_attachments_".time());
$e->make_multipart("mixed");
foreach my $file (@files) {
 	# decrypt $file
 	my $new = MIME::Entity->build(...)
 	$e->add_part($new);
}

David's advice will save you from the additional HD space needed in step 
1).

- -- 
Steffen Kaiser
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQEVAwUBU1n9SlGgR0+MU/4GAQIMDQf8D8J8qVDcNi4KZN03pRZJNqLLJGQjC17s
SmWCBx3lJmDVvPZFtHCqGrL/Rsl2aOAESKduXvh0d/EUSMtQ7qBefMtzzRuItJE+
4wh3KKwhpH4Zk0Oo5WEDjYPuS+xYFTEmcIYmWGIiFOgW8aJYVpsEiONa+eeyCw0u
crAdtg/uC+Vet8bNSg9v0iFTmsBVtcmT4ypD+13jSoHI9MQu2j3SvNRDr4ri46Xe
NaQDXUTV/AtFAtgubvnLemRm+FSq+ORTtYhlWLYvbUANU6zUC8nCzKLx03MvqUHp
K+MNcbLsKVqRaVNq+AosIBLv1YpYsZHqPxxROVv8hpun+kiTbe/O1A==
=V/4i
-----END PGP SIGNATURE-----


More information about the MIMEDefang mailing list