Scanners per domain

This feature allows selecting which scanners (and in what order) they are to be run for a domain or even for a user. This is a useful feature in a commercial environment, where the user must pay to have his messages scanned for virus and/or spam. If you are using this feature in a commercial environment or if you just find this software useful, you could consider donating me some money (something between 10 and 100 US $) to my PayPal account using my email address at the bottom of this page... (of course, this patch will always be free software). I will be very happy with that and I will send you a email when ever a new version is released.
This feature doesn't slows down qmail-scanner.

When qmail-scanner is being installed the @scanner_array (the array that contains the scanners that will be run) is left empty, and there are two new arrays:

@scanners_installed is the array with all installed scanners in the computer, if you disable $scanners_pd then qmail-scanner will fall to this array. Don't modify it unless you really know what you do.

@scanners_default if $scanners_pd is enabled qmail-scanner will use this array for the users/domains that don't have a custom scanner_array set in the $scanners_per_domain.txt file.
After the installation, you can edit qmail-scanner-queue.pl and set it to none to skip all the scanners, even perlscan, or to whatever you want and is present in @scanners_installed.
If you want to skip the scanners only for a particular user/domain set his scanners list to none in the $scanners_per_domain.txt file.

scanners_per_domain.txt

The user/domain configurations are stored in the file scanners_per_domain.txt, the syntax of this file is:

    domain.com:scanner1,scanner2,scanner3
    user1@domain.com:scanner1,scanner2
    user2@domain.com:none
    #
    domain2.com:none
    user3@domain2.com:scanner1,scanner2,scanner3
  

Lines starting with a '#' or 'space' will be ignored. For the users you have to write the full mail address.

It is possible to write 'sophie' or 'sophie_scanner', 'clamdscan' or 'clamdscan_scanner'...

You can write 'ps' or 'perlscanner' instead of 'perlscan_scanner' and 'sa' instead of 'spamassassin'. But you must *not* write in this file fast_spamassassin or verbose_spamassassin, that is set in the variable spamc_options (or sa_alt) in the file qmail-scanner-queue.pl.

Run '/var/qmail/bin/qmail-scanner-queue.pl -p' to generate the db after this file is modified.

Run '/var/qmail/bin/qmail-scanner-queue.pl -h' to see all the flags.

   # /var/qmail/bin/qmail-scanner-queue.pl -h


   qmail-scanner-queue.pl

       -h - This help
       -v - show details about this install.
            Please include in any bug reports.
       -z - gather virus scanner/DAT versions
            and cleanup old temp files
       -g - generate perlscanner database
       -r - read from perlscanner and

       -p - generate scanner per domain database
       -d - display scanner per domain database
       -s - sort the text file /var/spool/qmailscan/scanners_per_domain.txt
            (not yet implemented)

  

How it works

The first thing you must understand is that when there are multiple recipients qmail-scanner will check the message for each recipient. The match is done is this order:

1) If the variable RELAYCLIENT is set, qmail-scanner tries to match the return-path first and then the domain-return-path against the database. If there is a match the @scanner_array is set for this message.

2) If there is not a match or if the RELAYCLIENT is not set, starts the match for each recipient, first the rcpt-to and then the rcpt-to-domain.

3) If there is *not* a match (for the actual recipient) qmail-scanner set for this recipient the @scanner_array to the @scanners_default array (that could be set to none or not) and runs the scanners.

4) If there is a match the @scanner_array is set to the read value from the scanners_per_domain.txt and then the scanners are run.

5) If there are more recipients return to the third step.

When the @scanner_array is set to none only a recieved header will be added to the message. But if you have a messages with multiple recipients the tag_score will be added to each recipent that has at least one scanner in his @scanner_array, so you will find the spamassassin score in the headers even when the user doesn't have spamassassin in his own array, but the X-Spam-Status is only added for the users that really has spamassassin in their own array.

The scanners are run only once for a message, if there are multiple recipient (a lot of) qmail-scanner won't slow down running spamassassin many times. The results of the scanners are stored in a hash from where be readed for the following recipients of the message.

Example

    From -> /var/qmail/bin/qmail-scanner-queue.pl

    my @scanners_installed=("clamdscan_scanner","sophie_scanner","spamassassin","perlscan_scanner");
    my @scanners_default=("perlscan_scanner");


    From -> /var/spool/qmailscan/scanners_per_domain.txt

    domain.com:sophie,clamdscan,sa,ps
    tizio@domain.com:sa,ps
    caio@domain.com:clamdscan,sa,ps
    sempronio@domain.com:none
    #
    otherdomain.com:none
    jsmith@otherdomain.com:sophie,sa,ps
    jdoe@otherdomain.com:sa,ps
  

Che fatica...


Back
Salvatore Toribio

20040809