Mailing List Archive

spamc exit codes
I have searched both the archives and Google for this topic, and I have
found a lot of messages on it, but not a single answer, so I cam going to
try again:

Anyone know the magic to get spamc to operate as
spamassassin re: spamassassin --exit-code ?

just replacing spamassassin with spamc doesn't
do it in my mail delivery script. I need to
use a different script path if the message is
tagged as spam.

It is possible to filter the message twice, but
if spamc were to return the exit code regardless
if -c were set, double filtering isn't required.

I use Postfix for a corporate wide email gateway
and want to filter ALL spam off to a separate
directory to be analyzed.

Yes, I have been told I can install procmail and
so on, but if I could get the exit code instead,
my job is done and no additional programs need to
be installed.

Any ideas appreciated. Thanks!
Re: spamc exit codes [ In reply to ]
On Tue, 9 Mar 2004, Jason Borkowsky wrote:

> Anyone know the magic to get spamc to operate as
> spamassassin re: spamassassin --exit-code ?

Spamc operated under a different paradigm than SpamAssassin;
spamc is an executable program that connects across a network
to a machine running spamd, spamd does all the heavy lifting,
passes the findings back to spamc, which then spits the finished
product to stdout. The exit code in this instance is an indicator
of whether spamc was able to communicate with (the remote) spamd
process, and whether that process was successful (i.e. spamd
returned valid data, spam or not).

To make matters worse, SpamAssassin's scores are reals and
UNIX's exit codes are ints. You just don't want to fiddle with
the exit code because you may need it for something else.

> It is possible to filter the message twice, but
> if spamc were to return the exit code regardless
> if -c were set, double filtering isn't required.

What happens if your spamd dies and spamc, operating in its
normal mode cannot communicate with spamd? It'll quit with a
non-zero exit code and procmail (or whatever your delivery mechanism
is) should do the right thing and get the original text of the
message back. How, in that case, does one tell if the spamc/spamd
handshake actually worked?

> Yes, I have been told I can install procmail and
> so on, but if I could get the exit code instead,
> my job is done and no additional programs need to
> be installed.

Run messages through a default spamc to a temp file, grab the spam
score, and do with that what you want. Double-scanning is not the
answer, especially if you've got a busy site.

+------------------------------------------------+---------------------+
| Carl Richard Friend (UNIX Sysadmin) | West Boylston |
| Minicomputer Collector / Enthusiast | Massachusetts, USA |
| mailto:crfriend@rcn.com +---------------------+
| http://users.rcn.com/crfriend/museum | ICBM: 42:22N 71:47W |
+------------------------------------------------+---------------------+
Re: spamc exit codes [ In reply to ]
> To make matters worse, SpamAssassin's scores are reals and
> UNIX's exit codes are ints. You just don't want to fiddle with
> the exit code because you may need it for something else.

> Run messages through a default spamc to a temp file, grab the spam
> score, and do with that what you want. Double-scanning is not the
> answer, especially if you've got a busy site.

Actually, I tried exactly this, and then sent a "normal heavy" load through
my SpamAssassin script to test it, and there were times when the temp file
would be overwritten before the current spamc process was done with it. I
found you have to keep the data flowing (such as sequential pipes) otherwise
you have to start locking files.

I will keep working on a solution, but if anyone has any suggestions, please
let me know.
Re: spamc exit codes [ In reply to ]
On Tue, 9 Mar 2004, Jason Borkowsky wrote:

> > Run messages through a default spamc to a temp file, grab the spam
> > score, and do with that what you want. Double-scanning is not the
> > answer, especially if you've got a busy site.
>
> Actually, I tried exactly this, and then sent a "normal heavy" load through
> my SpamAssassin script to test it, and there were times when the temp file
> would be overwritten before the current spamc process was done with it. I
> found you have to keep the data flowing (such as sequential pipes) otherwise
> you have to start locking files.

Use "mktemp" (or "tmpfile", depending upon your context) to create a
temporary file with a unique name, then there's no danger of overwriting.


--
Dave Funk University of Iowa
<dbfunk (at) engineering.uiowa.edu> College of Engineering
319/335-5751 FAX: 319/384-0549 1256 Seamans Center
Sys_admin/Postmaster/cell_admin Iowa City, IA 52242-1527
#include <std_disclaimer.h>
Better is not better, 'standard' is better. B{
RE: spamc exit codes [ In reply to ]
Maybe this is a stupid question, but why doesn't spamc return different
error codes; one for "can't communicate with spamd", another for "e-mail
is spam", etc.

> -----Original Message-----
> From: David B Funk [mailto:dbfunk@engineering.uiowa.edu]
> Sent: Tuesday, March 09, 2004 8:25 PM
> To: Jason Borkowsky
> Cc: spamassassin-users@incubator.apache.org
> Subject: Re: spamc exit codes
>
> On Tue, 9 Mar 2004, Jason Borkowsky wrote:
>
> > > Run messages through a default spamc to a temp file, grab the
spam
> > > score, and do with that what you want. Double-scanning is not the
> > > answer, especially if you've got a busy site.
> >
> > Actually, I tried exactly this, and then sent a "normal heavy" load
> through
> > my SpamAssassin script to test it, and there were times when the
temp
> file
> > would be overwritten before the current spamc process was done with
it.
> I
> > found you have to keep the data flowing (such as sequential pipes)
> otherwise
> > you have to start locking files.
>
> Use "mktemp" (or "tmpfile", depending upon your context) to create a
> temporary file with a unique name, then there's no danger of
overwriting.
>
>
> --
> Dave Funk University of Iowa
> <dbfunk (at) engineering.uiowa.edu> College of Engineering
> 319/335-5751 FAX: 319/384-0549 1256 Seamans Center
> Sys_admin/Postmaster/cell_admin Iowa City, IA 52242-1527
> #include <std_disclaimer.h>
> Better is not better, 'standard' is better. B{
> ------------------------------------------------------------
> Mail was checked for spam by the Freeware Edition of No Spam Today!
> The Freeware Edition is free for personal and non-commercial use.
> You can remove this notice by purchasing a full license! To order
> or to find out more please visit: http://www.no-spam-today.com
Re: spamc exit codes [ In reply to ]
> > Actually, I tried exactly this, and then sent a "normal heavy" load through
> > my SpamAssassin script to test it, and there were times when the temp file
> > would be overwritten before the current spamc process was done with it. I
> > found you have to keep the data flowing (such as sequential pipes) otherwise
> > you have to start locking files.
>
> Use "mktemp" (or "tmpfile", depending upon your context) to create a
> temporary file with a unique name, then there's no danger of overwriting.

Excellent idea! Did that and it works well. Just need to go over it and
optimize it a bit now. Thanks!