[Mimedefang] Debugging slaves that die

Steffen Kaiser skmimedefang at smail.inf.fh-bonn-rhein-sieg.de
Thu Nov 24 02:58:37 EST 2005


On Thu, 24 Nov 2005, Roland Pope wrote:

Actually, I do like debugging my scripts and see what's going on in there.

I used to do the following when I tested my filter's _begin/../end stage 
heavily:

I've added this code into the filter:

                 action_quarantine_entire_message("Message quarantined 
because for TESTING purpose");
                 get_quarantine_dir();
                 foreach my $fnam (glob('*')) {
                         if(-f $fnam && !-e "$QuarantineSubdir/$fnam") {
                                 if(open(OUT, ">$QuarantineSubdir/$fnam")) 
{
                                         if(open(IN, $fnam)) {
                                                 while(<IN>) {
                                                         print OUT;
                                                 }
                                                 close IN;
                                         }
                                         close OUT;
                                 }
                         }
                 }

The "foreach" loop causes that all files are available in the quarantined 
directory, incl COMMANDS, which is essential.

Then you can check the filter doing this:

$ cd $QuarantineSubdir
$ rm -r RESULT Work
$ perl -d mimedefang.pl -f filter $(pwd)
> c do_scan
> c filter_begin
... do the debugging
> q
$ test -f RESULTS && cat RESULTS || echo no results

However, if you do not check the logic of the filter itself, but some 
general problem, you must be aware that you debug as the defang-user (the 
demon runs as), that you cannot emulate the timings and that a slave may 
have leftover values of a previous run.

Bye,

-- 
Steffen Kaiser



More information about the MIMEDefang mailing list