<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">
<channel>
    <title>freebsd.munk.me.uk - Spam</title>
    <link>http://freebsd.munk.me.uk/</link>
    <description>FreeBSD System Administration</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.5.2 - http://www.s9y.org/</generator>
    
    <image>
        <url>http://freebsd.munk.me.uk/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: freebsd.munk.me.uk - Spam - FreeBSD System Administration</title>
        <link>http://freebsd.munk.me.uk/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Installing Exim, SASLAuthd, ClamAV and SpamAssassin on FreeBSD 6.2</title>
    <link>http://freebsd.munk.me.uk/archives/212-Installing-Exim,-SASLAuthd,-ClamAV-and-SpamAssassin-on-FreeBSD-6.2.html</link>
            <category>Email</category>
            <category>Ports</category>
            <category>Security</category>
            <category>Spam</category>
    
    <comments>http://freebsd.munk.me.uk/archives/212-Installing-Exim,-SASLAuthd,-ClamAV-and-SpamAssassin-on-FreeBSD-6.2.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=212</wfw:comment>

    <slash:comments>13</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=212</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    &lt;strong&gt;Introduction&lt;/strong&gt;&lt;br /&gt;
This article describes the steps necessary to install and configure Exim on FreeBSD 6.2 with support for the following:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li/&gt;authenticated SMTP (asmtp) using SASLAuthd&lt;br /&gt;
&lt;li/&gt;spam detection and quarantine using SpamAssassin&lt;br /&gt;
&lt;li/&gt;malware detection and quarantine using ClamAV&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
Each of the required &#039;dependencies&#039; or components will be installed and configured, Exim will be installed and configured and finally we will test to check each component is working as required.&lt;br /&gt;
&lt;br /&gt;
With regards to spam and malware scanning, the system described will quarantine any files/messages that it finds classified as spam or malware.  In this way the quarantined files can be checked over by the admin at a later date and various stats gathering can be done if required.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Installing and Configuring SASLAuthd&lt;/strong&gt;&lt;br /&gt;
SASLAuthd is an authentication daemon that can handle authentication requests from 3rd party applications such as Exim - generally for any application that can&#039;t directly access a system password database because of permission restrictions.  In this case running Exim MTA as &#039;root&#039; is a potential security risk, so exim runs as the &#039;mailnull&#039; user on FreeBSD.  Unfortunately this means Exim can&#039;t easily read the system password database to authenticate users who want to send mail via the server, which is where SASLAuthd comes in.  Any requests for authentication with Exim are passed on to the SASLAuthd daemon which will then verify whether the user credentials are valid - if so, the email is delivered, if not, it&#039;s rejected.&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li/&gt;Install SASLAuthd from the FreeBSD ports tree:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/root#&amp;#160;cd&amp;#160;/usr/ports/security/cyrus-sasl2-saslauthd/&lt;br /&gt;
root@win&amp;#160;/usr/ports/security/cyrus-sasl2-saslauthd#&amp;#160;make&amp;#160;install&lt;br /&gt;
...&lt;br /&gt;
root@win&amp;#160;/usr/ports/security/cyrus-sasl2-saslauthd#&amp;#160;rehash&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Configure SASLAuthd to run at boot.&lt;br /&gt;
&lt;br /&gt;
Edit /etc/rc.conf to include the following:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;saslauthd_enable=&quot;YES&quot;&lt;br /&gt;
saslauthd_flags=&quot;-a&amp;#160;getpwent&quot;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt;&lt;br /&gt;
SASLAuthd will run using the &#039;getpwent&#039; authentication mechanism with the flag above.  This method uses the passwd file directly instead of using other means like kerberos or PAM.  If you require another method, check the manpage for saslauthd.&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Start the SASLAuthd daemon running:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/usr/ports/security/cyrus-sasl2-saslauthd#&amp;#160;cd&amp;#160;/usr/local/etc/rc.d&lt;br /&gt;
root@win&amp;#160;/usr/local/etc/rc.d#&amp;#160;./saslauthd&amp;#160;start&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;(Optional) Test the SASLAuthd daemon:&lt;br /&gt;
&lt;br /&gt;
Substitute &#039;user&#039; and &#039;pass&#039; for the username and password of a user&lt;br /&gt;
account on your system:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/usr/local/etc/rc.d#&amp;#160;testsaslauthd&amp;#160;-u&amp;#160;user&amp;#160;-p&amp;#160;pass&lt;br /&gt;
0&amp;#58;&amp;#160;OK&amp;#160;&quot;Success.&quot;&lt;/div&gt;&lt;br /&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Installing and Configuring SpamAssassin&lt;/strong&gt;&lt;br /&gt;
SpamAssassin (SA) is one solution to the problem of spam.  SA can run as a daemon (spamd) in the background and accept requests from an MTA such as Exim to check whether an email message should be classified as spam.&lt;br /&gt;
&lt;br /&gt;
Spamd looks at the message and checks for various factors that make the message more or less likely to be spam and assigns the message a score based on what it finds.  Spamd will then reply to the MTA, telling it the spam score that it gave that message.  The MTA can then decide - based on that score - whether to accept/reject the message - or in the case of this guide whether to instead quarantine the message.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li/&gt;Install SA from the FreeBSD ports.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt;&lt;br /&gt;
There are various installation options you can choose when installing SA which you should see when you first run &#039;make install&#039; in the SA port directory.  To see the options after already configuring them you can run &#039;make config&#039;.&lt;br /&gt;
&lt;br /&gt;
In turn, each of SA&#039;s dependencies may also have options you can configure at install time.&lt;br /&gt;
&lt;br /&gt;
To write this guide I&#039;m only using the single option &#039;AS_ROOT&#039; in the SA install configuation and for the other items  generally just choose the&lt;br /&gt;
defaults.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/root#&amp;#160;cd&amp;#160;/usr/ports/mail/p5-Mail-SpamAssassin/&lt;br /&gt;
root@win&amp;#160;/usr/ports/mail/p5-Mail-SpamAssassin#&amp;#160;make&amp;#160;install&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Once complete, you should see:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;_&amp;#160;&amp;#160;_____&amp;#160;_____&amp;#160;_____&amp;#160;_&amp;#160;&amp;#160;&amp;#160;_&amp;#160;_____&amp;#160;___&amp;#160;___&amp;#160;&amp;#160;_&amp;#160;&amp;#160;&amp;#160;_&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/&amp;#160;\|_&amp;#160;&amp;#160;&amp;#160;_|_&amp;#160;&amp;#160;&amp;#160;_|&amp;#160;____|&amp;#160;\&amp;#160;|&amp;#160;|_&amp;#160;&amp;#160;&amp;#160;_|_&amp;#160;_/&amp;#160;_&amp;#160;\|&amp;#160;\&amp;#160;|&amp;#160;|&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/&amp;#160;_&amp;#160;\&amp;#160;|&amp;#160;|&amp;#160;&amp;#160;&amp;#160;|&amp;#160;|&amp;#160;|&amp;#160;&amp;#160;_|&amp;#160;|&amp;#160;&amp;#160;\|&amp;#160;|&amp;#160;|&amp;#160;|&amp;#160;&amp;#160;|&amp;#160;|&amp;#160;|&amp;#160;|&amp;#160;|&amp;#160;&amp;#160;\|&amp;#160;|&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/&amp;#160;___&amp;#160;\|&amp;#160;|&amp;#160;&amp;#160;&amp;#160;|&amp;#160;|&amp;#160;|&amp;#160;|___|&amp;#160;|\&amp;#160;&amp;#160;|&amp;#160;|&amp;#160;|&amp;#160;&amp;#160;|&amp;#160;|&amp;#160;|_|&amp;#160;|&amp;#160;|\&amp;#160;&amp;#160;|&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/_/&amp;#160;&amp;#160;&amp;#160;\_\_|&amp;#160;&amp;#160;&amp;#160;|_|&amp;#160;|_____|_|&amp;#160;\_|&amp;#160;|_|&amp;#160;|___\___/|_|&amp;#160;\_|&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;See&amp;#160;/usr/local/share/doc/p5-Mail-SpamAssassin/INSTALL,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;and&amp;#160;/usr/local/share/doc/p5-Mail-SpamAssassin/UPGRADE,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;or&amp;#160;http&amp;#58;//spamassassin.org/dist/INSTALL&amp;#160;and&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;http&amp;#58;//spamassassin.org/dist/UPGRADE&amp;#160;BEFORE&amp;#160;enabling&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;this&amp;#160;version&amp;#160;of&amp;#160;SpamAssassin&amp;#160;for&amp;#160;important&amp;#160;information&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;regarding&amp;#160;changes&amp;#160;in&amp;#160;this&amp;#160;version.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
It&#039;s a good idea to read the files listed in the banner above.  SA has a large number of options that can be configured; a good place to start configuring options on FreeBSD is in /usr/local/etc/mail/spamassassin/.&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Configure SA to run at boot.&lt;br /&gt;
&lt;br /&gt;
Edit /etc/rc.conf to include the following:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;spamd_enable=&quot;YES&quot;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Start SA spamd.&lt;br /&gt;
&lt;br /&gt;
We can now go on to actually start spamd running as a daemon and verify spamd started ok:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/root#&amp;#160;cd&amp;#160;/usr/local/etc/rc.d&lt;br /&gt;
root@win&amp;#160;/usr/local/etc/rc.d#&amp;#160;rehash&lt;br /&gt;
root@win&amp;#160;/usr/local/etc/rc.d#&amp;#160;./sa&lt;br /&gt;
sa-spamd&amp;#42;&amp;#160;&amp;#160;&amp;#160;saslauthd&amp;#42;&lt;br /&gt;
root@win&amp;#160;/usr/local/etc/rc.d#&amp;#160;./sa-spamd&amp;#160;start&lt;br /&gt;
Starting&amp;#160;spamd.&lt;br /&gt;
munk@win&amp;#160;/usr/local/etc/rc.d#&amp;#160;./sa-spamd&amp;#160;status&lt;br /&gt;
spamd&amp;#160;is&amp;#160;running&amp;#160;as&amp;#160;pid&amp;#160;754.&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This tells us spamd is running ok in the background.&lt;br /&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Installing and Configuring ClamAV&lt;/strong&gt;&lt;br /&gt;
ClamAV is an anti-virus suite and includes a daemon clamd (runs in the background to check for requests to test for virii), another daemon freshclam (updates the virus definition database) and a couple of clients to run on the commandline if you need them for local virus scanning.&lt;br /&gt;
&lt;br /&gt;
Exim will send requests to the clamd server in much the same was as spamd does - if clamd classifies a message as containing a virus, Exim will reject delivery of the message and instaed quarantine it.&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li/&gt;Install ClamAV from the FreeBSD ports tree:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/root#&amp;#160;cd&amp;#160;/usr/ports/security/clamav&lt;br /&gt;
root@win&amp;#160;/usr/ports/security/clamav#&amp;#160;make&amp;#160;install&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Configure ClamAV to start at boot time.&lt;br /&gt;
&lt;br /&gt;
Edit /etc/rc.conf to include:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;clamav_clamd_enable=&quot;YES&quot;&lt;br /&gt;
clamav_freshclam_enable=&quot;YES&quot;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Configure clamd.&lt;br /&gt;
&lt;br /&gt;
Edit /usr/local/etc/clamd.conf to include the following:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;LogFile&amp;#160;/var/log/clamav/clamd.log&lt;br /&gt;
PidFile&amp;#160;/var/run/clamav/clamd.pid&lt;br /&gt;
DatabaseDirectory&amp;#160;/var/db/clamav&lt;br /&gt;
LocalSocket&amp;#160;/var/run/clamav/clamd&lt;br /&gt;
FixStaleSocket&lt;br /&gt;
User&amp;#160;clamav&lt;br /&gt;
AllowSupplementaryGroups&lt;br /&gt;
ScanMail&lt;br /&gt;
ScanArchive&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Start clamd and freshclam.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/root#&amp;#160;cd&amp;#160;/usr/local/etc/rc.d&lt;br /&gt;
root@win&amp;#160;/usr/local/etc/rc.d#&amp;#160;./clamav-clamd&amp;#160;start&lt;br /&gt;
Starting&amp;#160;clamav_clamd.&lt;br /&gt;
root@win&amp;#160;/usr/local/etc/rc.d#&amp;#160;./clamav-freshclam&amp;#160;start&lt;br /&gt;
Starting&amp;#160;clamav_freshclam.&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Note:&lt;/strong&gt;&lt;br /&gt;
You may see the following message on first running clamd:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;LibClamAV&amp;#160;Warning&amp;#58;&amp;#160;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&lt;br /&gt;
LibClamAV&amp;#160;Warning&amp;#58;&amp;#160;&amp;#42;&amp;#42;&amp;#42;&amp;#160;&amp;#160;The&amp;#160;virus&amp;#160;database&amp;#160;is&amp;#160;older&amp;#160;than&amp;#160;7&amp;#160;days.&amp;#160;&amp;#160;&amp;#42;&amp;#42;&amp;#42;&lt;br /&gt;
LibClamAV&amp;#160;Warning&amp;#58;&amp;#160;&amp;#42;&amp;#42;&amp;#42;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Please&amp;#160;update&amp;#160;it&amp;#160;IMMEDIATELY!&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;&amp;#42;&amp;#42;&lt;br /&gt;
LibClamAV&amp;#160;Warning&amp;#58;&amp;#160;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#42;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
As long as you&#039;re running freshclam, you can safely ignore this message.  Freshclam should update your definitions automatically.  Be sure to configure freshclam to update the virus definitions regularly.&lt;br /&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
ClamAV should be configured now and ready to accept request to check for malware from the Exim MTA.&lt;br /&gt;
&lt;br /&gt;
We can now move on finally to install and configure Exim.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Installing and Configuring Exim&lt;/strong&gt;&lt;br /&gt;
Exim configuration can be very complicated.  This guide will only deal with the configuration of Exim so it accepts mail on a domain &#039;mail.example.com&#039;, scans the mail for malware/spam  - quarantining anything it finds as malware/spam and accepts authentication requests correctly.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Important:&lt;/strong&gt;&lt;br /&gt;
Ensure your mail server&#039;s DNS is configured correctly and preferably has a reverse DNS record (rDNS) set up.  Many mail servers will not deliver mail correctly to/from your mail server without rDNS.&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li/&gt;Install Exim from the FreeBSD ports tree:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&amp;#91;12&amp;#58;10&amp;#58;57&amp;#93;&amp;#160;root@win&amp;#160;/root#&amp;#160;cd&amp;#160;/usr/ports/mail/exim&lt;br /&gt;
&amp;#91;12&amp;#58;12&amp;#58;30&amp;#93;&amp;#160;root@win&amp;#160;/usr/ports/mail/exim#&amp;#160;&amp;#160;make&amp;#160;-DWITH_CONTENT_SCAN&amp;#160;-DWITH_SASLAUTHD&amp;#160;install&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Stop the Sendmail daemon if it&#039;s already running:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/root#&amp;#160;cd&amp;#160;/etc/rc.d&lt;br /&gt;
root@win&amp;#160;/etc/rc.d#&amp;#160;./sendmail&amp;#160;stop&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Configure Exim to run at boot time.&lt;br /&gt;
&lt;br /&gt;
Edit /etc/rc.conf to include:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;sendmail_enable=&quot;NO&quot;&lt;br /&gt;
sendmail_submit_enable=&quot;NO&quot;&lt;br /&gt;
sendmail_outbound_enable=&quot;NO&quot;&lt;br /&gt;
sendmail_msp_queue_enable=&quot;NO&quot;&lt;br /&gt;
exim_enable=&quot;YES&quot;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This has the effect of disabling sendmail at boot time - the default FreeBSD MTA - and running Exim instead.&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Configure mailer.conf to use Exim as the default MTA.&lt;br /&gt;
&lt;br /&gt;
Edit /etc/mail/mailer.conf to read:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;sendmail&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/usr/local/sbin/exim&lt;br /&gt;
send-mail&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/usr/local/sbin/exim&lt;br /&gt;
mailq&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/usr/local/sbin/exim&amp;#160;-bp&lt;br /&gt;
newaliases&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/usr/bin/true&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This will allow any FreeBSD base system mail related commands to use Exim instead of Sendmail.&lt;br /&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Configuring Exim&lt;/strong&gt;&lt;br /&gt;
We now move on to configuring Exim.&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Set the primary hostname.&lt;br /&gt;
&lt;br /&gt;
Edit /usr/local/etc/exim/configure.&lt;br /&gt;
&lt;br /&gt;
Find and edit the &#039;primary_hostname&#039; line for your domain:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;primary_hostname&amp;#160;=&amp;#160;example.com&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This configures Exim to accept mail primarily for the &#039;example.com&#039; domain - ie foobar@example.com.&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Find and edit the following lines to read:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;av_scanner&amp;#160;=&amp;#160;clamd&amp;#58;/var/run/clamav/clamd&lt;br /&gt;
spamd_address&amp;#160;=&amp;#160;127.0.0.1&amp;#160;783&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Configure the malware and spam Access Control Lists (ACLs).&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;How malware/spam checking works in this system:&lt;/strong&gt;&lt;br /&gt;
We add a check in the acl_check_data ACL for spam and malware.  Exim will request each email is checked for spam/malware by the relevant daemon - spamd for spam, clamd for malware.  If the message is classified as spam/malware by the relevant daemons, Exim will add a header to the message &#039;X-Quarantine-Me-Spam&#039; (similar for malware).&lt;br /&gt;
&lt;br /&gt;
Later on when it comes to actually delivering (termed &#039;routing&#039; in Exim terminology), we add two routers to test for the existence of the headers that are added in the acl_check_data ACL if a message is found to be spam/malware.  If the headers are found by the malware/spam routers, the message is not delivered but instead copied to a quarantine location on disk.&lt;br /&gt;
&lt;br /&gt;
This quarantine location can then be checked later by an admin to check if anything is amiss - ie regular non spam/malware mail that should really have been delivered.&lt;br /&gt;
&lt;br /&gt;
Once you&#039;re satisfied the configuration is working as it should - ie after a few months of operation - and not finding false positives, you can change the malware/spam acl checks to just deny instead of adding the quarantine headers.  Having said that, I still opt to just quarantine malware/spam and remove it at a later date.&lt;br /&gt;
&lt;br /&gt;
On to configuring the data ACL:&lt;br /&gt;
&lt;br /&gt;
Modify the acl_check_data ACL to read/include:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;acl_check_data&amp;#58;&lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;#&amp;#160;Deny&amp;#160;if&amp;#160;the&amp;#160;message&amp;#160;contains&amp;#160;a&amp;#160;virus.&amp;#160;Before&amp;#160;enabling&amp;#160;this&amp;#160;check,&amp;#160;you&lt;br /&gt;
&amp;#160;&amp;#160;#&amp;#160;must&amp;#160;install&amp;#160;a&amp;#160;virus&amp;#160;scanner&amp;#160;and&amp;#160;set&amp;#160;the&amp;#160;av_scanner&amp;#160;option&amp;#160;above.&lt;br /&gt;
&amp;#160;&amp;#160;#&lt;br /&gt;
&amp;#160;&amp;#160;#&amp;#160;defer_ok&amp;#160;-&amp;#160;pass&amp;#160;this&amp;#160;message&amp;#160;if&amp;#160;scanner&amp;#160;is&amp;#160;down&amp;#160;etc&amp;#58;&lt;br /&gt;
&amp;#160;&amp;#160;warn&amp;#160;&amp;#160;message&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;X-Quarantine-Me-Malware&amp;#58;&amp;#160;$malware_name&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;log_message&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;malware&amp;#58;&amp;#160;$malware_name&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;demime&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;&amp;#42;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;malware&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;&amp;#42;/defer_ok&lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;#&amp;#160;Add&amp;#160;headers&amp;#160;to&amp;#160;a&amp;#160;message&amp;#160;if&amp;#160;it&amp;#160;is&amp;#160;judged&amp;#160;to&amp;#160;be&amp;#160;spam.&amp;#160;Before&amp;#160;enabling&amp;#160;this,&lt;br /&gt;
&amp;#160;&amp;#160;#&amp;#160;you&amp;#160;must&amp;#160;install&amp;#160;SpamAssassin.&amp;#160;You&amp;#160;may&amp;#160;also&amp;#160;need&amp;#160;to&amp;#160;set&amp;#160;the&amp;#160;spamd_address&lt;br /&gt;
&amp;#160;&amp;#160;#&amp;#160;option&amp;#160;above.&lt;br /&gt;
&amp;#160;&amp;#160;#&lt;br /&gt;
&amp;#160;&amp;#160;warn&amp;#160;&amp;#160;&amp;#160;&amp;#160;message&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;X-Quarantine-Me-Spam&amp;#58;&amp;#160;SA&amp;#160;score&amp;#160;$spam_score\n\&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;X-SA-Report&amp;#58;&amp;#160;$spam_report&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;log_message&amp;#160;&amp;#160;&amp;#160;=&amp;#160;Spam&amp;#160;score&amp;#160;$spam_score&amp;#160;&amp;#62;&amp;#160;5&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;spam&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;spamd/defer_ok&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;condition&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;${if&amp;#160;&amp;#62;{$spam_score_int}{50}{1}{0}}&lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;#&amp;#160;Accept&amp;#160;the&amp;#160;message.&lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;accept&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;At the top of the routers section&lt;/strong&gt;, modify to read/include:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;begin&amp;#160;routers&lt;br /&gt;
&lt;br /&gt;
check_malware&amp;#58;&lt;br /&gt;
&amp;#160;&amp;#160;driver&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;redirect&lt;br /&gt;
&amp;#160;&amp;#160;condition&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;${if&amp;#160;def&amp;#58;h_X-Quarantine-Me-Malware&amp;#58;&amp;#160;{1}{0}}&lt;br /&gt;
&amp;#160;&amp;#160;headers_add&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;X-Quarantined-Malware&amp;#58;&amp;#160;$h_X-Quarantine-Me-Malware&amp;#58;&lt;br /&gt;
&amp;#160;&amp;#160;headers_remove&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;X-Quarantine-Me-Malware&lt;br /&gt;
&amp;#160;&amp;#160;data&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;/var/quarantine/malware/malware.$tod_logfile&lt;br /&gt;
&amp;#160;&amp;#160;file_transport&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;address_file&lt;br /&gt;
&lt;br /&gt;
check_spam&amp;#58;&lt;br /&gt;
&amp;#160;&amp;#160;driver&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;redirect&lt;br /&gt;
&amp;#160;&amp;#160;condition&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;${if&amp;#160;def&amp;#58;h_X-Quarantine-Me-Spam&amp;#58;&amp;#160;{1}{0}}&lt;br /&gt;
&amp;#160;&amp;#160;headers_add&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;X-Quarantined-Spam&amp;#58;&amp;#160;$h_X-Quarantine-Me-Spam&amp;#58;&lt;br /&gt;
&amp;#160;&amp;#160;headers_remove&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;X-Quarantine-Me-Spam&lt;br /&gt;
&amp;#160;&amp;#160;data&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;/var/quarantine/spam/spam.$tod_logfile&lt;br /&gt;
&amp;#160;&amp;#160;file_transport&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#160;address_file&lt;br /&gt;
&lt;br /&gt;
	no_more&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Modify the authenticators section to read:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;begin&amp;#160;authenticators&lt;br /&gt;
plain&amp;#58;&lt;br /&gt;
	driver&amp;#160;=&amp;#160;plaintext&lt;br /&gt;
	public_name&amp;#160;=&amp;#160;PLAIN&lt;br /&gt;
	server_condition&amp;#160;=&amp;#160;${if&amp;#160;saslauthd{{$2}{$3}}{1}{0}}&lt;br /&gt;
&lt;br /&gt;
login&amp;#58;&lt;br /&gt;
	driver&amp;#160;=&amp;#160;plaintext&lt;br /&gt;
	public_name&amp;#160;=&amp;#160;LOGIN&lt;br /&gt;
	server_prompts&amp;#160;=&amp;#160;&quot;Username&amp;#58;&amp;#58;&amp;#160;&amp;#58;&amp;#160;Password&amp;#58;&amp;#58;&quot;&lt;br /&gt;
	server_condition&amp;#160;=&amp;#160;${if&amp;#160;saslauthd{{$1}{$2}}{1}{0}}&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Save the /usr/local/etc/exim/configuration file.&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Create the quarantine directories and change ownership to mailnull:mail:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/root#&amp;#160;mkdir&amp;#160;-p&amp;#160;/var/quarantine/{malware,spam}&lt;br /&gt;
root@win&amp;#160;/root#&amp;#160;chown&amp;#160;mailnull&amp;#58;mail&amp;#160;/var/quarantine/{malware,spam}&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Restart Exim to suck in the new config options:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/root#&amp;#160;/usr/local/etc/rc.d/exim&amp;#160;restart&lt;br /&gt;
Stopping&amp;#160;exim.&lt;br /&gt;
Starting&amp;#160;exim.&lt;/div&gt;&lt;br /&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
Exim should now be set to check for malware/spam and to authenticate users.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Testing Exim configuration&lt;/strong&gt;&lt;br /&gt;
Finally we can move on to test that our config works correctly for spam/malware checking and for authenticating users.&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li/&gt;Testing Exim&#039;s malware/spam scanning.&lt;br /&gt;
&lt;br /&gt;
The easiest option is to send an email to your mailserver with specially crafted malware/spam signatures included in the body of the message.  When spamd/clamd see these signature strings in the body of the messages, they should classify the message as spam/malware and Exim in turn will quarantine the messages.&lt;br /&gt;
&lt;br /&gt;
The official EICAR malware/virus testing signature is as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;X5O%@AP&amp;#91;4\PZX54&amp;#40;P^&amp;#41;7CC&amp;#41;7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILEspamcH+H&amp;#42;&lt;/div&gt;&lt;br /&gt;
See here for the official string:&lt;br /&gt;
&lt;a href=&quot;http://www.eicar.org/anti_virus_test_file.htm&quot;  title=&quot;http://www.eicar.org/anti_virus_test_file.htm&quot;&gt;&lt;br /&gt;
http://www.eicar.org/anti_virus_test_file.htm&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The official GTUBE spam testing signature is as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;XJS&amp;#42;C4JDBQADN1.NSBN3&amp;#42;2IDNEN&amp;#42;GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL&amp;#42;C.34X&lt;/div&gt;&lt;br /&gt;
See here for the official string:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://spamassassin.apache.org/gtube/&quot;  title=&quot;http://spamassassin.apache.org/gtube/&quot;&gt;http://spamassassin.apache.org/gtube/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Note:&lt;/strong&gt;&lt;br /&gt;
Another option for testing spam/malware scanning is to run exim from the commandline using the command &#039;exim -bh 127.0.0.1&#039;.  This will run an SMTP session from the commandline (think telnet) and allow you to inject your own specially crafted message using the signatures above.  This requires you enter a valid SMTP session, something like:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;HELO&amp;#160;example.com&lt;br /&gt;
MAIL&amp;#160;FROM&amp;#58;foo@example.com&lt;br /&gt;
RCPT&amp;#160;TO&amp;#58;foo@example.com&lt;br /&gt;
DATA&lt;br /&gt;
X5O%@AP&amp;#91;4\PZX54&amp;#40;P^&amp;#41;7CC&amp;#41;7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILEspamcH+H&amp;#42;&lt;br /&gt;
.&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This would simulate the injection of a mail message with a virus in it and in &#039;exim -bh&#039; mode you can see a lot of useful debugging info to verify everything works ok.&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Testing Exim&#039;s Authentication configuration.&lt;br /&gt;
&lt;br /&gt;
We can now test that ASMTP is working.  For this you can either run exim in one of it&#039;s many excellent debugging modes or you can simply configure a remote email client to use ASMTP.  This guide will use the commandline to test ASMTP.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Important:&lt;/strong&gt;&lt;br /&gt;
Before attempting this method please read &lt;a href=&quot;http://www.exim.org/exim-html-4.10/doc/html/spec_32.html#IX1630&quot; target=&quot;_blank&quot;&gt;the exim documentation on how ASMTP works&lt;/a&gt;.  The following assumes you have read and understood that text.&lt;br /&gt;
&lt;br /&gt;
First create a simple perl script called &#039;encode&#039; in /usr/local/etc/exim/ and make sure it is executable:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/usr/local/etc/exim#&amp;#160;cat&amp;#160;encode&lt;br /&gt;
#!/usr/bin/perl&lt;br /&gt;
use&amp;#160;MIME&amp;#58;&amp;#58;Base64;&lt;br /&gt;
printf&amp;#160;&amp;#40;&quot;%s&quot;,&amp;#160;encode_base64&amp;#40;eval&amp;#160;&quot;&quot;$ARGV&amp;#91;0&amp;#93;&quot;&quot;&amp;#41;&amp;#41;;&lt;br /&gt;
root@darkstar&amp;#160;/usr/local/etc/exim#&amp;#160;chmod&amp;#160;+x&amp;#160;encode&lt;br /&gt;
root@darkstar&amp;#160;/usr/local/etc/exim#&amp;#160;ls&amp;#160;-al&amp;#160;encode&lt;br /&gt;
-rwxr-xr-x&amp;#160;&amp;#160;1&amp;#160;root&amp;#160;&amp;#160;wheel&amp;#160;&amp;#160;85&amp;#160;Apr&amp;#160;23&amp;#160;12&amp;#58;25&amp;#160;encode&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Now decide which user account on your server you wish to test ASMTP with.  It must be an account you know the password for obviously.  I created an account called &#039;dummy&#039; and set the password to &#039;dummy&#039; as well - if you do this remember to remove the account or disable it as soon as you&#039;ve finished testing.&lt;br /&gt;
&lt;br /&gt;
Encode the user:password pair into base64 MIME using the &#039;encode&#039; script we created above:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@darkstar&amp;#160;/usr/local/etc/exim#&amp;#160;./encode&amp;#160;&quot;\0dummy\0dummy&quot;&lt;br /&gt;
AGR1bW15AGR1bW15&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Now enter into Exim&#039;s fake SMTP session command-line mode and just for good measure do it in authentication debug mode as well:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@win&amp;#160;/root#&amp;#160;&amp;#160;exim&amp;#160;-d+auth&amp;#160;-bh&amp;#160;127.0.0.1&lt;br /&gt;
Exim&amp;#160;version&amp;#160;4.66&amp;#160;&amp;#40;FreeBSD&amp;#160;6.1&amp;#41;&amp;#160;uid=0&amp;#160;gid=0&amp;#160;pid=3056&amp;#160;D=fbb95cfd&lt;br /&gt;
Probably&amp;#160;Berkeley&amp;#160;DB&amp;#160;version&amp;#160;1.8x&amp;#160;&amp;#40;native&amp;#160;mode&amp;#41;&lt;br /&gt;
Support&amp;#160;for&amp;#58;&amp;#160;crypteq&amp;#160;iconv&amp;#40;&amp;#41;&amp;#160;IPv6&amp;#160;use_setclassresources&amp;#160;PAM&amp;#160;Perl&amp;#160;OpenSSL&amp;#160;Content_Scanning&amp;#160;Old_Demime&lt;br /&gt;
Lookups&amp;#58;&amp;#160;lsearch&amp;#160;wildlsearch&amp;#160;nwildlsearch&amp;#160;iplsearch&amp;#160;cdb&amp;#160;dbm&amp;#160;dbmnz&amp;#160;dnsdb&amp;#160;dsearch&amp;#160;nis&amp;#160;nis0&amp;#160;passwd&lt;br /&gt;
Authenticators&amp;#58;&amp;#160;cram_md5&amp;#160;plaintext&amp;#160;spa&lt;br /&gt;
Routers&amp;#58;&amp;#160;accept&amp;#160;dnslookup&amp;#160;ipliteral&amp;#160;manualroute&amp;#160;queryprogram&amp;#160;redirect&lt;br /&gt;
Transports&amp;#58;&amp;#160;appendfile/maildir/mailstore/mbx&amp;#160;autoreply&amp;#160;lmtp&amp;#160;pipe&amp;#160;smtp&lt;br /&gt;
Fixed&amp;#160;never_users&amp;#58;&amp;#160;0&lt;br /&gt;
Size&amp;#160;of&amp;#160;off_t&amp;#58;&amp;#160;8&lt;br /&gt;
changed&amp;#160;uid/gid&amp;#58;&amp;#160;forcing&amp;#160;real&amp;#160;=&amp;#160;effective&lt;br /&gt;
&amp;#160;&amp;#160;uid=0&amp;#160;gid=0&amp;#160;pid=3056&lt;br /&gt;
&amp;#160;&amp;#160;auxiliary&amp;#160;group&amp;#160;list&amp;#58;&amp;#160;0&lt;br /&gt;
seeking&amp;#160;password&amp;#160;data&amp;#160;for&amp;#160;user&amp;#160;&quot;mailnull&quot;&amp;#58;&amp;#160;using&amp;#160;cached&amp;#160;result&lt;br /&gt;
getpwnam&amp;#40;&amp;#41;&amp;#160;succeeded&amp;#160;uid=26&amp;#160;gid=26&lt;br /&gt;
seeking&amp;#160;password&amp;#160;data&amp;#160;for&amp;#160;user&amp;#160;&quot;root&quot;&amp;#58;&amp;#160;cache&amp;#160;not&amp;#160;available&lt;br /&gt;
getpwnam&amp;#40;&amp;#41;&amp;#160;succeeded&amp;#160;uid=0&amp;#160;gid=0&lt;br /&gt;
configuration&amp;#160;file&amp;#160;is&amp;#160;/usr/local/etc/exim/configure&lt;br /&gt;
log&amp;#160;selectors&amp;#160;=&amp;#160;00000ffc&amp;#160;00089001&lt;br /&gt;
trusted&amp;#160;user&lt;br /&gt;
admin&amp;#160;user&lt;br /&gt;
changed&amp;#160;uid/gid&amp;#58;&amp;#160;privilege&amp;#160;not&amp;#160;needed&lt;br /&gt;
&amp;#160;&amp;#160;uid=26&amp;#160;gid=6&amp;#160;pid=3056&lt;br /&gt;
&amp;#160;&amp;#160;auxiliary&amp;#160;group&amp;#160;list&amp;#58;&amp;#160;6&amp;#160;6&lt;br /&gt;
seeking&amp;#160;password&amp;#160;data&amp;#160;for&amp;#160;user&amp;#160;&quot;mailnull&quot;&amp;#58;&amp;#160;cache&amp;#160;not&amp;#160;available&lt;br /&gt;
getpwnam&amp;#40;&amp;#41;&amp;#160;succeeded&amp;#160;uid=26&amp;#160;gid=26&lt;br /&gt;
originator&amp;#58;&amp;#160;uid=0&amp;#160;gid=0&amp;#160;login=root&amp;#160;name=Charlie&amp;#160;Root&lt;br /&gt;
sender&amp;#160;address&amp;#160;=&amp;#160;root@win.munk.me.uk&lt;br /&gt;
sender_fullhost&amp;#160;=&amp;#160;&amp;#91;127.0.0.1&amp;#93;&lt;br /&gt;
sender_rcvhost&amp;#160;=&amp;#160;&amp;#91;127.0.0.1&amp;#93;&lt;br /&gt;
&lt;br /&gt;
&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#160;SMTP&amp;#160;testing&amp;#160;session&amp;#160;as&amp;#160;if&amp;#160;from&amp;#160;host&amp;#160;127.0.0.1&lt;br /&gt;
&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#160;but&amp;#160;without&amp;#160;any&amp;#160;ident&amp;#160;&amp;#40;RFC&amp;#160;1413&amp;#41;&amp;#160;callback.&lt;br /&gt;
&amp;#42;&amp;#42;&amp;#42;&amp;#42;&amp;#160;This&amp;#160;is&amp;#160;not&amp;#160;for&amp;#160;real!&lt;br /&gt;
&lt;br /&gt;
host&amp;#160;in&amp;#160;hosts_connection_nolog?&amp;#160;no&amp;#160;&amp;#40;option&amp;#160;unset&amp;#41;&lt;br /&gt;
LOG&amp;#58;&amp;#160;smtp_connection&amp;#160;MAIN&lt;br /&gt;
&amp;#160;&amp;#160;SMTP&amp;#160;connection&amp;#160;from&amp;#160;&amp;#91;127.0.0.1&amp;#93;&lt;br /&gt;
host&amp;#160;in&amp;#160;host_lookup?&amp;#160;yes&amp;#160;&amp;#40;matched&amp;#160;&quot;&amp;#42;&quot;&amp;#41;&lt;br /&gt;
looking&amp;#160;up&amp;#160;host&amp;#160;name&amp;#160;for&amp;#160;127.0.0.1&lt;br /&gt;
DNS&amp;#160;lookup&amp;#160;of&amp;#160;1.0.0.127.in-addr.arpa&amp;#160;&amp;#40;PTR&amp;#41;&amp;#160;succeeded&lt;br /&gt;
IP&amp;#160;address&amp;#160;lookup&amp;#160;yielded&amp;#160;localhost.munk.me.uk&lt;br /&gt;
gethostbyname2&amp;#160;looked&amp;#160;up&amp;#160;these&amp;#160;IP&amp;#160;addresses&amp;#58;&lt;br /&gt;
&amp;#160;&amp;#160;name=localhost.munk.me.uk&amp;#160;address=&amp;#58;&amp;#58;1&lt;br /&gt;
&amp;#160;&amp;#160;name=localhost.munk.me.uk&amp;#160;address=127.0.0.1&lt;br /&gt;
checking&amp;#160;addresses&amp;#160;for&amp;#160;localhost.munk.me.uk&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#58;&amp;#58;1&lt;br /&gt;
&amp;#160;&amp;#160;127.0.0.1&amp;#160;OK&lt;br /&gt;
sender_fullhost&amp;#160;=&amp;#160;localhost.munk.me.uk&amp;#160;&amp;#91;127.0.0.1&amp;#93;&lt;br /&gt;
sender_rcvhost&amp;#160;=&amp;#160;localhost.munk.me.uk&amp;#160;&amp;#40;&amp;#91;127.0.0.1&amp;#93;&amp;#41;&lt;br /&gt;
set_process_info&amp;#58;&amp;#160;&amp;#160;3056&amp;#160;handling&amp;#160;incoming&amp;#160;connection&amp;#160;from&amp;#160;localhost.munk.me.uk&amp;#160;&amp;#91;127.0.0.1&amp;#93;&lt;br /&gt;
host&amp;#160;in&amp;#160;host_reject_connection?&amp;#160;no&amp;#160;&amp;#40;option&amp;#160;unset&amp;#41;&lt;br /&gt;
host&amp;#160;in&amp;#160;sender_unqualified_hosts?&amp;#160;no&amp;#160;&amp;#40;option&amp;#160;unset&amp;#41;&lt;br /&gt;
host&amp;#160;in&amp;#160;recipient_unqualified_hosts?&amp;#160;no&amp;#160;&amp;#40;option&amp;#160;unset&amp;#41;&lt;br /&gt;
host&amp;#160;in&amp;#160;helo_verify_hosts?&amp;#160;no&amp;#160;&amp;#40;option&amp;#160;unset&amp;#41;&lt;br /&gt;
host&amp;#160;in&amp;#160;helo_try_verify_hosts?&amp;#160;no&amp;#160;&amp;#40;option&amp;#160;unset&amp;#41;&lt;br /&gt;
host&amp;#160;in&amp;#160;helo_accept_junk_hosts?&amp;#160;no&amp;#160;&amp;#40;option&amp;#160;unset&amp;#41;&lt;br /&gt;
SMTP&amp;#62;&amp;#62;&amp;#160;220&amp;#160;win.munk.me.uk&amp;#160;ESMTP&amp;#160;Exim&amp;#160;4.66&amp;#160;Wed,&amp;#160;17&amp;#160;Jan&amp;#160;2007&amp;#160;19&amp;#58;24&amp;#58;22&amp;#160;+0000&lt;br /&gt;
220&amp;#160;win.munk.me.uk&amp;#160;ESMTP&amp;#160;Exim&amp;#160;4.66&amp;#160;Wed,&amp;#160;17&amp;#160;Jan&amp;#160;2007&amp;#160;19&amp;#58;24&amp;#58;22&amp;#160;+0000&lt;br /&gt;
smtp_setup_msg&amp;#160;entered&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
When you get to this point you are ready to start an SMTP &#039;conversation&#039; with Exim.  First introduce yourself to Exim using the SMTP &#039;EHLO localhost&#039; command:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;EHLO&amp;#160;localhost&lt;br /&gt;
SMTP&amp;#60;&amp;#60;&amp;#160;EHLO&amp;#160;localhost&lt;br /&gt;
sender_fullhost&amp;#160;=&amp;#160;localhost.munk.me.uk&amp;#160;&amp;#40;localhost&amp;#41;&amp;#160;&amp;#91;127.0.0.1&amp;#93;&lt;br /&gt;
sender_rcvhost&amp;#160;=&amp;#160;localhost.munk.me.uk&amp;#160;&amp;#40;&amp;#91;127.0.0.1&amp;#93;&amp;#160;helo=localhost&amp;#41;&lt;br /&gt;
set_process_info&amp;#58;&amp;#160;&amp;#160;3103&amp;#160;handling&amp;#160;incoming&amp;#160;connection&amp;#160;from&amp;#160;localhost.munk.me.uk&amp;#160;&amp;#40;localhost&amp;#41;&amp;#160;&amp;#91;127.0.0.1&amp;#93;&lt;br /&gt;
host&amp;#160;in&amp;#160;pipelining_advertise_hosts?&amp;#160;yes&amp;#160;&amp;#40;matched&amp;#160;&quot;&amp;#42;&quot;&amp;#41;&lt;br /&gt;
host&amp;#160;in&amp;#160;auth_advertise_hosts?&amp;#160;yes&amp;#160;&amp;#40;matched&amp;#160;&quot;&amp;#42;&quot;&amp;#41;&lt;br /&gt;
host&amp;#160;in&amp;#160;tls_advertise_hosts?&amp;#160;no&amp;#160;&amp;#40;option&amp;#160;unset&amp;#41;&lt;br /&gt;
250-win.munk.me.uk&amp;#160;Hello&amp;#160;localhost.munk.me.uk&amp;#160;&amp;#91;127.0.0.1&amp;#93;&lt;br /&gt;
250-SIZE&amp;#160;52428800&lt;br /&gt;
250-PIPELINING&lt;br /&gt;
250-AUTH&amp;#160;PLAIN&amp;#160;LOGIN&lt;br /&gt;
250&amp;#160;HELP&lt;br /&gt;
SMTP&amp;#62;&amp;#62;&amp;#160;250-win.munk.me.uk&amp;#160;Hello&amp;#160;localhost.munk.me.uk&amp;#160;&amp;#91;127.0.0.1&amp;#93;&lt;br /&gt;
250-SIZE&amp;#160;52428800&lt;br /&gt;
250-PIPELINING&lt;br /&gt;
250-AUTH&amp;#160;PLAIN&amp;#160;LOGIN&lt;br /&gt;
250&amp;#160;HELP&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
In response to your &#039;EHLO localhost&#039; command, Exim returns more debug information but most importantly for us it also indicates what authentication options it offers in this line:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;250-AUTH&amp;#160;PLAIN&amp;#160;LOGIN&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This indicates that currently acceptable AUTH methods are PLAIN and LOGIN.&lt;br /&gt;
&lt;br /&gt;
We can then test the PLAIN login method using the &quot;\0dummy\0dummy&quot; user:password pair we encoded above:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;AUTH&amp;#160;PLAIN&amp;#160;AGR1bW15AGR1bW15&lt;br /&gt;
SMTP&amp;#60;&amp;#60;&amp;#160;AUTH&amp;#160;PLAIN&amp;#160;AGR1bW15AGR1bW15&lt;br /&gt;
Running&amp;#160;pwcheck&amp;#160;authentication&amp;#160;for&amp;#160;user&amp;#160;&quot;dummy&quot;&lt;br /&gt;
pwcheck&amp;#58;&amp;#160;success&amp;#160;&amp;#40;NULL&amp;#41;&lt;br /&gt;
plain&amp;#160;authenticator&amp;#58;&lt;br /&gt;
&amp;#160;&amp;#160;$1&amp;#160;=&lt;br /&gt;
&amp;#160;&amp;#160;$2&amp;#160;=&amp;#160;dummy&lt;br /&gt;
&amp;#160;&amp;#160;$3&amp;#160;=&amp;#160;dummy&lt;br /&gt;
expanded&amp;#160;string&amp;#58;&amp;#160;1&lt;br /&gt;
SMTP&amp;#62;&amp;#62;&amp;#160;235&amp;#160;Authentication&amp;#160;succeeded&lt;br /&gt;
235&amp;#160;Authentication&amp;#160;succeeded&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This indicates that authentication for &#039;dummy:dummy&#039; would succeed and mail would be relayed (pending further conditional checks by Exim).&lt;br /&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
So we now have a working Exim with support for spam/malware checking and authentication over SMTP. 
    </content:encoded>

    <pubDate>Wed, 17 Jan 2007 20:19:00 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/212-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Serendipity Spam Statistics</title>
    <link>http://freebsd.munk.me.uk/archives/170-Serendipity-Spam-Statistics.html</link>
            <category>ipfilter</category>
            <category>Perl</category>
            <category>Serendipity</category>
            <category>Spam</category>
    
    <comments>http://freebsd.munk.me.uk/archives/170-Serendipity-Spam-Statistics.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=170</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=170</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    I just downloaded this great looking &lt;a href=&quot;andreas.id.au/blog/archives/77-Akismet-Spam-Statistics.html&quot;  title=&quot;Spam Statistics Plugin&quot;&gt;spam statistics plugin for Serendipity from Andreas&lt;/a&gt;.  Unfortunately after installing it it didn&#039;t seem to work, so I got stuck in to see what was up.&lt;br /&gt;
&lt;br /&gt;
Turns out it only works when the &lt;a href=&quot;http://blog.s9y.org/archives/123-Spamblock-Improvements,-Part-II.html&quot;  title=&quot;Serendipity Spamblock Plugin&quot;&gt;spamblock plugin&lt;/a&gt; logs to the database, so I&#039;ll either look into making it work with log files or maybe think about adding something to the admin stats plugin if that&#039;s possible.  Or do neither given it&#039;s not uber important to me given I get a raft of info on the spam stats each night via a cron job.&lt;br /&gt;
&lt;br /&gt;
I have a cron job that checks various things spam related on a daily basis - checking for referer spam, quarantined files uploaded via PHP, mod_security log entries that need attention and finally checking for serendipity / weblog spam.  The situation with weblog spam had gotten so bad on the old domain munk.nu that I even ended up creating a script to convert spamblock log entries into firewall rules for ipf.  I&#039;m not kidding, at least 100 trackback spam entries per day through June and July - for the year 2006 so far there are nearly 9000 unique IPs dropping new trackback spam.&lt;br /&gt;
&lt;br /&gt;
What&#039;s annoying too is that even adding offending IPs to my firewall block list, each and every new day there would be another 100 new unique IP addresses spamming the blog.  No doubt this is a botnet - 100 new zombies found per day sounds like a professional organisation.&lt;br /&gt;
&lt;br /&gt;
Ho hum.  Anyway I&#039;ll add the &#039;log2ipf.pl&#039; perl script in the extended part of this article.  It&#039;s a perl script that&#039;s little more than an extended &#039;grep | sed&#039; which searches for text in a file and then reports how many results it found for each item.  In the default case using just &#039;log2ipf.pl somefile.log&#039; it searches for:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&quot;s9y&quot;=&amp;#62;qr/.&amp;#42;\&amp;#91;REJECTED&amp;#58;&amp;#160;&amp;#91;No&amp;#160;API-created&amp;#160;comments|Trackback&amp;#160;URL&amp;#160;invalid|Filtered&amp;#160;by&amp;#160;Akismet\.com&amp;#93;.&amp;#42;,&amp;#160;IP&amp;#160;&amp;#40;.&amp;#42;?&amp;#41;&amp;#93;.&amp;#42;/,&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
in this case it reports a list of IP addresses and how many times each IP address was &#039;caught&#039; trying to spam - but it could be modified to do anything.  For example I have another &#039;filter&#039; setup to see how many people use a google search to find pics on my server by searching for the term &#039;picasa.ini&#039;:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&quot;picasa&quot;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#62;qr/^.&amp;#42;?\s+&amp;#40;.&amp;#42;?&amp;#41;\s+.&amp;#42;%22index\+of%22\+%2F\+picasa\.ini.&amp;#42;/&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
so I can feed apache logfiles to log2ipf.pl using this commandline:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;;&amp;#160;log2ipf.pl&amp;#160;-l&amp;#160;picasa&amp;#160;/var/log/httpd/all/2006/07/&amp;#42;/&amp;#42;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;24.242.97.20&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1&lt;br /&gt;
&amp;#160;&amp;#160;67.141.28.129&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
telling me there was just 2 such searches during July 2006 (woo).  I seem to remember that search returning more than that at the time I wrote the filter though lol.  You get the idea anyway.&lt;br /&gt;
&lt;br /&gt;
To add a new &#039;filter&#039;, best thing to do is import a sample logfile line you want to produce a result, then customize the script %re variable to include your custom filter.  &lt;br /&gt;
&lt;br /&gt;
For example, say you wanted to search for auth log failures for SSH (this is actually done for you by the periodic utility on FreeBSD if you set it up in /etc/periodic.conf, but that&#039;s another article! - you could write something like this for the %re filter:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;my&amp;#160;%re=&amp;#40;&lt;br /&gt;
&quot;s9y&quot;=&amp;#62;qr/.&amp;#42;\&amp;#91;REJECTED&amp;#58;&amp;#160;&amp;#91;No&amp;#160;API-created&amp;#160;comments|Trackback&amp;#160;URL&amp;#160;invalid|Filtered&amp;#160;by&amp;#160;Akismet\.com&amp;#93;.&amp;#42;,&amp;#160;IP&amp;#160;&amp;#40;.&amp;#42;?&amp;#41;&amp;#93;.&amp;#42;/,&lt;br /&gt;
#Example&amp;#160;of&amp;#160;logfile&amp;#160;line&amp;#160;we&amp;#160;want&amp;#160;to&amp;#160;catch&amp;#58;&lt;br /&gt;
#&amp;#160;Aug&amp;#160;26&amp;#160;14&amp;#58;57&amp;#58;35&amp;#160;users&amp;#160;sshd&amp;#91;30136&amp;#93;&amp;#58;&amp;#160;Failed&amp;#160;password&amp;#160;for&amp;#160;root&amp;#160;from&amp;#160;211.48.62.102&amp;#160;port&amp;#160;50706&amp;#160;ssh2&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&quot;ssh&quot;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#62;qr/.&amp;#42;Failed&amp;#160;password&amp;#160;for&amp;#160;.&amp;#42;&amp;#160;from&amp;#160;&amp;#40;.&amp;#42;?&amp;#41;&amp;#160;.&amp;#42;/,&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&quot;picasa&quot;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#62;qr/^.&amp;#42;?\s+&amp;#40;.&amp;#42;?&amp;#41;\s+.&amp;#42;%22index\+of%22\+%2F\+picasa\.ini.&amp;#42;/&lt;br /&gt;
&amp;#41;;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
which would result in:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;;&amp;#160;log2ipf.pl&amp;#160;-l&amp;#160;ssh&amp;#160;/var/log/auth.log&lt;br /&gt;
&amp;#160;168.126.71.148&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;210.34.14.53&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;3&lt;br /&gt;
&amp;#160;&amp;#160;84.10.149.105&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;3&lt;br /&gt;
&amp;#160;&amp;#160;211.48.62.102&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;3&lt;br /&gt;
&amp;#160;220.231.54.232&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;3&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;195.10.193.4&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;5&lt;br /&gt;
&amp;#160;213.179.181.26&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;11&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
As I say you can do the equivalent with grep, sed, sort and uniq on the commandline:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;;&amp;#160;grep&amp;#160;&quot;Failed&amp;#160;password&amp;#160;for&quot;&amp;#160;/var/log/auth.log&amp;#160;|&amp;#160;sed&amp;#160;-e&amp;#160;&#039;s/.&amp;#42;Failed&amp;#160;password&amp;#160;for&amp;#160;.&amp;#42;&amp;#160;from&amp;#160;\&amp;#40;&amp;#91;^&amp;#160;&amp;#93;&amp;#42;\&amp;#41;.&amp;#42;/\1/&#039;&amp;#160;\&lt;br /&gt;
&amp;#160;&amp;#160;|&amp;#160;sort&amp;#160;|&amp;#160;uniq&amp;#160;-c&amp;#160;|&amp;#160;sort&amp;#160;-n&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;1&amp;#160;168.126.71.148&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;3&amp;#160;210.34.14.53&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;3&amp;#160;211.48.62.102&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;3&amp;#160;220.231.54.232&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;3&amp;#160;84.10.149.105&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;5&amp;#160;195.10.193.4&lt;br /&gt;
&amp;#160;&amp;#160;11&amp;#160;213.179.181.26&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
But for a very large file the timing differences between this method and the perl script are massive.&lt;br /&gt;
&lt;br /&gt;
Anyhoo this is turning into a crazy long entry so I&#039;ll turn it in.  The script log2ipf.pl - should rename that really since it&#039;s got little to do with ipf really! - is in the extended article below if anyone&#039;s interested.&lt;br /&gt;
 &lt;br /&gt;&lt;a href=&quot;http://freebsd.munk.me.uk/archives/170-Serendipity-Spam-Statistics.html#extended&quot;&gt;Continue reading &quot;Serendipity Spam Statistics&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Thu, 31 Aug 2006 13:16:31 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/170-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>

</channel>
</rss>