Hi!

Here's a repost of a suggestion for a new scanning sub I posted some
time ago. To use this code, you must define $fsecure45_binary and add
fsecure45_scanner to scanner array.

I'm sorry about the line wrapping, don't have the time to fix it now.


- Jyri

========================================================================

    } elsif ($scanner eq "fsecure45") {
      open(FS,"$fsecure45_binary --version|")||die "failed to call $fsecure45_binary 
--version - $!";
      while (<FS>) {
        chomp;
        if (/^F-Secure Anti-Virus for Linux version ([0-9\.]+) build ([0-9]+)/) {
          $SCANINFO .="fsecure45: version $1 build $2 / ";
        } elsif (/F-PROT database version ([0-9\.]+-[0-9\.]+-[0-9\.]+)/) {
          $SCANINFO .= "f-prot database $1 / ";
        } elsif (/AVP FPI Engine database version ([0-9\.]+-[0-9\.]+-[0-9\.]+)/) {
          $SCANINFO .= "avp fpi database $1. ";
        }
      }
      close(FS);

========================================================================

sub fsecure45_scanner {
  #F-Secure 4.5 scanner
    &debug("fsecure45: starting scan of directory \"$scandir/$file_id\"...");
    my ($fsecure45_verbose)="--list" if ($DEBUG);
    my ($start_fsecure45_time)=[gettimeofday];
    my ($DD,$fsecure45_status,$stop_fsecure45_time,$fsecure45_time);
    &debug("run $fsecure45_binary  $fsecure45_verbose --archive --auto --dumb  
$scandir/$file_id 2>&1");
    $DD=`$fsecure45_binary  $fsecure45_verbose --archive --auto --dumb  
$scandir/$file_id  2>&1`;
    $fsecure45_status=($? >> 8);
    &debug("--output of fsecure45 was:\n$DD--");

    FSECURE45: {

        # If FSAV gives return codes 1, 7 or 130, then something is wrong.
        # Otherwise we can assume scanning went ok. (Code 9 means
        # scanning of at least one file failed. This can happen for
        # example when scanning a corrupted or encrypted ZIP file.)
    
        if ( $fsecure45_status == 1 or $fsecure45_status == 7 or $fsecure45_status == 
130 ) {
            # 1 = Abnormal termination; unrecoverable error. (Usually a missing or 
corrupted file.)
            # 7 = Out of memory.
            # 130 = Program was terminated by pressing Ctrl-C, or by a sigterm or 
suspend event.
            &tempfail("corrupt or unknown F-Secure 4.5 scanner/resource problems - 
exit status
$fsecure45_status");
            last FSECURE45;
        }

        if ($DD =~ /Infected:(.*)\n/) {
            $quarantine_description=$1;
            &debug("There be a virus! ($quarantine_description)");
            ($quarantine_event=$quarantine_description)=~s/\s/_/g;
            $quarantine_event="FSEC45:".substr($quarantine_event,0,$QE_LEN);
            $description .= "\n---fsecure45 results ---\n$DD";
            last FSECURE45;
        }

        if ($DD =~ /Suspected:(.*)\n/) {
            $quarantine_description=$1;
            &debug("There be a virus! ($quarantine_description)");
            ($quarantine_event=$quarantine_description)=~s/\s/_/g;
            $quarantine_event="FSEC45:".substr($quarantine_event,0,$QE_LEN);
            $description .= "\n---fsecure45 results ---\n$DD";
            last FSECURE45;
        }

    }
    $stop_fsecure45_time=[gettimeofday];
    $fsecure45_time = tv_interval ($start_fsecure45_time, $stop_fsecure45_time);
    &debug("fsecure45: finished scan of dir \"$scandir/$file_id\" in $fsecure45_time 
secs");
}



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Qmail-scanner-general mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/qmail-scanner-general

Reply via email to