[Mimedefang] Help with filter - modified

Paul Whittney pwhittney at net.bacconsulting.com
Fri Apr 2 06:40:39 EST 2004


Mark,

I've had a quick look, and may not have found everything, but to be honest,
I would recommend taking the suggested-minimum-filter-for-windows-clients filter
and editing it again, as missing brackets isn't the only issue.

Let me see if I can explain... I've mangled this a bit. Hope it makes some sort
of sense.

> 
> #***********************************************************************
> # To enable syslogging of virus and spam activity, add the following
> # to the filter:

> md_graphdefang_log_enable();

Im assuming that some of this is wordwrapping issues in the client..

> # You may optionally provide a syslogging facility by passing an
> # argument such as:  md_graphdefang_log_enable('local4');  If you do
> this, be

As the above line would fail otherwise...

> # sure to setup the new syslog facility (probably in /etc/syslog.conf).
> # An optional second argument causes a line of output to be produced
> # for each recipient (if it is 1), or only a single summary line
> # for all recipients (if it is 0.)  The default is 1.
> # Comment this line out to disable logging.
> #***********************************************************************
> md_graphdefang_log_enable('mail', 1);

[snip]
> # This procedure returns true for entities with bad filenames.
> sub filter_bad_filename ($) {
>     my($entity) = @_;
>     my($bad_exts, $re);
> 
> # Bad extensions
> 
>     $bad_exts =
> '(ade|adp|app|asd|asf|asx|bas|bat|chm|cmd|com|cpl|crt|dll|exe|fxp|hlp|ht
> a|hto|inf|ini|ins|isp|jar|js|jse|lib|lnk|mdb|mde|msc|msi|msp|mst|pcd|prg
> |reg|scr|sct|sh|shb|shs|sys|url|vb|vbe|vbg|vbs|vcs|vxd|wmd|wms|wmz|wsc|w
> sf|wsh|zls|\{[^\}]+\})';

Missing end of sub filter_bad_filename, and missing close brace.
filter_bad_filename returns a value of true or false (I think... It's
early, and I haven't had coffee yet), but needs the test to be run as well.
Have a look at the original code for pointers.

> sub filter_begin () {

Is there any more of filter_begin? if not, close brace missing here

>     
> #***********************************************************************
> # %PROCEDURE: filter
> # %ARGUMENTS:

Is this the start of filter ($$$$) { ? If so, define the subroutine.

>    if (filter_bad_filename($entity)) {
>        md_graphdefang_log('bad_filename', $fname, $type);
> #	action_notify_administrator("A MULTIPART attachment of type
> $type, named $fname was dropped.\n");

I assume the above line was wordwrapped.. 

> 	return action_bounce("We are not accepting emails with
> attachments of this type");
>    }
>  
>    return action_accept();
> }

Correct close brace if filter was defined.. (actually, it might think
this is the end of filter_begin, and I'm not sure that was what you want)

-Paul Whittney



More information about the MIMEDefang mailing list