<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>johker&#039;s blog &#187; bayes</title>
	<atom:link href="http://johker.ibutho.de/tag/bayes/feed/" rel="self" type="application/rss+xml" />
	<link>http://johker.ibutho.de</link>
	<description>stories about me, my life and my trips</description>
	<lastBuildDate>Sun, 18 Dec 2011 11:53:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Der neue Server: Teil 6 Spambekämpfung</title>
		<link>http://johker.ibutho.de/2009/04/01/der-neue-server-teil-6-spambekampfung/</link>
		<comments>http://johker.ibutho.de/2009/04/01/der-neue-server-teil-6-spambekampfung/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 15:55:25 +0000</pubDate>
		<dc:creator>johker</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[amavis]]></category>
		<category><![CDATA[amavisd-new]]></category>
		<category><![CDATA[anti-spam]]></category>
		<category><![CDATA[bash script]]></category>
		<category><![CDATA[bayes]]></category>
		<category><![CDATA[clamav]]></category>
		<category><![CDATA[content filter]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[cronjob]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[detect virus]]></category>
		<category><![CDATA[dkim]]></category>
		<category><![CDATA[dspam]]></category>
		<category><![CDATA[fight junk]]></category>
		<category><![CDATA[fight spam]]></category>
		<category><![CDATA[fight virus]]></category>
		<category><![CDATA[gateway]]></category>
		<category><![CDATA[konfiguration]]></category>
		<category><![CDATA[lmtp]]></category>
		<category><![CDATA[mta]]></category>
		<category><![CDATA[policyd-weight]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[pyzor]]></category>
		<category><![CDATA[razor]]></category>
		<category><![CDATA[sa-compile]]></category>
		<category><![CDATA[sa-learn]]></category>
		<category><![CDATA[sa-update]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[sieve]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[spamassassin]]></category>
		<category><![CDATA[Spambekämpfung]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[Virenfilter]]></category>
		<category><![CDATA[volatile]]></category>

		<guid isPermaLink="false">http://johker.ibutho.de/?p=192</guid>
		<description><![CDATA[Nachfolgend wird erklärt, wie man policyd-weight, amavisd-new, clamav, spamassassin, dspam installiert, konfiguriert und in das bestehende Setup integriert. policyd-weight policyd-weight ist ein effektives Tool zur Spambekämpfung schon vor der Annahme einer E-Mail. Es überprüft das &#8220;Envelope&#8221; und gleicht die Absenderadresse &#8230; <a href="http://johker.ibutho.de/2009/04/01/der-neue-server-teil-6-spambekampfung/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Nachfolgend wird erklärt, wie man <em>policyd-weight</em>, <em>amavisd-new</em>, <em>clamav</em>, <em>spamassassin</em>, <em>dspam</em> installiert, konfiguriert und in das bestehende Setup integriert.</p>
<h1>policyd-weight</h1>
<p><em>policyd-weight</em> ist ein effektives Tool zur Spambekämpfung schon vor der Annahme einer E-Mail. Es überprüft das &#8220;Envelope&#8221; und gleicht die Absenderadresse gegen mehrere DNS-Blacklists ab.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> policyd-weight</pre></div></div>

<p>Danach erstellen wir noch eine Standardkonfiguration für <em>policyd-weight</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">policyd-weight defaults <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>policyd-weight.conf</pre></div></div>

<p>Folgende Zeile in &#8220;<em>/etc/postfix/main.cf</em>&#8221; ändern:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">###  check_policy_service inet:127.0.0.1:12525,</span></pre></div></div>

<p>&#8230; zu:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">check_policy_service inet:127.0.0.1:<span style="color: #000000;">12525</span>,</pre></div></div>

<p>Jetzt muss die <em>postfix</em>-Konfiguration neu geladen werden und <em>policyd-weight</em> neu gestartet werden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>policyd-weight restart
postfix reload</pre></div></div>

<h1>amavisd-new</h1>
<p><em>Amavisd-new</em> ist ein Content-Filter, der sich in fast jeden MTA integrieren lässt. Über <em>amavisd-new</em> lassen sich viele verschiedene Tools, wie z.B. <em>ClamAV</em> zur Virenprüfung, <em>Spamassassin</em> zur Spamfilterung oder <em>dspam</em> &#8211; ebenfalls zu Spamfilterung &#8211; integrieren.<br />
Wenn eine E-Mail in <em>postfix</em> ankommt, wird diese an <em>amavis</em> weitergeleitet, überprüft und wieder &#8211; mit zusätzlichen Headern &#8211; an <em>postfix</em> zur Auslieferung zurückgesendet. Natürlich kann man <em>amavis</em> auch so konfigurieren, dass bestimmte Nachrichtentypen, z.B. Virusmails oder Spammails, sofort geblockt werden. Sobald die Nachricht von <em>amavis</em> an postfix zurückgegeben wurde, kann eine automatische Einsortierung in Ordner über <em>sieve</em> folgen (z.B. Spam-Mails nach Junk).</p>
<p>Installation:<br />
Zu &#8220;<em>/etc/apt/sources.list</em>&#8221; hinzufügen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># volatile repository (e.g. for clamav)</span>
deb http:<span style="color: #000000; font-weight: bold;">//</span>volatile.debian.org<span style="color: #000000; font-weight: bold;">/</span>debian-volatile lenny<span style="color: #000000; font-weight: bold;">/</span>volatile main contrib non-free</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> amavisd-new spamassassin clamav clamav-daemon clamav-freshclam pax lha arj <span style="color: #c20cb9; font-weight: bold;">bzip2</span> unrar zoo nomarch <span style="color: #c20cb9; font-weight: bold;">cpio</span> lzop cabextract apt-listchanges libauthen-sasl-perl libdbi-perl dspam libmail-dkim-perl razor pyzor dcc-client libdbd-pg-perl</pre></div></div>

<p>Nun folgt die Konfiguration von <em>amavis</em> (Konfigurationsdateien sind unter &#8220;<em>/etc/amavis/conf.d/</em>&#8221; zu finden). Ich führe jeweils nur geänderte Zeilen auf:</p>
<p><em>01-debian</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$unrar</span>      = <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'rar'</span>, <span style="color: #ff0000;">'unrar'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #666666; font-style: italic;">#disabled (non-free, no security support)</span>
<span style="color: #666666; font-style: italic;">#$unrar         = undef;</span>
<span style="color: #007800;">$lha</span>    = <span style="color: #ff0000;">'lha'</span>; <span style="color: #666666; font-style: italic;">#disabled (non-free, no security support)</span>
<span style="color: #666666; font-style: italic;">#$lha   = undef;</span></pre></div></div>

<p><em>05-domain_id</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">@</span>local_domains_acl = <span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #ff0000;">&quot;.&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>;</pre></div></div>

<p><em>05-node_id</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$myhostname</span> = <span style="color: #ff0000;">&quot;mail.domain.tld&quot;</span>;</pre></div></div>

<p><em>15-content_filter_mode</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">@</span>bypass_virus_checks_maps = <span style="color: #7a0874; font-weight: bold;">&#40;</span> 
   \<span style="color: #000000; font-weight: bold;">%</span>bypass_virus_checks, \<span style="color: #000000; font-weight: bold;">@</span>bypass_virus_checks_acl, \<span style="color: #007800;">$bypass_virus_checks_re</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">@</span>bypass_spam_checks_maps = <span style="color: #7a0874; font-weight: bold;">&#40;</span>
   \<span style="color: #000000; font-weight: bold;">%</span>bypass_spam_checks, \<span style="color: #000000; font-weight: bold;">@</span>bypass_spam_checks_acl, \<span style="color: #007800;">$bypass_spam_checks_re</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;</pre></div></div>

<p><em>20-debian_defaults</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$final_virus_destiny</span>      = D_DISCARD;  <span style="color: #666666; font-style: italic;"># (data not lost, see virus quarantine)</span>
<span style="color: #007800;">$final_banned_destiny</span>     = D_PASS;   <span style="color: #666666; font-style: italic;"># D_REJECT when front-end MTA</span>
<span style="color: #007800;">$final_spam_destiny</span>       = D_PASS;
<span style="color: #007800;">$final_bad_header_destiny</span> = D_PASS;     <span style="color: #666666; font-style: italic;"># False-positive prone (for spam)</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># $sa_spam_subject_tag = '***SPAM*** ';</span>
<span style="color: #007800;">$sa_tag_level_deflt</span>  = undef;</pre></div></div>

<p><em>50-user</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$max_servers</span> = <span style="color: #000000;">2</span>;
&nbsp;
<span style="color: #007800;">$policy_bank</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #ff0000;">'MYNETS'</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> = <span style="color: #7a0874; font-weight: bold;">&#123;</span>   <span style="color: #666666; font-style: italic;"># mail originating from @mynetworks</span>
  originating =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000;">1</span>,  <span style="color: #666666; font-style: italic;"># is true in MYNETS by default, but let's make it explicit</span>
  os_fingerprint_method =<span style="color: #000000; font-weight: bold;">&gt;</span> undef,  <span style="color: #666666; font-style: italic;"># don't query p0f for internal clients</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>;
&nbsp;
<span style="color: #007800;">$recipient_delimiter</span> = <span style="color: #ff0000;">'+'</span>;
&nbsp;
<span style="color: #007800;">$warnvirusrecip</span> = <span style="color: #000000;">1</span>;
&nbsp;
<span style="color: #007800;">$mailfrom_notify_admin</span> = <span style="color: #ff0000;">&quot;postmaster\@<span style="color: #007800;">$mydomain</span>&quot;</span>;
<span style="color: #007800;">$mailfrom_notify_recip</span> = <span style="color: #ff0000;">&quot;postmaster\@<span style="color: #007800;">$mydomain</span>&quot;</span>;
<span style="color: #007800;">$mailfrom_notify_spamadmin</span> = <span style="color: #ff0000;">&quot;postmaster\@<span style="color: #007800;">$mydomain</span>&quot;</span>;</pre></div></div>

<p>Jetzt fügen wir noch den <em>clamav</em>-Nutzer der <em>amavis</em>-Gruppe hinzu:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">adduser clamav amavis</pre></div></div>

<p>Danach müssen wir Änderungen an der <em>postfix</em>-Konfiguration vornehmen:</p>
<p><em>Zu <em>main.cf</em> hinzufügen</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">content_filter = amavis:<span style="color: #7a0874; font-weight: bold;">&#91;</span>127.0.0.1<span style="color: #7a0874; font-weight: bold;">&#93;</span>:<span style="color: #000000;">10024</span>
receive_override_options = no_address_mappings</pre></div></div>

<p><em>Zu <em>master.cf</em> hinzufügen</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">amavis       unix  -       -       n       -       <span style="color: #000000;">2</span>       lmtp 
    <span style="color: #660033;">-o</span> <span style="color: #007800;">lmtp_data_done_timeout</span>=<span style="color: #000000;">1200</span>
    <span style="color: #660033;">-o</span> <span style="color: #007800;">lmtp_send_xforward_command</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>
    <span style="color: #660033;">-o</span> <span style="color: #007800;">disable_dns_lookups</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>
    <span style="color: #660033;">-o</span> <span style="color: #007800;">max_use</span>=<span style="color: #000000;">20</span>
127.0.0.1:<span style="color: #000000;">10025</span> inet n  -       n       -       -       smtpd
    <span style="color: #660033;">-o</span> <span style="color: #007800;">content_filter</span>=
    <span style="color: #660033;">-o</span> <span style="color: #007800;">local_recipient_maps</span>=
    <span style="color: #660033;">-o</span> <span style="color: #007800;">relay_recipient_maps</span>=
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_delay_reject</span>=no
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_restriction_classes</span>=
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_client_restrictions</span>=
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_helo_restrictions</span>=
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_sender_restrictions</span>=
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_recipient_restrictions</span>=permit_mynetworks,reject
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_data_restrictions</span>=reject_unauth_pipelining
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_end_of_data_restrictions</span>=
    <span style="color: #660033;">-o</span> <span style="color: #007800;">mynetworks</span>=127.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span>    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_error_sleep_time</span>=<span style="color: #000000;">0</span>
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_soft_error_limit</span>=<span style="color: #000000;">1001</span>
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_hard_error_limit</span>=<span style="color: #000000;">1000</span>
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_client_connection_count_limit</span>=<span style="color: #000000;">0</span>
    <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_client_connection_rate_limit</span>=<span style="color: #000000;">0</span>
    <span style="color: #660033;">-o</span> <span style="color: #007800;">receive_override_options</span>=no_header_body_checks,no_unknown_recipient_checks</pre></div></div>

<p>Zuletzt werden <em>postfix</em>, <em>amavis</em> und <em>clamav</em> neu gestartet:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>postfix restart
<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>amavis restart
<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>clamav-daemon restart</pre></div></div>

<h2>Testen der Konfiguration</h2>
<p>Zum Testen genügt es eine Mail an den Mailserver zu schicken und sich danach die Header-Informationen anzuschauen. Finden sich ähnliche Header wie die folgenden in der Mail wieder, so wird amavis aufgerufen.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">X-virus-scanned: Debian amavisd-new at domain.tld
X-spam-flag: NO
X-spam-score: <span style="color: #000000;">2.898</span>
X-spam-level: <span style="color: #000000; font-weight: bold;">**</span>
X-spam-status: No, <span style="color: #007800;">score</span>=<span style="color: #000000;">2.898</span> <span style="color: #007800;">required</span>=<span style="color: #000000;">6.31</span> <span style="color: #007800;">tests</span>=<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">SPF_PASS</span>=-<span style="color: #000000;">0.001</span>, <span style="color: #007800;">TVD_SPACE_RATIO</span>=<span style="color: #000000;">2.899</span><span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>Des Weiteren kann man mit folgendem Befehl testen, ob Spam erkannt wird:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sendmail</span> john<span style="color: #000000; font-weight: bold;">@</span>example.com <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>doc<span style="color: #000000; font-weight: bold;">/</span>spamassassin<span style="color: #000000; font-weight: bold;">/</span>examples<span style="color: #000000; font-weight: bold;">/</span>sample-spam.txt</pre></div></div>

<p>&#8230; oder Viren:</p>

<div class="wp_syntax"><div class="code"><pre class="test" style="font-family:monospace;">telnet localhost 25
HELO localhost
MAIL FROM: &lt;user@change_to_my_domain.tld&gt;
RCPT TO: &lt;user@change_to_my_domain.tld&gt;
DATA
From: virus-tester
To: undisclosed-recipients:;
Subject: amavisd test - simple - spam test pattern
X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
.
&nbsp;
quit</pre></div></div>

<h1>Spamassassin Konfiguration</h1>
<p>Ans Ende der Datei &#8220;/etc/spamassassin/local.cf&#8221; anfügen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">use_bayes <span style="color: #000000;">1</span>
use_bayes_rules <span style="color: #000000;">1</span>
bayes_auto_learn <span style="color: #000000;">1</span>
bayes_auto_expire <span style="color: #000000;">0</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># pyzor</span>
use_pyzor <span style="color: #000000;">1</span>
pyzor_path <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>pyzor
&nbsp;
<span style="color: #666666; font-style: italic;"># razor</span>
use_razor2 <span style="color: #000000;">1</span>
razor_config <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>razor<span style="color: #000000; font-weight: bold;">/</span>razor-agent.conf</pre></div></div>

<p><em>/etc/spamassassin/v312.pre</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">loadplugin Mail::SpamAssassin::Plugin::DKIM</pre></div></div>

<p><em>/etc/spamassassin/v320.pre</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">loadplugin Mail::SpamAssassin::Plugin::Shortcircuit
loadplugin Mail::SpamAssassin::Plugin::Rule2XSBody</pre></div></div>

<p>Razor konfigurieren:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">su</span> - amavis
razor-admin <span style="color: #660033;">-create</span></pre></div></div>

<p>Spamassassin-Regeln neu laden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">sa-update</pre></div></div>

<h2>Automatische Updates</h2>
<p>Um <em>spamassassin</em> voll auszureizen, richten wir einen <em>cronjob</em> ein über welchen jede Nacht die Regeln auf den neuesten Stand gebracht werden (als <strong>root</strong> ausführen!):</p>
<p><em>/usr/local/sbin/updateSpamassassin</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
sa-update <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
sa-compile <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">crontab <span style="color: #660033;">-e</span>
<span style="color: #000000;">42</span> <span style="color: #000000;">3</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>updateSpamassassin <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null</pre></div></div>

<h2>Ham/Spam aus /var/vmail lernen</h2>
<p>Nun erstellen wir noch ein Skript, welches Spam, bzw. Ham aus den Mailboxen der Benutzer lernt (aus den Ordnern &#8220;INBOX&#8221; und &#8220;Junk&#8221;). Dieses Skript rufen wir wöchentlich über einen Cronjob auf.</p>
<p><em>/usr/local/sbin/trainSpamassassin</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">VMAILDIR</span>=<span style="color: #ff0000;">&quot;/var/vmail&quot;</span>
<span style="color: #007800;">SADIR</span>=<span style="color: #ff0000;">&quot;/var/lib/amavis/.spamassassin&quot;</span>
<span style="color: #007800;">DBPATH</span>=<span style="color: #ff0000;">&quot;/var/lib/amavis/.spamassassin/bayes&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$VMAILDIR</span>
<span style="color: #000000; font-weight: bold;">for</span> domain <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">find</span> .<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-maxdepth</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-not</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">&quot;.&quot;</span> <span style="color: #660033;">-type</span> d<span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #007800;">domaindir</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$VMAILDIR</span>/<span style="color: #007800;">$domain</span>&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$domaindir</span>
        <span style="color: #000000; font-weight: bold;">for</span> user <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">find</span> .<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-maxdepth</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-not</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">&quot;.&quot;</span> <span style="color: #660033;">-type</span> d<span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">do</span>
                <span style="color: #007800;">maildir</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$domaindir</span>/<span style="color: #007800;">$user</span>/maildir&quot;</span>
                <span style="color: #007800;">inbox</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$maildir</span>/cur&quot;</span>
                <span style="color: #007800;">junk</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$maildir</span>/.Junk/cur&quot;</span>
&nbsp;
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Learning ham from <span style="color: #007800;">$inbox</span>&quot;</span>
                sa-learn <span style="color: #660033;">--ham</span> <span style="color: #660033;">--showdots</span> <span style="color: #660033;">--dbpath</span> <span style="color: #007800;">$DBPATH</span> <span style="color: #007800;">$inbox</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Learning junk from <span style="color: #007800;">$junk</span>&quot;</span>
                sa-learn <span style="color: #660033;">--spam</span> <span style="color: #660033;">--showdots</span> <span style="color: #660033;">--dbpath</span> <span style="color: #007800;">$DBPATH</span> <span style="color: #007800;">$junk</span>
        <span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> amavis:amavis <span style="color: #007800;">$SADIR</span></pre></div></div>

<p>Nun noch das Skript in die <em>crontab</em> aufnehmen (als <strong>root</strong> ausführen!):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">crontab <span style="color: #660033;">-e</span>
<span style="color: #000000;">33</span> <span style="color: #000000;">4</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>trainSpamassassin <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null</pre></div></div>

<h1>Globale sieve-Regeln</h1>
<p>Um dem Benutzer das Erstellen von <em>sieve</em>-Regeln für Spam zu ersparen, fügen wir in die Datei &#8220;/var/vmail/default.sieve&#8221; folgende Zeile ein, um Spam-Mails automatisch in den Ordner &#8220;Junk&#8221; zu verschieben (<em>sieve</em> wurde schon in Teil 5 dieser Serie konfiguriert):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">require <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;fileinto&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;
<span style="color: #666666; font-style: italic;"># Move spam to spam folder</span>
<span style="color: #000000; font-weight: bold;">if</span> header :contains <span style="color: #ff0000;">&quot;X-Spam-Flag&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;YES&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  fileinto <span style="color: #ff0000;">&quot;Junk&quot;</span>;
  stop;
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<h1>dspam</h1>
<p>Die Konfiguration von <em>dspam</em> wird nachgereicht.</p>
<p>Quellen:</p>
<p>http://workaround.org/articles/ispmail-etch/#step-5-deliver-emails-through-the-dovecot-lda</p>
<p>http://www200.pair.com/mecham/spam/spamfilter20090215.html#amavisconfig</p>
<p>http://wiki.rootforum.de/mailserver/postfix/clamav_amavisd</p>
<p>http://www.howtoforge.com/virtual-users-domains-postfix-courier-mysql-squirrelmail-debian-lenny-p3</p>
<p>http://www.tuxj0b.de/HOWTO_Mailserver_mit_Postfix_Dovecot_Antispam_und_PostgreSQL_Backend</p>
]]></content:encoded>
			<wfw:commentRss>http://johker.ibutho.de/2009/04/01/der-neue-server-teil-6-spambekampfung/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

