Release
 

Part 14 - Clam Antivirus & Spamassassin

Alright, the next 2 steps are going to be the trickiest of the entire installation. First, on this page, we're going to install Clam Antivirus and Spamassassin. Then, on the next page, we will install qmail-scanner which will tie ClamAV and Spamassassin into the operation of our qmail server. I'm going to warn you again that these next two steps are typically a pain in the ass. I am constantly trying to make these steps as universal and easy as possible, but the ease of these steps depends heavily on how your system is configured and how experienced you are. If you've never done this before, you can pretty much bet you're going to have a problem or 2 along the way. But don't give up. If you get into a bind, feel free to consult the qmailrocks mailing list, mailing list archive, IRC channel or chat forum. Using these 4 resources, you've got an excellent chance of getting any help you may need. OK, it's time to put some hair on your chest!

The first thing you must do is make sure that you've got a recent version of Perl installed on your box. Using the command "perl -v" will typically tell you what version is running. Spamassassin 3, at least when I installed it, required Perl 5.8. If you're running something older than 5.8, you will likely need to upgrade. I'm not going to go into a great deal of detail into how to upgade Perl here, but I will tell you a little story that might help. My FreeBSD box was running a default 5.005 version of perl. Using the "pkg_delete" command, I removed that version. I then installed the new Perl 5.8 from the FreeBSD ports collection. After that, I ran the following command to instruct the system to use the ports installation of Perl from now on:

use.perl port

And viola! My box was now using the new 5.8 version of Perl. I hope you like my little story.

Once you've got the right version of Perl installed on your box, you will now want to verify that you have all the required Perl modules and packages that will enable Clam AV and Spamassassin to function correctly.

The following Perl Modules/packages are required. If you find that I'm missing one here, let me know.

Digest::SHA1
Digest::HMAC

Net::DNS
Time::HiRes
HTML::Tagset
HTML::Parser

Pod::Usage
Parse::Syslog
Statistics::Distributions

- Helpful Hints -

Checking/Installing Perl Modules

How do I know if my server has these perl modules?

The following script will check your system for the above modules.

You MUST run this script as a NON-ROOT user!!

/downloads/qmailrocks/scripts/util/check_perlmods.script

If you see an output similar to this: /usr/local/lib/perl5/site_perl/5.6.1/mach/Time/HiRes.pm , you're good to go! However, if you get a "not found" type response for any of the above modules, you will need to install them.

Ok, so if I don't have the module(s), how do I down and install it(them)?

There are 3 main ways you can do this:

1. The old fashioned way (CPAN) - Go to http://www.cpan.org, download the needed module, read the "INSTALL" file and away you go. I've also included tarballs of these modules in the Qmailrocks package, so feel free to use them if you want.

2. Using the pkg_add utility - This is the best method because the pkg_add utility AUTOMATICALLY installs any dependencies that may be needed for these Perl modules to be installed. This saves lots of time and hassle.

3. The easy way (The Ports Collection) - The Freebsd ports collection has made a lazy man out of me. They make all this crap so easy.

Installing directly with the pkg_add utility

As root, run the following commands:

pkg_add -r p5-Time-HiRes
pkg_add -r p5-Net-DNS
pkg_add -r p5-Digest-SHA1
pkg_add -r p5-Digest-HMAC
pkg_add -r p5-HTML-Tagset
pkg_add -r p5-HTML-Parser
pkg_add -r p5-Parse-Syslog
pkg_add -r p5-PodParser
pkg_add -r p5-Statistics-Distributions

Installing from the ports collection:

On my server, I found the needed ports in the following locations:

Time::HiRes - /usr/ports/devel/p5-Time-HiRes
Net::DNS - /usr/ports/dns/p5-Net-DNS
Digest::SHA1 - /usr/ports/security/p5-Digest-SHA1
Digest::HMAC - /usr/ports/security/p5-Digest-HMAC
HTML-Tagset - /usr/ports/www/p5-HTML-Tagset
HTML::Parser - /usr/ports/www/p5-HTML-Parser
Pod::Usage - /usr/ports/textproc/p5-PodParser
Parse::Syslog - /usr/ports/textproc/p5-Parse-Syslog
Statistics::Distributions - /usr/ports/math/p5-Statistics-Distributions

Simply cd into each packages directory as shown above and run: make install && make clean

Note: If you find that the directory "/usr/ports" does not exist, it means you don't have the ports collection. You can get the latest Freebsd ports tree at ftp://ftp.freebsd.org/pub/FreeBSD/ports/ports/ports.tar.gz (anonymous login)

Damn! Now wasn't that easy?

Ok, so at this point you should have all 4 of the above Perl modules installed on your system. So let's install Clam Anti Virus and then Spamassassin.

Installing Clam Anti Virus...

cd /downloads/qmailrocks/

tar zxvf clamav-x.xx.tar.gz

cd clamav-x.xx

pw useradd clamav -s /sbin/nologin -d /tmp

pw useradd qscand -s /sbin/nologin -d /tmp

