New version of bogofilter-milter.pl

Tom Anderson tanderso at oac-design.com
Tue Jul 31 01:15:42 CEST 2007


Comments in-line...

Jonathan Kamens wrote:
> 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)?

Seems to me like using "LOG_MAIL" is correct given the docs:

perldoc Sys::Syslog

"...$facility specifies the part of the system to report about, for 
example LOG_USER or LOG_LOCAL0 : see your syslog(3) documentation for 
the facilities available in your system. Facility can be given as a 
string or a numeric macro."

man 3 syslog

"The facility argument is used to specify what type of program is 
logging the message.  This lets the  configuration file specify that 
messages from different facilities will be handled differently...

        LOG_MAIL
               mail subsystem"

Syslog says you should use LOG_MAIL for the mail subsystem and 
Sys::Syslog says that it can be a string.  I'm using Perl v5.8.8, 
Sys::Syslog v0.18, Linux kernel v2.6.12, and glibc v2.5-r0.

As far as I can tell, "mail" means nothing to Syslog on my system.  And 
it certainly prevents any logging from happening.  Making this 
configurable seems to be a good solution to me.

> 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.

Yep, I thought it only made sense to make that configurable.

> 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?

Sure, you can use my name/email.  Please make the email 
neo+bogofilter-milter at orderamidchaos.com.  Here are some comments you 
can append to the top (just an altered version of your comments):

# bogofilter-milter.pl	This shell script takes care of starting and
# stopping bogofilter-milter.pl.
#
# description: bogofilter-milter.pl integrates bogofilter into sendmail.
# processname: bogofilter-milter.pl
# pidfile: /var/run/bogofilter-milter.pid
#
# This script is known to work on Gentoo systems.  To use it to run
# bogofilter-milter on startup, save it as
# /etc/init.d/bogofilter-milter, make sure it's executable, and
# run "rc-update add bogofilter-milter default".  See rc-update docs for
# more info such as adding it to a different run level.  To use it to
# launch the bogofilter-milter daemon immediately, run
# "/etc/init.d/bogofilter-milter start"

# If you change where bogofilter-milter.pl is saved or where the PID and
# sock files are located, modify the paths below accordingly.

# This script is by Tom Anderson <neo+bogofilter-milter at orderamidchaos.com>.

Feel free to modify it as you see fit.

> 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".

Those empty header messages suck.  I'm glad you were able to address those.

> 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.

No prob.

BTW, here's another issue I was having that you may or may not know 
something about.  When I put the bogofilter-milter below clamav in my 
sendmail.mc, everything works fine, but when I put clamav under it, it 
says the socket is unsafe.  Any ideas?

Jul 30 19:10:50 [sm-mta] l6UNATfp026297: Milter (bogofilter-milter): 
local socket name /var/run/bogofilter-milter.sock unsafe
Jul 30 19:10:50 [sm-mta] l6UNATfp026297: Milter (bogofilter-milter): to 
error state

Tom


> 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