Bonkersoft
Fragen Tipps und Nippes
Navigation

Suche
Suche
   
Suche
Kurze Beschreibung, spamassassin mit postfix, Procmail und clamav zu installieren.
Beitrag von Christian
geschrieben: 30.12.2009 10:41
  Benötigte Pakete für spamassassin installieren:
text-Code:
aptitude install spamassassin spamc razor pyzor libmail-spf-query-perl


Benötigte Pakete für clamav installieren:
text-Code:
aptitude install clamav clamav-freshclam arj unzoo lha libcurl3-gssapi ca-certificates libldap2-dev bzip2 gzip unzip


spamd Benutzer anlegen:
bash-Code:
addgroup --system spamd
adduser --system --group --home /var/lib/spamassassin --no-create-home --disabled-password --disabled-login spamd
mkdir /var/lib/spamassassin
chown spamd:spamd /var/lib/spamassassin
chown -R spamd:spamd /etc/spamassassin/


Die Datei /etc/default/spamassassin  muss noch angepasst werden.
Z.b.
apache-Code:
# /etc/default/spamassassin
# Duncan Findlay
 
# WARNING: please read README.spamd before using.
# There may be security risks.
 
# Change to one to enable spamd
ENABLED=1
 
# Options
# See man spamd for possible options. The -d option is automatically added.
 
# SpamAssassin uses a preforking model, so be careful! You need to
# make sure --max-children is not set to anything higher than 5,
# unless you know what you're doing.
 
OPTIONS="-m 2 -c -u spamd -l --socketpath=/var/run/spamd.sock --siteconfigpath=/etc/spamassassin"
 
# Pid file
# Where should spamd write its PID to file? If you use the -u or
# --username option above, this needs to be writable by that user.
# Otherwise, the init script will not be able to shut spamd down.
PIDFILE="/var/run/spamd.pid"
 
# Set nice level of spamd
NICE="--nicelevel 15"
 
# Cronjob
# Set to anything but 0 to enable the cron job to automatically update
# spamassassin's rules on a nightly basis
CRON=1


Inhalt von /etc/spamassassin/local.cf  anpassen
Z.b.
apache-Code:
# How many hits before a message is considered spam.
required_score           5.0                        
 
# Whether to change the subject of suspected spam
rewrite_header Subject ****SPAM****(_SCORE_)     
 
# Encapsulate spam in an attachment
report_safe             0          
 
#   Set which networks or hosts are considered 'trusted' by your mail
#   server (i.e. not spammers)                                       
#                                                                    
#trusted_networks 127.0.0.0/8                                        
 
# Add report into headers
add_header spam Report _REPORT_
add_header spam Flag _YESNOCAPS_
add_header all Status _YESNO_, hits=_HITS_ required=_REQD_ tests=_TESTSSCORES(,)_ bayes=_BAYES_ autolearn=_AUTOLEARN_
 
add_header all Level _STARS(*)_
add_header all Checker-Version SpamAssassin _VERSION_ (_SUBVERSION_) on _HOSTNAME_
 
# Set file-locking method (flock is not safe over NFS, but is faster)
 
lock_method flock
allow_user_rules 1
 
rbl_timeout 4
ok_locales all
dns_available yes
#auto_whitelist_factor 0.03
whitelist_to root@*        
whitelist_to abuse@*       
whitelist_from root@*      
whitelist_from postmaster@*
 
#bayes konfiguration
use_bayes 1         
bayes_journal_max_size 15000000
bayes_expiry_max_db_size 20000000
bayes_auto_learn       1         
bayes_learn_to_journal 1         
bayes_ignore_header Return-Path  
bayes_ignore_header Received     
bayes_ignore_header X-Spam-Flag  
bayes_ignore_header X-Spam-Status
bayes_ignore_header X-Spam-Flag  
bayes_ignore_header X-Spam-Level 
bayes_ignore_header X-purgate    
bayes_ignore_header X-purgate-ID 
bayes_ignore_header X-purgate-Ad 
bayes_ignore_header X-GMX-Antispam
bayes_ignore_header X-Resent-For
bayes_ignore_header X-Resent-By
bayes_ignore_header X-Resent-To
bayes_ignore_header Resent-To
bayes_ignore_header Sender
bayes_ignore_header Precedence
bayes_ignore_header X-Antispam
bayes_ignore_header X-Sieve
bayes_ignore_header X-Spamcount
bayes_ignore_header X-Spamsensitivity
bayes_ignore_header To
bayes_ignore_header X-Sieve
bayes_ignore_header X-WEBDE-FORWARD
 
