[Mimedefang] blocked file types in text file
Matthew.van.Eerde at hbinc.com
Matthew.van.Eerde at hbinc.com
Mon Sep 19 12:48:35 EDT 2005
Mark Coetser wrote:
> If I wanted to create a text file with all the blocked filetypes, how
> would I include that text file in my mimedefang-filter ?
>
You probably want to put the file-slurping code OUTSIDE of filter_bad_filename. That way the mimedefang slave reads the file once, when it is created.
This has the advantage that you don't have to read the file every time you call filter_bad_filename. This can be faster. It has the disadvantage that every time you edit the file, currently-running slaves won't be aware of the change. If you get in the habit of reloading MIMEDefang every time you edit the file, that can mitigate the problem.
OUTSIDE OF ANY FUNCTION (untested:)
my $bad_exts_file = '/etc/mail/mimedefang-badexts';
open(BADEXTS, $bad_exts_file) or
die("Could not open $bad_exts_file\n$!");
my @raw_lines = <BADEXTS>;
close(BADEXTS);
my @good_lines = ();
for my $line (@raw_lines)
{
chomp($line);
$line =~ s/#.*//; # trim comments
$line =~ s/\s+$//; # trim trailing whitespace
next if $line eq ""; # skip blank lines
push $line, @good_lines;
}
my $bad_exts_from_file = join("|", @good_lines);
>
> sub filter_bad_filename ($) {
> my($entity) = @_;
> my($bad_exts, $re);
>
> # Bad extensions
> $bad_exts = '/etc/mail/mimedefang-badexts';
$bad_exts = $bad_exts_from_file;
--
Matthew.van.Eerde (at) hbinc.com 805.964.4554 x902
Hispanic Business Inc./HireDiversity.com Software Engineer
More information about the MIMEDefang
mailing list