Bug? mailreaver.crm returns wrong exit code with --stats_only

Chris Shenton <[email protected]>
Newsgroups gmane.mail.spam.crm114
Message-ID <[email protected]>
On FreeBSD-6.3 I'm running

 X-CRM114-Version:_20080326-BlameSentansoken

I'm integrating it with Qmail's ".qmail" mechanism which can look at a
process' returned exit status value and file mail directly into a
mailbox.  So I've set mailfilter.cf with:

  :rejected_mail_exit_code: /0/
  :accepted_mail_exit_code: /1/
  :unsure_mail_exit_code:   /1/
  :program_fault_exit_code: /111/

This works, returning 0 for spam and 1 for good mail with
mailreaver.crm, *unless* I specify the --stats_only option, in which case
it *always* returns 0.  If I use the --report_only option instead, it
returns 0 and 1 appropriately.

If I use mailfilter.crm it returns the correct codes with no options,
with --stats_only and with --report_only.

So it seems there's some bug with mailreaver.crm which is causing it not
to return the :accepted_mail_exit_code: for good mail when --stats_only
is used.  I'm too much of a CRM114 newbie to be able to parse and
understand what mailreaver.crm's doing, but here are some tests to demo
the problem:

  > cat /tmp/spam.mail | crm -u $HOME/crm114 mailreaver.crm  >/dev/null
  > echo $?
  0
  > cat /tmp/good.mail | crm -u $HOME/crm114 mailreaver.crm  >/dev/null
  > echo $?
  1

  > cat /tmp/spam.mail | crm -u $HOME/crm114 mailreaver.crm  --stats_only
  -49.54
  > echo $?
  0
  > cat /tmp/good.mail | crm -u $HOME/crm114 mailreaver.crm  --stats_only
   75.85
  > echo $?
  0                   <=============== PROBLEM, should be 1

  > cat /tmp/spam.mail | crm -u $HOME/crm114 mailreaver.crm --report_only
  X-CRM114-Version: 20080326-BlameSentansoken ( TRE 0.7.5 (LGPL) ) MR-2AB8DE83 
  X-CRM114-CacheID: sfid-20080605_11520_4E4A6F3D 
  X-CRM114-Status: SPAM  ( -48.36  )
  > echo $?
  0

  > cat /tmp/good.mail | crm -u $HOME/crm114 mailreaver.crm --report_only
  X-CRM114-Version: 20080326-BlameSentansoken ( TRE 0.7.5 (LGPL) ) MR-2AB8DE83 
  X-CRM114-CacheID: sfid-20080605_11521_D01B8240 
  X-CRM114-Status: GOOD (  77.48  )
  > echo $?
  1                  <============== OK, works properly with this option


When I run mailfilter the same way, the behavior is consistent, correct:

  > cat /tmp/spam.mail | crm -u $HOME/crm114 mailfilter.crm  >/dev/null
  > echo $?
  0
  > cat /tmp/good.mail | crm -u $HOME/crm114 mailfilter.crm  >/dev/null
  > echo $?
  1

  > cat /tmp/spam.mail | crm -u $HOME/crm114 mailfilter.crm  --stats_only
  -50.4788 
  > echo $?
  0
  > cat /tmp/good.mail | crm -u $HOME/crm114 mailfilter.crm  --stats_only
  75.8535 
  > echo $?
  1

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.