Scan Messages and CustomFunction

Jerry Benton jerry.benton at mailborder.com
Wed Sep 30 19:52:28 UTC 2015


anyone have any feedback on this? I haven't had time to take a look at it,

-
Jerry Benton
www.mailborder.com
Sent from my iPhone

> On Sep 24, 2015, at 04:42, Alvaro Marín <alvaro at hostalia.com> wrote:
> 
> Hi again,
> 
> debugging the code, I've found those 2 calls to "Scan Messages" function:
> 
> [+] Message.pm, new (constructor, called by Postfix.pm's CreateBatch
> function):
> 
>  # Decide if we want to scan this message at all
>  $this->{scanmail} = MailScanner::Config::Value('scanmail', $this);
>  if ($this->{scanmail} =~ /[12]/) {
>    $this->{scanmail} = 1;
>  } else {
>    # Make sure it is set to something, and not left as undef.
>    $this->{scanmail} = 0;
>  }
>  if ($this->{scanmail} !~ /1/) {
>    $this->{scanvirusonly} = 1;
>  } else {
>    $this->{scanvirusonly} = 0;
>  }
> 
> [+] Postfix.pm, in CreateBatch function:
> 
>        if (MailScanner::Config::Value("scanmail", $newmessage) =~ /[12]/ ||
>            MailScanner::Config::Value("virusscan", $newmessage) =~ /1/ ||
>            MailScanner::Config::Value("dangerscan", $newmessage) =~ /1/) {
>          $newmessage->NeedsScanning(1);
> 
> 
> So in that Postfix.pm's code, insted of read the value of $newmessage's
> variable "scanmail", that was created in Message.pm code that I've
> pasted before, it calls again to MailScanner::Config::Value function
> that searchs again for that value (if is a ruleset it will look for the
> rule in the rules file or if it's a function, like in my configuration,
> it will execute it one more time).
> Changing that code by:
> 
>    if ($newmessage->{"scanmail"} =~ /[12]/ ||
>      $newmessage->{"virusscan"} =~ /1/ ||
>      $newmessage->{"dangerscan"} =~ /1/) {
>    $newmessage->NeedsScanning(1);
> 
> it reads the value from the variable filled by Message.pm, and doesn't
> call again to the function.
> 
> Can you confirm if this is correct?
> Thanks.
> 
> Regards,
> 
>> El 23/09/15 a las 17:52, Alvaro Marín escribió:
>> Hello,
>> 
>> I'm writing a CustomFunction to check the "Scan Messages" value in a
>> database:
>> 
>> Scan Messages = &ScanMsgs
>> 
>> I've done the same with :
>> 
>> Spam Checks (for avoid mails being scanned, that is, whitelisting)
>> Is Definitely Spam  (for blacklisting)
>> 
>> and these 2 functions run fine.
>> 
>> The problem with "Scan Messages" is that the function is executed two
>> times for each message:
>> 
>> Sep 23 17:15:05 MailScanner[22554]: 4694D2180A7.AC573: ScanMsgs checking.
>> Sep 23 17:15:05 MailScanner[22554]: 4694D2180A7.AC573: ScanMsgs checking.
>> 
>> and I see in MySQL logs that the queries are done 2 times.
>> Simplifying the code to:
>> 
>> ========
>> package MailScanner::CustomConfig;
>> sub InitScanMsgs {
>>   MailScanner::Log::InfoLog("Starting ScanMsgs...");
>> }
>> sub ScanMsgs {
>>   my($message) = @_;
>>   my $msgid=$message->{id};
>>   MailScanner::Log::WarnLog("$msgid: ScanMsgs checking.");
>>   return 0;
>> }
>> sub EndScanMsgs {
>>   MailScanner::Log::InfoLog("Ending ScanMsgs...");
>>   exit;
>> }
>> 1;
>> ========
>> 
>> the problem still occurs.
>> Any idea? Is strange because, as I've said, white and blacklisting work
>> fine with similar code.
>> 
>> Thank you.
>> Regards,
> 
> 
> -- 
> Alvaro Marín Illera
> Hostalia Internet
> www.hostalia.com
> 
> 
> 
> -- 
> MailScanner mailing list
> mailscanner at lists.mailscanner.info
> http://lists.mailscanner.info/listinfo/mailscanner
> 


More information about the MailScanner mailing list