http://nntp.x.perl.org/group/perl.qpsmtpd/544
which built on a patch by Peter J Holzer:
http://nntp.x.perl.org/group/perl.qpsmtpd/503
is this patch which adds an additional configuration option spamd_socket, which specifies where the Unix Domain socket for spamd is located. Lightly tested but WFM...
John
p.s. patch attached instead of inline because Mozilla messes up long lines arbitrarily ;~(
Index: plugins/spamassassin =================================================================== RCS file: /cvs/public/qpsmtpd/plugins/spamassassin,v retrieving revision 1.5 diff -u -r1.5 spamassassin --- plugins/spamassassin 18 Mar 2003 09:53:37 -0000 1.5 +++ plugins/spamassassin 30 Oct 2003 16:09:24 -0000 @@ -49,6 +49,12 @@
The default is to never munge the subject based on the SpamAssassin score.
+=item spamd_socket [/path/to/socket]
+
+Beginning with Mail::SpamAssassin 2.60, it is possible to use Unix
+domain sockets for spamd. This is faster and more secure than using
+a TCP connection.
+
=back
With both options the configuration line will look like the following
@@ -92,8 +98,17 @@
my $paddr = sockaddr_in($port, $iaddr);
my $proto = getprotobyname('tcp');
+ if ( $self->{_args}->{spamd_socket} =~ /^([\w\/.]+)$/ ) { # connect to Unix Domain
Socket
+ my $spamd_socket = $1;
+
+ socket(SPAMD, PF_UNIX, SOCK_STREAM, 0)
+ or $self->log(1, "Could not open socket: $!") and return (DECLINED);
+
+ $paddr = sockaddr_un($spamd_socket);
+ } else {
socket(SPAMD, PF_INET, SOCK_STREAM, $proto)
or $self->log(1, "Could not open socket: $!") and return (DECLINED);
+ }
connect(SPAMD, $paddr)
or $self->log(1, "Could not connect to spamassassin daemon: $!") and return
DECLINED;
@@ -102,7 +117,7 @@
$transaction->body_resetpos;
- print SPAMD "REPORT_IFSPAM SPAMC/1.0" . CRLF;
+ print SPAMD "SYMBOLS SPAMC/1.0" . CRLF;
# or CHECK or REPORT or SYMBOLS
print SPAMD join CRLF, split /\n/, $transaction->header->as_string
@@ -124,17 +139,22 @@
$transaction->header->add("X-Spam-Check-By", $self->qp->config('me'));
}
+ my ($flag, $hits, $required);
while (<SPAMD>) {
#warn "GOT FROM SPAMD1: $_";
- next unless m/\S/;
- s/\r?\n$/\n/;
- my @h = split /: /, $_, 2;
-
- $transaction->header->add(@h);
- last if $h[0] eq "Spam" and $h[1] =~ m/^False/;
-
+ last unless m/\S/;
+ if (m{Spam: (\w+) ; (-?\d+\.\d) / (-?\d+\.\d)}) {
+ ($flag, $hits, $required) = ($1, $2, $3);
+ }
}
+ my $tests = <SPAMD> || '';
+ $tests =~ s/\s+$//;
+ $self->log(5, "$flag, hits=$hits, required=$required, tests=$tests") if $tests;
+ $tests =~ s/(.{1,50}),/$1,\n\t/g; # wrap
+ $transaction->header->add('X-Spam-Status', "$flag, hits=$hits required=$required" .
+ ( $tests ? "\n\ttests=$tests" : '' ) );
+
return (DECLINED);
}
@@ -157,7 +177,9 @@
return DECLINED unless $score >= $self->{_args}->{munge_subject_threshold};
my $subject = $transaction->header->get('Subject') || '';
- $transaction->header->replace('Subject', "***SPAM*** $subject");
+ $subject = sprintf('@SPAM(%05.2f) %s', $score, $subject);
+ $self->log(5, qq(munging subject to "$subject"));
+ $transaction->header->replace('Subject', $subject);
return DECLINED;
}
