Comments on The Perfect SpamSnake - Ubuntu Jaunty Jackalope

The Perfect SpamSnake - Ubuntu Jaunty Jackalope This tutorial shows how to set up an Ubuntu Jaunty Jackalope based server as a spamfilter in Gateway mode. In the end, you will have a SpamSnake Gateway which will relay clean emails to your MTA. You will also be able to view your incoming queue, train your SpamSnake and carry out a few more advanced operations via MailWatch.

8 Comment(s)

Add comment

Please register in our forum first to comment.

Comments

By:

These are live notes that I collected as I got this great Spam Snake working: (and do note that it works very well - when you overcome a 'few' problems)

The line with: [apt-get install mailscanner razor pyzor clamav-module] produces a problem finding the clamav-module: (missing resolution steps outlined)

Steps to get and install the [Spam Snake] clamav-module:

Be sure you have perl installed... (if not sure use: aptitude install perl) then enter:

perl -MCPAN -e shell

If you are prompted if you want to configure perl automatically choose: yes

When you are at [cpan] prompt enter (steps 1-7):

1) install CPAN (gets any upgrades for perl / cpan)
2) reload cpan (reload any new version)
3) test File::Scan::ClamAV (it will download the ClamAV module)
4) look File::Scan::ClamAV (shell to the ClamAV area)
5) make install (will perform the ClamAV-module install)
6) exit
7) quit

All done, now we have the ClamAV-Module!

UPDATE: You will likely find that continuing with the [SpamSnake] setup that there will be other missing PERL modules:

I outline the steps to resolve this (it was pure research) - and it now works:

Type: (at Linux command line)

cpan -i ExtUtils::Command::MM
aptitude install libconvert-binhex-perl
cpan -i Checker::ISA
cpan -i Archive::Zip
aptitude install libyaml-perl
cpan -i OLE::Storage_Lite


Now we are almost there: - see if it now works OK

Test the final perl setup with this:

/opt/MailScanner/bin/check_mailscanner


The given steps (in this Spam Snake guide) shown as:

Create /etc/postfix/relay_recipients and add the following:

@example.com OK
@example2.com OK

Create /etc/postfix/transport and add the following:

example.com smtp:[192.168.0.x]
example2.com smtp:[192.168.0.x]

Create /etc/postfix/relay_domains and add the following:

example.com OK
example2.com OK

Must NOT include any reference to any declared virtual email domains, or you will see this error:

"postfix/trivial-rewrite: warning: do not list domain mydomain.com in BOTH virtual_mailbox_domains and relay_domains"

The line that has: example.com smtp:[192.168.0.x] must be a full and valid IP address!


I have performed several email tests and I am very happy with the final process, Additionally, all outgoing emails show this text report:

This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Peter Bowey

By:

In the Ubuntu / Debain's /etc/init.d/mailscanner startup script (or the default MailWasher /etc/rc2.d/S20mailscanner) to include the required UID / GUID on the daemon start line: (see next line)

Find the line in the Ubuntu /etc/init.d/mailscanner distro (or the orig MailScanners own .tar distro = /etc/rc2.d/S20mailscanner) that has:

start-stop-daemon --start --quiet --nicelevel $run_nice --exec $DAEMON --name $NAME -- $DAEMON_ARGS \

and change it to:

start-stop-daemon --start --quiet --nicelevel $run_nice --chuid postfix --exec $DAEMON --name $NAME -- $DAEMON_ARGS \

 This doesn't work for me since I run Karmic. I get an error that Mailscanner can't set the gid in ... line ...

Solution:

start-stop-daemon --start --quiet --nicelevel $run_nice --chuid postfix:www-data --exec $DAEMON --name $NAME -- $DAEMON_ARGS \

Runs like a charm now with no errors.

 

By:

You see an error like this: (mail.log)

"ClamAV-autoupdate: ClamAV updater /usr/local/bin/freshclam cannot be run"