./configure

make && make check && make install && make clean

Now we'll do a few configuration settings to the /usr/local/etc/clamd.conf file. This file won't get use much, since we aren't going be using the daemonized version of ClamAV, but it does get accessed occasionally by other processes.

vi /usr/local/etc/clamd.conf

"Example" - needs be commented out. If it is not, make sure that it is commented out (#)
"LogFile" - should be uncommented and set to /var/log/clamav/clamd.log
"LogTime" - should be uncommmented.
"LogSyslog" - should be uncommented.
"User" - should be uncommented and set to qscand

"ScanMail" - should be uncommented.

vi /usr/local/etc/freshclam.conf

"Example" - needs be commented out. If it is not, make sure that it is commented out (#)
"DatabaseDirectory" - should be uncommented and set to /usr/local/share/clamav

vi /usr/local/etc/rc.d/clamd.sh

#!/bin/sh

FOO_BIN=/usr/local/sbin/clamd
test -x $FOO_BIN || exit 5

case "$1" in
start)
echo "Starting `$FOO_BIN -V`"
$FOO_BIN

;;
stop)
echo "Shutting down `$FOO_BIN -V`"
killall $FOO_BIN

;;
restart)
$0 stop
$0 start

;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac

chmod 755 /usr/local/etc/rc.d/clamd.sh

/usr/local/etc/rc.d/clamd.sh start

Ok, Clam AV is now installed, but let's go ahead and set it up so that it will auto-update every night with the latest virus definitions! First we will want to set up the proper logging for the updater....

/usr/local/bin/freshclam -l /var/log/clamav/clam-update.log

If the server is able to get updates, you should see an output similar to this:

[root@crescent clamav]# freshclam -l /var/log/clamav/clamav-update.log
ClamAV update process started at Sun Oct 24 23:36:22 2004
main.cvd is up to date (version: 27, sigs: 23982, f-level: 2, builder: tomek)
daily.cvd is up to date (version: 549, sigs: 1583, f-level: 3, builder: ccordes)

Woohoo! You're updated with the latest virus definiations from the Clam database!

Now we just set a crontab to run every night, which will run the auto-update procedure! In the example below, I've set mine to run every day at 1:40 AM. The odd run time came reccomended from ClamAV, if you're wondering. Running freshclam at times other than the top of an hour reduces the load on their servers. so feel free to adjust the time to something even more offbeat, like 1:42 AM or something. The guys at ClamAV will thank you.

crontab -e (make sure you run this command as root)

40 1* * * /usr/local/bin/freshclam --quiet -l /var/log/clamav/clam-update.log

Now save your new crontab and exit. That's it! We're all done with Clam Anti Virus! You will now have a server-wide e-mail virus scanner that updates itself every night with the latest and greatest virus definitions!

Now we install SpamAssassin...

cd /downloads/qmailrocks

Install most current version of SpamAssassin using the pkg_add utility...

pkg_add -r Mail-SpamAssassin

If you are unable to getch SpamAssassin in the above command, I've included a copy of the package in the qmailrocks bundle. I'm so nice.

pkg_add p5-Mail-SpamAssassin-3.0.1_2.tgz

Note: Alternatively, if you're a source junkie, I've included a tarball of Spamassassin 3.01 in the qmailrocks bundle.

SpamAssassin is now installed, so let's configure it...

cd /usr/local/etc/mail/spamassassin

cp local.cf.sample local.cf

vi local.cf

Make sure the following lines exist and are not commented out.

rewrite_subject 1
required_hits 5

Now save and exit out of the file.

And now we will configure the server to start SpamAssassin on boot:

vi /etc/rc.conf

Add the following line:

spamd_enable="YES"

Now save and exit out of the file.

Start up SpamAssassin:

/usr/local/etc/rc.d/sa-spamd.sh start

and check the status to make sure it's running:

/usr/local/etc/rc.d/sa-spamd.sh status

If spamd is runnign correctly, you should get an status output like this:

spamd is running as pid 65467 65470 65471 65472 65473 65474.

If all has gone well, both Spamassassin and Clam Anti Virus should now be installed and SpamAssassin should be running. With both of these programs installed, we can now install Qmail-Scanner.

Proceed to Part 15

 

 

Color Coded Qmail Installation Key
 
Regular Black Text 
 Qmail installation notes and summaries by the author. Me talking.
 
Bold Black Text 
 Commands to be run by you, the installer.
 
Bold Maroon Text 
 Special notes for Redhat 9 users.
 
Bold Red Text 
 Vital and/or critical information.
 
Regular/Bold Purple text 
 Denotes helpful tips and hints or hyperlinks.
 
Regular Orange Text 
 Command line output.
Cp

Regular green text 

 Denotes the contents of a file or script.
home | about | the installation | utilities | faq | contact | journal | mailing list | list archive | forum | links | donatemerchandise
modified
This mirror last modified: Thursday, August 9th, 2012 15:59:20 CEST
 
The Rocks Project