Technische Anleitung · 4 min read · Jan 03, 2026

Mailscanner/Exim Gateway Mit Communigate PRO Anleitung - Seite 3

FuzzyOCR

Wir werden die Bild-Hashes in einer MySQL-Datenbank speichern, um die Leistung zu verbessern, sodass Bilder, die wir bereits gescannt haben, nicht erneut gescannt werden, da OCR eine ressourcenintensive Aktivität ist.

MySQL-Datenbank erstellen

Das SQL-Skript erstellt die Datenbank und Tabellen und fügt einen Benutzer fuzzyocr mit dem Passwort fuzzyocr hinzu:

mysql -p < /usr/local/src/devel/FuzzyOcr.mysql

Ändern Sie das Passwort:

mysqladmin -u fuzzyocr -p fuzzyocr password

Grundeinstellungen

Bearbeiten Sie /etc/mail/spamassassin/FuzzyOCR.cf und setzen Sie die grundlegenden Optionen:

focr_path_bin /usr/bin:/usr/local/bin  

focr_minimal_scanset 1  

focr_autosort_scanset 1  

focr_enable_image_hashing 3  

focr_logfile /tmp/FuzzyOcr.log

FuzzyOCR dazu bringen, die Datenbank zu verwenden

Bearbeiten Sie die Datei /etc/mail/spamassassin/FuzzyOCR.cf und fügen Sie hinzu:

focr_mysql_db FuzzyOcr  

focr_mysql_hash Hash  

focr_mysql_safe Safe  

focr_mysql_user fuzzyocr  

focr_mysql_pass password  

focr_mysql_host localhost  

focr_mysql_port 3306  

focr_mysql_socket /var/lib/mysql/mysql.sock

Razor konfigurieren

Registrieren Sie Ihr Razor-System:

razor-admin -register

Clamav konfigurieren

Basis-Konfiguration

Diese Clamav-Installation verwendet sowohl die offiziellen Signaturen als auch die Sanesecurity-Signaturen, die zur Bekämpfung von Bild- und PDF-Spam sowie Phishing-Angriffen eingesetzt werden.

Fügen Sie den Clamav-Benutzer zur Exim-Gruppe hinzu:

usermod -G exim clamav

Konfigurieren Sie clamd, um auf den Unix-Socket zu hören:

LocalSocket /var/run/clamav/clamd.socket

Konfigurieren Sie clamd, um beim Booten zu starten:

chkconfig --level 345 clamd on

SELinux

Damit Clamav im enforcing-Modus arbeiten kann, müssen wir einige lokalisierte Richtlinienmodule hinzufügen. Die Beispielrichtlinie ist unten:

module clamlocal 1.0;
require {
        class dir { add_name read remove_name search write };
        class file { create getattr lock read write append };
        type clamd_t;
        type clamd_var_log_t;
        type logwatch_t;
        type proc_t;
        type sysctl_kernel_t;
        type var_spool_t;
        type var_t;
        type var_log_t;
        role system_r;
};
allow clamd_t proc_t:file { getattr read };
allow clamd_t sysctl_kernel_t:dir search;
allow clamd_t sysctl_kernel_t:file read;
allow clamd_t var_spool_t:dir read;
allow clamd_t var_spool_t:file { getattr read };
allow clamd_t var_t:dir { add_name read remove_name write };
allow clamd_t var_t:file { create getattr lock read write };
allow logwatch_t clamd_var_log_t:dir { read search };
allow clamd_t var_log_t:file append;
allow clamd_t var_t:dir { read write };

Das Modul kann von http://www.topdog-software.com/files/clamlocal.te.gz heruntergeladen werden.

Bauen und installieren Sie das Modul:

wget http://www.topdog-software.com/files/clamlocal.te.gz  
gunzip clamlocal.te.gz  
checkmodule -M -m -o clamlocal.mod clamlocal.te  
semodule_package -o clamlocal.pp -m clamlocal.mod  
semodule -i clamlocal.pp

Mailwatch konfigurieren

Patch für verbesserte Version

Dieser Patch sorgt dafür, dass Mailwatch Nachrichten über den Mailfeeder freigibt, indem die tatsächliche Nachricht über den SMTP-Server erneut eingespeist wird, sodass sie wie die ursprüngliche Nachricht erscheint, die gesendet wurde, im Gegensatz zur Standard-Mailwatch-Freigabe, die die freigegebene E-Mail als Anhang vom Postmaster-Konto sendet.

wget http://www.topdog-software.com/files/mailwatch_release.patch.gz  
gunzip mailwatch_release.patch.gz  
cd /var/www/html  
patch -i ../mailwatch_release.patch

