qmail-scanner-queue and qmail-dk
by Arian Ban

This is based on some information found on internet. The original add-on i found here. But this add-on it has a bug, like if you want to send an email to more that one recipients, the qmail-scanner-queue return an error like this:

Fri, 15 Feb 2008 09:19:33 EET:13136/13135: error_condition: X-Antivirus-ecranbleu-2.02st: Unable to open pipe to /var/qmail/bin/qmail-dk [81] (#4.3.0) -
Fri, 15 Feb 2008 09:19:33 EET:13136/13135: ------ Process 13136/13135 finished. Total of 0.26839 secs
Fri, 15 Feb 2008 09:19:33 EET:13136/13135: error_condition: X-Antivirus-ecranbleu-2.02st: Unable to close pipe to /var/qmail/bin/qmail-dk [81] (#4.3.0) - Illegal seek
Fri, 15 Feb 2008 09:19:33 EET:13136/13135: ------ Process 13136/13135 finished. Total of 0.278197 secs

The error is created by re-replace the $qmailqueue variable in qmail_requeue subroutin. Another impovement is that i add the verify DK for incomming emails. The add-on sould be added after between line:

sub qmail_requeue {
  my($sender,$env_recips,$msg)=@_;
  my ($temp,$findate);
and
  &debug("q_r: fork off child into $qmailqueue...");

The addon is:
  $qmailqueuedk = '/var/qmail/bin/qmail-dk';
# set DKSIGN variable to private key to sign with $ENV{'DKSIGN'}='/etc/domainkeys/%/default';
# set DKVERIFY variable to reject bad signed emails # for more details about DKVERIFY check man qmail-dk or http://qmail.jms1.net/patches/domainkeys.shtml
$ENV{'DKVERIFY'}='EGIJKfh';
# check rcpthosts file for relaying domains open(RCPTHOSTS, "</var/qmail/control/rcpthosts"); while (<RCPTHOSTS>) { chomp; if (/^$domain_returnpath$/i || $domain_returnpath =~ /$_$/i) { # match found if ( $qmailqueue ne $qmailqueuedk ) {
# set DKQUEUE to original qmail-queue to spawn
$ENV{'DKQUEUE'}=$qmailqueue; # set $qmailqueue to qmail-dk so qmail-scanner calls it to sign keys
$qmailqueue = $qmailqueuedk; } &minidebug("Signing message from $returnpath with a DomainKey"); }
} close(RCPTHOSTS); # check rcpthosts file for relaying domains open(RCPTHOSTS, "</var/qmail/control/rcpthosts"); while (<RCPTHOSTS>) {
chomp;
if (/^$domain_one_recip$/i) {
# match found
# set DKQUEUE to original qmail-queue to spawn
if ( $qmailqueue ne $qmailqueuedk ) {
#&minidebug("$qmailqueue and $qmailqueuedk");
# set $qmailqueue to qmail-dk so qmail-scanner calls it to sign keys, if $qmailqueue not defined prev.
$ENV{'DKQUEUE'}=$qmailqueue;
# set $qmailqueue to qmail-dk so qmail-scanner calls it to verify keys
$qmailqueue = $qmailqueuedk; } &minidebug("Verifing message from $returnpath to $one_recip if it has a valid DomainKey"); } } close(RCPTHOSTS);