diff --git a/spamc.c b/spamc.c index e88eb6b..891ee9c 100644 --- a/spamc.c +++ b/spamc.c @@ -95,6 +95,9 @@ int flags = SPAMC_RAW_MODE | SPAMC_SAFE_FALLBACK; /* global to control whether we should exit(0)/exit(1) on ham/spam */ int use_exit_code = 0; +/* threshold for outright rejection (as opposed to warning) */ +float redzone = -1; + /* Aug 14, 2002 bj: global to hold -e command */ char **exec_argv; @@ -217,9 +220,9 @@ read_args(int argc, char **argv, struct transport *ptrn) { #ifndef _WIN32 - const char *opts = "-BcrRd:e:fyp:t:s:u:L:C:xzSHU:ElhVKF:0:1:2"; + const char *opts = "-BcrRd:e:fyp:t:s:u:L:C:xzSHU:EZ:lhVKF:0:1:2"; #else - const char *opts = "-BcrRd:fyp:t:s:u:L:C:xzSHElhVKF:0:1:2"; + const char *opts = "-BcrRd:fyp:t:s:u:L:C:xzSHEZ:lhVKF:0:1:2"; #endif int opt; int ret = EX_OK; @@ -246,6 +249,7 @@ read_args(int argc, char **argv, { "full", no_argument, 0, 'R' }, { "headers", no_argument, 0, 2 }, { "exitcode", no_argument, 0, 'E' }, + { "zap", required_argument, 0, 'Z' }, { "no-safe-fallback", no_argument, 0, 'x' }, { "log-to-stderr", no_argument, 0, 'l' }, { "pipe-to", required_argument, 0, 'e' }, @@ -332,6 +336,12 @@ read_args(int argc, char **argv, use_exit_code = 1; break; } + case 'Z': + { + use_exit_code = 1; + redzone = (float)atof(spamc_optarg); + break; + } case 'R': { flags |= SPAMC_REPORT; @@ -909,6 +919,7 @@ main(int argc, char *argv[]) } else if (message_write(out_fd, &m) >= 0) { result = m.is_spam; + if (redzone >= 0) result = m.score >= redzone; if ((flags & SPAMC_CHECK_ONLY) && result != EX_TOOBIG) { message_cleanup(&m); ret = result; @@ -929,6 +940,8 @@ main(int argc, char *argv[]) /* FAIL: */ #if 1 result = m.is_spam; + if (redzone >= 0) result = m.score >= redzone; + if (ret != EX_OK) { result = ret; } diff --git a/spamc.pod b/spamc.pod index 5a18bf6..ba8a8af 100644 --- a/spamc.pod +++ b/spamc.pod @@ -62,8 +62,8 @@ SIZE extension in your BSMTP file will cause many problems). Just check if the message is spam or not. Set process exitcode to 1 if message is spam, 0 if not spam or processing failure occurs. Will print score/threshold to stdout (as ints) or 0/0 if there was an error. -Combining B<-c> and B<-E> is a no-op, since B<-c> implies the behaviour -of B<-E>. +Note: B<-c> implies B<-E>. +Note: B<-c> can usefully be combined with B<-Z>. =item B<-d> I, B<--dest>=I @@ -92,6 +92,13 @@ This option is not supported on Win32 platforms. Filter according to the other options, but set the process exitcode to 1 if message is spam, 0 if not spam or processing failure occurs. +=item B<-Z> I, B<--exitcode> I + +Filter according to the other options, but set the process exitcode to +1 if the message score equals or exceeds I, 0 if not spam or +processing failure occurs. Note: B<-Z> implies B<-E>. Note: B<-Z> +can usefully be combined with B<-c>. + =item B<-F> I, B<--config>=I Specify a configuration file to read additional command-line flags from.