New version of bogofilter-milter.pl
Jonathan Kamens
jik at kamens.brookline.ma.us
Fri Jul 27 05:08:26 CEST 2007
The change from 'mail' to 'LOG_MAIL' in the openlog call is wrong,
according to the Sys::Syslog documentation on my machine. The
documentation says that you can use either a facility string, e.g.,
'mail', or a facility macro /without/ quotes, e.g., LOG_MAIL. It
doesn't say that you're allowed to use 'LOG_MAIL' in quotes. While it's
interesting that that works for you :-), since it's contraindicated by
the documentation and specifying 'mail' works just fine for me, I don't
think I can accept that patch. Could you dig a little deeper and see if
you can figure out what's going on at your end? What version of Perl
are you using (what does "perl -v" return)? What version of Sys::Syslog
are you using (what does "perl -e 'use Sys::Syslog; print
$Sys::Syslog::Version;'" return)?
I like your changes to make the codes and message configurable at the
top of the script. I've incorporated those changes into my version, thanks.
I've put my Fedora start/stop script up for download at
http://stuff.mit.edu/~jik/software/bogofilter-milter/bogofilter-milter.fedora.
Thanks for your Gentoo script; I've put it up for download at
http://stuff.mit.edu/~jik/software/bogofilter-milter/bogofilter-milter.gentoo.
Can I put your name and email address at the top of the script as the
author of it? I like to give credit where credit is due, but I don't
like to put people's names and/or email addresses up on a Web page
without their consent :-). Also, would you mind looking at the
explanatory comments at the top of my Fedora script and writing up
something similar for the Gentoo script?
I've put a new version of bogofilter-milter.pl at
http://stuff.mit.edu/~jik/software/bogofilter-milter/bogofilter-milter.pl.
It has these changes in it from the last version:
* configurable rejection messages as suggested by Tom Anderson
* minor documentation improvements in the comments at the top
* properly handle messages with empty headers, a new tactic that the
spammers have apparently just started using
* when my_eom_callback is called unexpectedly (which was happening,
until I fixed the empty-headers problem), accept the message
rather than dying, because dying leaves sendmail high and dry
without a milter, which makes it really unhappy
* add a bunch of debug messages (which I needed in order to figure
out the empty-headers problem) which are only logged when the
script is run with "--debug".
Please let me know if you have any questions, comments or concerns.
Thanks,
jik
P. S. For future reference, in the future please send context or unified
diffs rather than plain diffs; the latter are impossible to apply if the
file being patched has had any changes made in the interim.
On 07/26/2007 10:27 PM, Tom Anderson wrote:
> I've made some changes to bogofilter-milter.pl to remedy a few
> problems I was having, one being that it wasn't writing to my
> syslog... I fixed that one. Another being that the rejection message
> wasn't working and still isn't. Instead of the given setreply, it
> returns "554 5.7.1 Command rejected". I still can't figure that one
> out after reading the Sendmail::Milter docs several times. Anyway
> here's my patch thus far:
>
> 70a71,73
> > # The syslog facility to which to log messages -- see syslog(3) docs
> > my $facility = 'LOG_MAIL';
> >
> 142a146,153
> > # Rejection options
> > my $rcode = "550"; # three-digit RFC 821 SMTP reply
> > my $xcode = "5.7.1"; # extended RFC 2034 reply code
> > my $message = "This message has been classified as spam.\n" .
> > "If it is not spam, please try rewording your message " .
> > "and sending it again. Otherwise, please contact " .
> > "recipient via phone, snail mail, IM, or another means.";
> >
> 196c207
> < openlog($whoami, 'pid', 'mail');
> ---
> > openlog($whoami, 'pid', $facility);
> 489,491c500
> < $ctx->setreply(550, "5.7.1", "Your message looks like
> spam.\n" .
> < "If it isn't, resend it with $magic_string " .
> < "in the Subject line.");
> ---
> > $ctx->setreply($rcode, $xcode, $message);
>
> Also, in case anyone is interested, I created a Gentoo start/stop script:
>
> #!/sbin/runscript
>
> depend() {
> need net
> use logger
> }
>
> start() {
> ebegin "Starting bogofilter-milter"
>
> if [ -f /var/run/bogofilter-milter.pid ]; then
> rm -f /var/run/bogofilter-milter.pid
> fi
>
> if [ -S /var/run/bogofilter-milter.sock ]; then
> rm -f /var/run/bogofilter-milter.sock
> fi
>
> start-stop-daemon --start --quiet --pidfile
> /var/run/bogofilter-milter.pid --exec /usr/sbin/bogofilter-milter.pl
> -- --daemon
> eend $? "Failed to start bogofilter-milter"
> }
>
> stop() {
> ebegin "Stopping bogofilter-milter"
> start-stop-daemon --stop --quiet --pidfile
> /var/run/bogofilter-milter.pid
> eend $? "Failed to stop bogofilter-milter"
> }
>
> Tom
More information about the Bogofilter
mailing list