#pyzor konfiguration
pyzor_max 3
 
# Andere Module benutzen
skip_rbl_checks 0
use_razor2 1
use_pyzor 1
 
#bayes punkte
score BAYES_00 -6.1
score BAYES_20 -2.0
score BAYES_40 -0.3
score BAYES_50 0.01
score BAYES_60 1.0
score BAYES_80 3.1
score BAYES_99 7.2
 
#razor punkte
score RAZOR2_CHECK 1.8
score RAZOR2_CF_RANGE_51_100 2.7
 
#dcc punkte
#score DCC_CHECK 4.9
 
#pyzor punkte
#score PYZOR_CHECK 4.8
# TVD_SPACE_RATIO ist zu hoch und wird beim phpBB3 immer gesetzt
score TVD_SPACE_RATIO 0
# Fehler seit 2010 siehe
# http://wiki.apache.org/spamassassin/Rules/FH_DATE_PAST_20XX
score FH_DATE_PAST_20XX 0.0
 


Spamassasin tunen siehe Mit diesem Link verlassen sie Bonkersoft http://www.ende-der-vernu...ssin-optimieren
bash-Code:
mkdir -m 700 /etc/spamassassin/sa-update-keys
chown spamd:spamd /etc/spamassassin/sa-update-keys
wget http://daryl.dostech.ca/sa-update/sare/GPG.KEY
su -s /bin/bash -c "sa-update --gpghomedir /etc/spamassassin/sa-update-keys --import GPG.KEY" spamd
rm -f GPG.KEY
wget http://spamassassin.apache.org/updates/GPG.KEY
su -s /bin/bash -c "sa-update --gpghomedir /etc/spamassassin/sa-update-keys --import GPG.KEY" spamd
rm -f GPG.KEY



Inhalt von /etc/spamassassin/keys
text-Code:
856AA88A
5244EC45



Inhalt von /etc/spamassassin/channels
text-Code:
updates.spamassassin.org
70_sare_adult.cf.sare.sa-update.dostech.net
70_sare_bayes_poison_nxm.cf.sare.sa-update.dostech.net
70_sare_html0.cf.sare.sa-update.dostech.net
70_sare_html1.cf.sare.sa-update.dostech.net
70_sare_header0.cf.sare.sa-update.dostech.net
70_sare_header1.cf.sare.sa-update.dostech.net
70_sare_specific.cf.sare.sa-update.dostech.net
70_sare_random.cf.sare.sa-update.dostech.net
70_sare_oem.cf.sare.sa-update.dostech.net
70_sare_genlsubj0.cf.sare.sa-update.dostech.net
70_sare_genlsubj1.cf.sare.sa-update.dostech.net
70_sare_obfu0.cf.sare.sa-update.dostech.net
70_sare_obfu1.cf.sare.sa-update.dostech.net
70_sare_stocks.cf.sare.sa-update.dostech.net
70_sare_evilnum0.cf.sare.sa-update.dostech.net
70_sare_evilnum1.cf.sare.sa-update.dostech.net
70_sare_spoof.cf.sare.sa-update.dostech.net
70_sare_uri0.cf.sare.sa-update.dostech.net
70_sare_uri1.cf.sare.sa-update.dostech.net
70_sare_whitelist_spf.cf.sare.sa-update.dostech.net
70_sare_whitelist_rcvd.cf.sare.sa-update.dostech.net
72_sare_redirect_post3.0.0.cf.sare.sa-update.dostech.net
72_sare_bml_post25x.cf.sare.sa-update.dostech.net
99_sare_fraud_post25x.cf.sare.sa-update.dostech.net
70_zmi_german.cf.zmi.sa-update.dostech.net



Die Datei keys und channels nur für spamd zugänglich machen
bash-Code:
chown spamd:spamd /etc/spamassassin/channels /etc/spamassassin/keys 
chmod 600 /etc/spamassassin/channels /etc/spamassassin/keys



