[Mimedefang] Narrowed down but still Dropping without extracting..
Aaron Enders
aenders24 at comcast.net
Tue Jun 7 08:23:37 EDT 2011
Issue: Mimedefang is dropping ms-tnef (winmail.dat) without scanning and
extracting the attachments. I have verified and am working with my
client that there is an attachment.
mail.info : Jun 6 15:38:11 smtp1 mimedefang.pl[21064]: ytnef didn't
find any attachments, but we are dropping the winmail.dat mime part anyway
Below is the code snippets where I believe the error lies. Can anyone
help point me to why it will not extract and only drops it? Code Wrong
or needs updated?
# if this is a application/ms-tnef message then extract and delete it
if (lc($type) eq "application/ms-tnef") {
@tnef_files = extract_tnef( $entity );
my $tnef_file_qty = @tnef_files;
if( $tnef_file_qty > 0 ){
md_syslog( 'info', "ytnef extracted some files so we are
now dropping the winmail.dat mime part" );
} else {
md_syslog( 'info', "ytnef didn't find any attachments, but
we are dropping the winmail.dat mime part anyway" );
}
return action_drop();
}
# add the tnef files to the message
foreach my $fname ( @tnef_files ) {
local($/) = undef;
open(FILE, "$fname");
my $file = <FILE>;
close(FILE);
$file =~ s:^.*[\\/]::;
action_add_part($entity, "application/octet-stream", "base64",
$file, $fname, "attachment");
md_syslog('info', "Added file $fname to message because it was
extracted from the winmail.dat");
}
@tnef_files = ();
# sub routine..
sub extract_tnef( $ ) {
my ( $entity ) = @_;
my ( $body ) = $entity->bodyhandle;
my @tnef_files = ();
if( ! defined( $body ) ){
return @tnef_files;
}
# Get filename
my ( $path ) = $body->path;
if( ! defined( $path ) ){
return @tnef_files;
}
@new_files = `/usr/bin/ytnef -f Work $path`;
foreach my $file ( @new_files ){
chomp( $file );
push( @tnef_files, $file );
md_syslog( 'info', "Found file $file in winmail.dat attachment" );
}
return @tnef_files;
}
More information about the MIMEDefang
mailing list