SMF-SPAMD ein wenig aufgebohrt
Ich benutze schon eine ganze Weile die Milter smf-* von Eugene Kurmanin
für Sendmail und bin sehr zufrieden damit.
Das Programm smf-spamd dient dazu Emails an SpamAssassin weiter zu reichen.
Wenn ein bestimmer einstellbarer Grenzwert bei der Überprüfung überschritten wird (in meinem Fall 15 Punkte), wird die Email mit einer Fehlermeldung abgelehnt.
Da ich unter anderem Emails von einem Server empfange der keinen Spamfilter verwendet, in dem speziellen Fall ist es eine Weiterleitung, werden auch sämtliche Mails abgelehnt die in diesem Fall über 15 Punkten liegen.
Dies resultiert dann auf dem externen Mailserver in einem Mailer Error der an mich gerichtet ist und die Spam Mail ist im Anhang der Error Mail.
Damit ist natürlich nicht viel gewonnen und bedeutet nur Mehrarbeit.
Eine Möglichkeit wäre den Host in die generelle Whitelist zu packen, dann wird die Mail aber schon beim eigentlichen Connect direkt durchgelassen ohne das eine Prüfung auf Spam erfolgt.
Der hier aufgeführte Patch führt eine zusätzliche Whitelist ein, die dieses Verhalten ändert.
Kommt eine Mail von einem Host dessen IP in der extra Whitelist steht, wird sie vom Server nie abgelehnt, sondern sie durchläuft die Prüfung durch SpamAssassin. Es spielt keine Rolle ob sie als EXTRA SPAM identifiziert wurde, sie wird ganz normal weitergeleitet, jedoch wird wie gewünscht das Subject richtig umgeschrieben und kann somit lokal direkt in den Spamordner geschoben werden.
Patch für smf-spamd -> Download
diff -up -r smf-spamd-1.3.1/smf-config.h smf-spamd-1.3.1-modded/smf-config.h
--- smf-spamd-1.3.1/smf-config.h 2007-01-18 15:35:08.000000000 +0100
+++ smf-spamd-1.3.1-modded/smf-config.h 2009-08-08 03:51:05.000000000 +0200
@@ -5,10 +5,13 @@
*/
/* Hosts/Networks whitelist (extended regex format) */
-#define WHITE_LIST "(^127\\.|^192\\.168\\.|^10\\.)"
+#define WHITE_LIST "(^127\\.|^192\\.168\\.|^10\\.)"
+
+/* Hosts/Networks which probably send EXTRA SPAM and should not be blocked*/
+#define WHITE_LIST_EXTRA "(^1\\.2\\.3\\.)"
/* Maximal message size */
-#define MAX_SIZE 131072 /* bytes */
+#define MAX_SIZE 5131072 /* bytes */
/* Probable SPAM e-Mail messages Subject tagging */
#define TAG_SUBJECT 1 /* set 0 to disable */
diff -up -r smf-spamd-1.3.1/smf-spamd.c smf-spamd-1.3.1-modded/smf-spamd.c
--- smf-spamd-1.3.1/smf-spamd.c 2007-01-18 15:35:08.000000000 +0100
+++ smf-spamd-1.3.1-modded/smf-spamd.c 2009-08-08 02:43:33.000000000 +0200
@@ -91,6 +91,10 @@ int daemon(int nochdir, int noclose) {
static const char *ignore_connect = WHITE_LIST;
static regex_t re_ignore_connect;
+static const char *no_ignore_connect = WHITE_LIST_EXTRA;
+static regex_t no_re_ignore_connect;
+
+
struct context {
char addr[64];
char fqdn[MAXLINE];
@@ -470,12 +474,18 @@ static sfsistat smf_eom(SMFICTX *ctx) {
elapsed = context->tend.tv_sec - context->tstart.tv_sec + (context->tend.tv_usec - context->tstart.tv_usec) / 1.0e6;
if (ret == 1) {
if (context->score >= EXTRA_SPAM) {
+ // if there is an entry in WHITELIST_EXTRA do not reject the message;
+ if (no_ignore_connect[0] && regexec(&no_re_ignore_connect, context->addr, 0, NULL, 0)){
char reject[MAXLINE];
syslog(LOG_NOTICE, "EXTRA SPAM (%.1f/%.1f), %.3fsec, %s, %s -> %s", context->score, context->threshold, elapsed, context->fqdn, context->from, context->rcpt);
snprintf(reject, sizeof(reject), "Sorry, looks like spam. Contact %s to resolve this issue", CONTACT_ADDRESS);
smfi_setreply(ctx, "554", "5.7.1", reject);
return SMFIS_REJECT;
+ }
+ else{
+ syslog(LOG_NOTICE, "EXTRA SPAM WHITELISTED (%.1f/%.1f), %.3fsec, %s, %s -> %s", context->score, context->threshold, elapsed, context->fqdn, context->from, context->rcpt);
+ }
}
if (REDIRECT_SPAM) {
if (context->rcpts) {
@@ -572,6 +582,7 @@ int main(int argc, char **argv) {
int ret = 0;
regcomp(&re_ignore_connect, ignore_connect, REG_EXTENDED|REG_ICASE);
+ regcomp(&no_re_ignore_connect, no_ignore_connect, REG_EXTENDED|REG_ICASE);
tzset();
openlog("smf-spamd", LOG_PID|LOG_NDELAY, SYSLOG_FACILITY);
if (!strncmp(oconn, "unix:", 5))
Alles weitere zu smf-spamd kann man auf der Seite des Entwicklers nachschaun.
gruss
Andre