Custom Function for Virus Scanners Variable {Scanned by HJMS}

Furnish, Trever G TGFurnish at HERFF-JONES.COM
Tue Oct 21 15:08:43 IST 2003


> When I save this and reboot, I receive the "Starting VirusScanners"

"reboot"?!  Why would you reboot?  Hopefully you just mean "restart
MailScanner"...

> and "Doing VirusScanners" log entries twice

I think you ought to see it once per MS child, since each one is going to
run these functions.

> (I don't when
> using this method
> with other custom functions).

That surprises me.

> It never writes the out.txt
> file ...

Suggest changing your file opening code from:
>   open(FILE,">>/home/out.txt");
>   print FILE "some junk here\n";
>   close (FILE);

...to:
if (open(FILE, ">>/home/out.txt")) {
   print FILE, "some junk here\n";
   close FILE;
} else {
   MailScanner::Log::InfoLog("Open failed: $!");
}

But keep in mind that your approach isn't multi-process safe - that is, you
will have multiple processes writing to the same file at the same time, so
don't be surprised to find corruption in that file, especially as email
traffic increases.

> nor does it
> pick up mail from the mailqueie.in?  MailScanner starts without any
> errors.  If I take out the line "my @todomain =
> @{$message->todomain}};" it
> seems to run, but It still runs the code twice at startup.

When you enabled debugging of mailscanner, did you run it from the init
script or directly from a command line?  Sometimes you'll see more when
running it via the command-line, though I'm not quite sure why.

You say it "runs the code twice at startup" -- how many mailscanner child
processes are you starting?

--
Trever

> -----Original Message-----
> From: Kyle Harris [mailto:lists at TRCINTL.COM]
> Sent: Monday, October 20, 2003 6:26 PM
> To: MAILSCANNER at JISCMAIL.AC.UK
> Subject: Re: Custom Function for Virus Scanners Variable {Scanned by
> HJMS}
>
>
> Here is some more info regarding my own previous post.
> Hopefully someone
> will be able to help out.  Anyway, if I set Virus Scanners =
> &VirusScanners
> in the config file and then define the following custom
> function in the
> CustomConfig.pm file (this is my entire file for
> troubleshooting purposes
> only):
>
> package MailScanner::CustomConfig;
> use strict 'vars';
> use strict 'refs';
> no  strict 'subs'; # Allow bare words for parameter %'s
> use vars qw($VERSION);
>
> sub InitVirusScanners {
>   MailScanner::Log::InfoLog("Starting VirusScanners");
> }
> sub EndVirusScanners {
>   MailScanner::Log::InfoLog("Stopping VirusScanners");
> }
> sub VirusScanners {
>   MailScanner::Log::InfoLog("Doing VirusScanners");
>   my ($message) = @_;
>   my @todomain = @{$message->{todomain}};
>   open(FILE,">>/home/out.txt");
>   print FILE "some junk here\n";
>   close (FILE);
>   return "clamav";
> }
> 1;
>
> When I save this and reboot, I receive the "Starting VirusScanners"
> and "Doing VirusScanners" log entries twice (I don't when
> using this method
> with other custom functions).  It never writes the out.txt
> file nor does it
> pick up mail from the mailqueie.in?  MailScanner starts without any
> errors.  If I take out the line "my @todomain =
> @{$message->todomain}};" it
> seems to run, but It still runs the code twice at startup.
>
> Julian, any ideas?
>



More information about the MailScanner mailing list