Hi. I'm using the qmail-qfilter program to call qmail-queue. qmail-scanner is calling qmail-qfilter. As the qmail program is written, it supports the return code of 31 to indicate permanent failure. (I direct you to the ending lines of qmail.c source. Also, the docs of qmail-qfilter are helpful here). http://www.mit.edu/afs/sipb/service/mail/src/qmail-1.03/qmail-1.03/qmail.c http://untroubled.org/qmail-qfilter/
qmail-scanner does not support the fatal failure supportive handing of exit code 31 which would permit the usual chaining of these programs.
if ($status != 0) { &tempfail ("Unable to queue message ($status). (#4.3.0) -\
$!" )}
Has anyone modified qmail-scanner for robust general use with qmail-qfilter? I'd think of two possible ways to do this.
1) add exit code 31 as a condition handled and returned by qmail-scanner
or
2) have qmail-scanner use sysin and sysout in the general way that filters do in the qmail-qfilter world.
Any thoughts?
Thanks, John
Hi. I decided to modify the code of qmail-scanner-queue (as built/configured on my test machine)
to be able to handle exit code 31 as returned from qmail compliant qmail-queue replacements.
I added a 5xx handler very similar to tempfail(), and the code looks further into returns
from close (QMQ) and waitpid so I can handle them if they are 31 code exits.
Here's a perltidy diff view of my relevant changes. I decided to code this since there
are qmail-qfilter things I would like to do after qmail-queue-scanner runs. This seems to
be working fine on my test server.
John
--- before-changes.pl +++ after-changes.pl
&debug( "tempfail: $V_HEADER-$VERSION: ", @_ ); close(LOG); &cleanup; exit 111; }
+# Fail with the given message and a permanent failure code. +sub fivexxfail { + syslog( 'mail|info', "$V_HEADER-$VERSION:[$file_id] @_" ); + if ( $log_details ne "syslog" ) { + warn "$V_HEADER-$VERSION:[$file_id] ", @_, "\n"; + } + $nowtime = sprintf "%02d/%02d/%02d %02d:%02d:%02d", $mday, $mon + 1, + $year + 1900, $hour, $min, $sec; + &debug( "fivexxfail: $V_HEADER-$VERSION: ", @_ ); + close(LOG); + &cleanup; + exit 31; +} + sub debug { print LOG "$nowtime:$$: ", @_, "\n" if ($DEBUG); }
sub working_copy { my ( $hdr, $last_hdr, $value, $num_of_headers );
--------------and ---------------
} } $still_headers = 0 if (/^(\r|\r\n|\n)$/); } print QMQ; } - close(QMQ) - || &tempfail("Unable to close pipe to $qmailqueue (#4.3.0) - $!"); + close(QMQ); + my $xstatus = ( $? >> 8 ); + &debug("$xstatus on exit from close qmq"); + if ( $xstatus == 31 ) { + &fivexxfail( + "mail server permanently rejected message. (#5.3.0) - $!"); + } + else { + if ( $xstatus != 0 ) { + &tempfail( +"Unable to close pipe to $qmailqueue ($xstatus). (#4.3.0) - $!" + ); + } + + } + + # ||&tempfail("Unable to close pipe to $qmailqueue (#4.3.0) - $!");
#This child is finished - exit exit; } else {
--------------------and-----------------
}
# We should now have queued the message. Let's find out the exit status # of qmail-queue. waitpid( $pid, 0 ); my $status = ( $? >> 8 ); - if ( $status != 0 ) { - &tempfail("Unable to queue message ($status). (#4.3.0) - $!"); + if ( $status == 31 ) { + &fivexxfail("mail server permanently rejected message (#5.3.0) - $!"); + } + else { + if ( $status != 0 ) { + &tempfail("Unable to queue message ($status). (#4.3.0) - $!"); + } }
}
sub valid_virus_to_report { my ($virus_type) = @_;
------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01 _______________________________________________ Qmail-scanner-general mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/qmail-scanner-general