This feature allows selecting which scanners (and in what order) they are
to be run for a domain or even for a user.
And also to set the sa_settings per user and/or domain.
Combined with Spamassassin sql settings allows you to do complete per user and/or domain customization.
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
the button 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 $settings_pd then qmail-scanner will fall to this array. Don't modify it unless you really know what you do.
@scanners_default if $settings_pd is enabled qmail-scanner will use this array for the users/domains that don't have a custom scanner_array set in the $settings_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 $settings_per_domain.txt file.
In the same way sa_quarantine is left empty and the site-wide value is stored in a new variable sa_quarantine_site. This is done for the following sa_settings:
The user/domain configurations are stored in the file settings_per_domain.txt, the syntax of this file is:
domain.com:scanner1,scanner2,scanner3'sa_subject'sa_quarantine'sa_delta'sa_delete'sa_reject'sa_forward'sa_fwd_verbose'sa_hdr_report'smaildir email@example.com:scanner1,scanner2'sa_subject'sa_quarantine''sa_delete'sa_reject firstname.lastname@example.org:none # domain2.com:none email@example.com:scanner1,scanner2,scanner3'none'sa_quarantine''sa_delete'sa_reject'''sa_hdr_report'smaildir firstname.lastname@example.org:scanner1,scanner2
Notice that the scanners are separated by a comma and the other settings by a single quote.
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 sa_fast (or sa_alt) in the file qmail-scanner-queue.pl.
You can omit the options that you want qmail-scanner gets from the sa_settings_site, but you always have to specify the scanners for the user/domain. If spamassassin it is not present in the user/domain settings, the sa_settings are ignored.
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-test.pl 2.00st-20060416 -h - This help -v - show details about this install. Please include in any bug reports. -V - show details about this install and some configuration information. -z - gather virus scanner/DAT versions and cleanup old temp files -g - generate perlscanner database -r - read from perlscanner database -p - generate settings per domain database -d - display settings per domain database -s - sort the text file /var/spool/qscan/settings_per_domain.txt
The first thing you must understand is that when there are multiple recipients qmail-scanner will check the message for each recipient (but each scanner runs only once except spamassassin with sql settings). 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 and sa_settings are 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 sets for this recipient the @scanner_array to the @scanners_default array (that could be set to none or not) and the sa_settings_site, and then runs the scanners.
4) If there is a match the @scanner_array and sa_settings are set to the read values from the settings_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 except spamassassin with sql settings), if there are multiple recipient (a lot of) qmail-scanner won't slow down running the antivirus many times. The results of the scanners are stored in a hash from where be readed for the following recipients of the message.
From -> /var/qmail/bin/qmail-scanner-queue.pl my @scanners_installed=("clamdscan_scanner","sophie_scanner","spamassassin","perlscan_scanner"); my @scanners_default=("perlscan_scanner"); my $sa_subject_site=''; my $sa_quarantine_site='2.1'; my $sa_delta_site='0'; my $sa_delete_site='3.6'; my $sa_reject_site='1'; my $sa_forward_site=''; my $sa_fwd_verbose_site='0'; my $sa_hdr_report_site='0'; my $smaildir_site="$vmaildir"; From -> /var/spool/qmailscan/settings_per_domain.txt domain.com:sophie,clamdscan,sa,ps'[SPAM]'email@example.com'1'1'spamdir_domain firstname.lastname@example.org:sa,ps'** SPAM **'2.5''3.9'0 email@example.com:clamdscan,sa,ps''''''''1'spamdir_caio firstname.lastname@example.org:none # otherdomain.com:none email@example.com:sophie,sa,ps'none'1.7''2.7'0'''1'spamdir_jsmith firstname.lastname@example.org:sa,ps