sa-update ausführen.
bash-Code:
su -s /bin/bash -c "sa-update -D --allowplugins --channelfile /etc/spamassassin/channels --gpgkeyfile /etc/spamassassin/keys --gpghomedir /etc/spamassassin/sa-update-keys" spamd


Zum schluss sollte man nochmal alle Debug Ausgaben lesen und auf Fehler überprüfen
bash-Code:
su -s /bin/bash -c "spamassassin -D --lint" spamd


Nun zu Clamav. Wir besorgen uns clamassassin
bash-Code:
aptitude install clamassassin


Die Konfiguration /etc/default/clamassassin anpassen.
apache-Code:
# Modify Subject line with a header ala spamassassin with rewrite_subject on
# You'll want to add a trailing space before the old subject
SUBJECTHEAD="****VIRUS**** "
 
# Configure your full path to clamscan or clamdscan
# (If you use clamdscan, see the README for directions)
CLAMSCAN=/usr/bin/clamscan
 
# Configure options passed to clamscanner
CLAMSCANOPT="--no-summary --stdout"
 
# Configure flag to add clamscanner to version header
ADDSCANNERFLAG=1
 
# Configure whether or not the virus signature version is added
# Default: 0.80 and higher: off, others: on
SIGVERSFLAG=0
 



Nun zu Procmail.
text-Code:
aptitude install procmail


/etc/procmailrc mit folgendem Inhalt erstellen
apache-Code:
#DROPPRIVS=yes
# Schalte mal zur Probe das Logfile ein
LOGFILE=/var/log/procmail
VERBOSE=ON
LOGABSTRACT=all
SHELL=/bin/sh
SENDMAIL="/usr/sbin/sendmail"
SENDMAILFLAGS="-oi -t"
# Fals du dovecot verwendest
#DELIVER="/usr/lib/dovecot/deliver -e -d ${LOGNAME}"
DEFAULT="$HOME/Maildir/"
LOG="--- Logging for ${LOGNAME}, "
SPAMDIR="$HOME/Maildir/.Spam/"
TRASHDIR="$HOME/Maildir/.Trash/"
 
# Zuerst pruefen, ob es ein subject gibt
:0 H
* !^Subject:
{
LOG="No Subject. "
:0 fhw
| /usr/bin/formail -I "Subject: Warning: without Subject!"
}
 
:0 H
* !^X-Virus-Checker
# Virus Scanner anwerfen
{
:0 fw
| /usr/bin/clamassassin
}
 
:0 H
#Nicht mehr scannen wenn schon auf eurem Server gescannt
* !^X-SPAM-CHECKER-VERSION: SpamAssassin
{
:0 fw
# Ist die nachricht kleiner als 250KB
# (250 * 1024 = 256000 bytes) durch spamc leiten
* < 256000
| /usr/bin/spamc --socket=/var/run/spamd.sock -t 30 -u ${LOGNAME}
}
 
# Work around procmail bug: any output on stderr will cause the "F" in "From"
# to be dropped.  This will re-add it.
:0 H
* ! ^From[ ]
* ^rom[ ]
{
LOG="*** Dropped F off From_ header! Fixing up. "
:0 fhw
| sed -e 's/^rom /From /'
}
 
# procmailrc des Benutzers laden
INCLUDERC="$HOME/.procmailrc"
LOG="---- POST ${LOGNAME} wird zugestellt ---- "
 
# Das Ergebnis der Zustellung wird geloggt:
#
:0 w
# Fals du dovecot verwendest
#| $DELIVER
EXITCODE=$?


In der /etc/postfix/main.cf den Eintrag ergänzen:
text-Code:
mailbox_command =/usr/bin/procmail -t -a "$EXTENSION"


In der /etc/postfix/master.cf folgenden Eintrag ergänzen:
apache-Code:
procmail  unix  -       n       n       -       15       pipe
   flags=R user=nobody argv=/usr/bin/procmail -t -o SENDER=${sender} -m USER=${user} EXTENSION=${extension} -m /etc/procmailrc ${sender} ${recipient}
 


Postfix neu starten und Fehler prüfen!