Basisverzeichnis konfigurieren

Da wir Mailwatch in /var/www/html anstelle von /var/www/html/mailscanner installieren, müssen wir Änderungen an der Konfiguration conf.php vornehmen, um dies widerzuspiegeln:

define(MAILWATCH_HOME, '/var/www/html');

Für die Datenbank konfigurieren

Setzen Sie die folgenden Optionen in conf.php:

define(DB_TYPE, 'mysql');
define(DB_USER, 'mailwatch');
define(DB_PASS, 'password');
define(DB_HOST, 'localhost:/var/lib/mysql/mysql.sock');
define(DB_NAME, 'mailscanner');

Quarantäne

Setzen Sie dies in die Datei conf.php:

define(QUARANTINE_USE_FLAG, true);
define(QUARANTINE_DAYS_TO_KEEP, 30);

Installieren Sie das Skript zur Bereinigung der Quarantäne

cp /usr/local/src/mailwatch-1.0.4/tools/quarantine_maint.php /usr/local/bin/  
chmod +x /usr/local/bin/quarantine_maint.php  
ln -s /usr/local/bin/quarantine_maint.php /etc/cron.daily

Deaktivieren Sie das von Mailscanner installierte Cron-Skript /etc/cron.daily/clean.quarantine

$disabled = 1;

SELinux

Damit Mailwatch im enforcing-Modus funktioniert, müssen wir ein benutzerdefiniertes SELinux-Richtlinienmodul installieren. Der Modulquellcode ist unten:

module mailwatch 1.0;

require {
        class dir { getattr read search };
        class file { getattr read execute execute_no_trans ioctl };
        class lnk_file { read getattr };
        class tcp_socket name_connect;
        type spamc_exec_t;
        type clamd_t;
        type getty_t;
        type hostname_exec_t;
        type initrc_t;
        type unconfined_t;
        type var_spool_t;
        type etc_mail_t;
        type ls_exec_t;
        type smtp_port_t;
        type spamassassin_exec_t;
        type httpd_sys_content_t;
        type httpd_t;
        type mysqld_t;
        type lib_t;
};

allow httpd_t clamd_t:dir getattr;
allow httpd_t hostname_exec_t:file getattr;
allow httpd_t var_spool_t:dir read;
allow httpd_t var_spool_t:file { getattr ioctl read };
allow httpd_t spamc_exec_t:file { execute execute_no_trans getattr read ioctl };
allow httpd_t etc_mail_t:dir { search getattr read };
allow httpd_t etc_mail_t:file { getattr read ioctl };
allow httpd_t etc_mail_t:lnk_file { getattr read };
allow httpd_t hostname_exec_t:file { execute read execute_no_trans };
allow httpd_t unconfined_t:dir { getattr search read };
allow httpd_t unconfined_t:file { read };
allow httpd_t initrc_t:dir { getattr search read };
allow httpd_t initrc_t:file read;
allow httpd_t ls_exec_t:file { execute read getattr execute_no_trans };
allow httpd_t spamassassin_exec_t:file { execute getattr read execute_no_trans ioctl };
allow mysqld_t httpd_sys_content_t:dir { getattr read search };
allow mysqld_t httpd_sys_content_t:file { read getattr };
allow httpd_t smtp_port_t:tcp_socket name_connect;
allow httpd_t lib_t:file execute_no_trans;

Der Modulquellcode kann von http://www.topdog-software.com/files/mailwatch.te.gz heruntergeladen werden.

Bauen und installieren Sie das Modul:

wget http://www.topdog-software.com/files/mailwatch.te.gz  
gunzip mailwatch.te.gz  
checkmodule -M -m -o mailwatch.mod mailwatch.te  
semodule_package -o mailwatch.pp -m mailwatch.mod  
semodule -i mailwatch.pp

GeoIP

Verbinden Sie sich mit Ihrem Server http://hostname/ anmelden, klicken Sie auf das Menü “Tools/Links” ? “GeoIP-Datenbank aktualisieren” und klicken Sie auf “Jetzt ausführen”.

Mail Warteschlangenmonitor

Installieren Sie das Überwachungsskript:

cp /usr/local/src/mailwatch-1.0.4/mailq.php /usr/local/bin  
chmod +x /usr/local/bin/mailq.php  
crontab -e  
0-59 * * * * /usr/local/bin/mailq.php

Bearbeiten Sie für das neue Verzeichnislayout:

if(flock($fl, LOCK_EX + LOCK_NB)) {
 require "/var/www/html/functions.php";

``
Share: X/Twitter LinkedIn

Erhalte neue Beiträge in deinem Posteingang.

Kein Spam. Jederzeit abmelden.