Solution: create a symbolic link from:   /usr/bin/freshclam -> /usr/local/bin/freshclam

Now the path reference works:

The [mail.log] will now show something like this:

"update.virus.scanners: Running autoupdate for clamav"
"ClamAV-autoupdate[31509]: ClamAV did not need updating"

Peter Bowey

By:

After moving the newly installed MailScanner to /opt and renaming the repository installed version to /etc/MailScanner.dist  this leaves the MailScanner init script still configured to look for Mailscanner.conf in /etc/MailScanner. Either changing the init script or creating a link fixes this.

By:

I was one of the likely many that recently updated Ubuntu/Debian PERL to the latest release of 5.10:

I found this latest PERL killed MailScanner - with logged (mail.log) reports of: "Insecure dependency in chown while running with the -T switch in ..../MailScanner/message.pm on line xxxx". MailScanner would then 'abort' any exec calls or just hang - leaving no outward flow of emails! Yet, after hours of research - there is a solution (other than going back to the older PERL V5.9.x)!

This new 'problem' results from the new PERL Taint Mode enforcement policy! This new 'rule' enables (and enforces) a number of wise security checks with programs (exec) called with different user and / or group ids.

There is a solution, and I have tested it with the latest release .tar of MailScanner v4.78.1:

In the Ubuntu / Debain's /etc/init.d/mailscanner startup script (or the default MailWasher /etc/rc2.d/S20mailscanner) to include the required UID / GUID on the daemon start line: (see next line)

Find the line in the Ubuntu /etc/init.d/mailscanner distro (or the orig MailScanners own .tar distro = /etc/rc2.d/S20mailscanner) that has:

start-stop-daemon --start --quiet --nicelevel $run_nice --exec $DAEMON --name $NAME -- $DAEMON_ARGS \

and change it to:

start-stop-daemon --start --quiet --nicelevel $run_nice --chuid postfix --exec $DAEMON --name $NAME -- $DAEMON_ARGS \

The effect of this change allows mailscanner to run with the required UID to prevent the new PERL enforced 'taint mode'. Please note that this means that MailWasher must have the UID set to postfix in the MailScanner.conf file.

Another change I found that was essential was to add the clamav user to the postfix group. Without this change I got permission denied errors when the clamd (daemon) was called by MailWasher to check emails on the /var/spool/postfix/incoming folder. (with UID = postfix).

With the new changes I have no further faults or errors using MailScanner (with all the extra 'SpamSnake' additions). This new code runs live on my own dedicated business mail server - so it is a live and real test! Normally, I used to recieve about 350 spam emails per day, now it has dropped to 2-3 that 'leak' through the 'SpamSnake'.

If any one is interested, I have ported the latest MailScanner tar release v4.78.1 to a true debain / ubuntu style package - without the generic /OPT/.... directory.

Peter Bowey

By: Frank Holler

Hi.

I am running Debian and mta exim4 and my error was different: "Insecure dependency in exec while running with -T switch at /usr/share/MailScanner//MailScanner/SweepOther.pm line 374"

So i changed  /etc/init.d/mailscanner and added "--chuid=Debian-exim" and the error disappeared. This helped.

Thanks alot.

By: Nivethan

Thank you verymuch, your method worked! I had been wondering with the mail scanner looping problem for two days and just before was going to go change back to a older perl version fortunately I found your comment! wow! brilliant....

By: Jamie Strandboge

I noticed that this tutorial recommends to disable all of AppArmor. Unless you have a very specific need to do so, this is not recommended. The apparmor profiles shipped in Ubuntu are designed to work with the default installation. If a particular profile is causing you trouble, please disable the profile or put it in complain mode, and leave the other profiles that are not causing problems to do their jobs. Better yet, file a bug. :) See my blog entry athttp://penguindroppings.wordpress.com/2009/07/07/should-i-disable-apparmor/ for details.