From lwiddif@Spydernet.Com Fri Apr 04 20:43:03 1997 X-VM-v5-Data: ([nil nil nil nil nil nil nil nil nil] [nil nil nil nil nil nil nil nil nil nil nil nil "^From:" nil nil nil nil nil nil nil] nil) Return-Path: Delivered-To: nelson@desk.crynwr.com Received: (qmail 29154 invoked from network); 4 Apr 1997 20:43:01 -0000 Received: from ns.crynwr.com (192.203.178.14) by 128.153.44.67 with SMTP; 4 Apr 1997 20:43:01 -0000 Received: (qmail 11598 invoked by uid 501); 4 Apr 1997 19:33:19 -0000 Delivered-To: nelson@crynwr.com Received: (qmail 11594 invoked from network); 4 Apr 1997 19:33:16 -0000 Received: from hades.spydernet.com (HELO mail.spydernet.com) (273@199.60.62.10) by ns.crynwr.com with SMTP; 4 Apr 1997 19:33:10 -0000 Received: (qmail 28608 invoked by uid 105); 4 Apr 1997 20:42:07 -0000 Message-ID: <19970404124206.06571@hades.spydernet.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=FL5UXtIhxfXey3p5 X-Mailer: Mutt 0.66e Reply-To: lwiddif@spydernet.com From: Lionel Widdifield To: Russel Nelson Subject: Qmail SMTPD SPAM diff Date: Fri, 4 Apr 1997 12:42:06 -0800 --FL5UXtIhxfXey3p5 Content-Type: text/plain; charset=us-ascii Russel, I had to add a set of braces to a if statement. Sometimes I really hate Dan's coding style. ;) -- Lionel Widdifield [] Spydernet Communications Systems Inc. [] P.O. Box 8406 lwiddif@spydernet.com [] Victoria BC, Canada V8W 3S1 [] Phone (250)383-2999 Fax 480-7262 --FL5UXtIhxfXey3p5 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=diff --- qmail-smtpd.c Fri Apr 4 12:33:51 1997 +++ orig/qmail-smtpd.c Mon Mar 17 16:53:32 1997 @@ -1,15 +1,8 @@ -#define BADRCPT 1 -#define XLOGGING 1 -#define DENYSPAM 1 -/*zzz Version 0.2*/ #include "signal.h" #include "readwrite.h" #include "getline.h" #include "stralloc.h" #include "substdio.h" -#ifdef XLOGGING -#include "subfd.h" -#endif #include "alloc.h" #include "conf-home.h" #include "control.h" @@ -65,11 +58,6 @@ stralloc bmf = {0}; struct constmap mapbmf; int flagbarf; /* defined if seenmail */ -#ifdef BADRCPT -int brtok = 0; -stralloc brt = {0}; -struct constmap mapbadrcptto; -#endif stralloc helohost = {0}; stralloc mailfrom = {0}; @@ -83,9 +71,6 @@ char *remoteinfo; char *local; char *relayclient; -#ifdef DENYSPAM -char *denymail; -#endif void dohelo(arg) char *arg; { @@ -105,9 +90,6 @@ remoteinfo = env_get("TCPREMOTEINFO"); relayclient = env_get("RELAYCLIENT"); dohelo(remotehost); -#ifdef DENYSPAM - denymail = env_get("DENYMAIL"); -#endif } void straynewline() @@ -248,76 +230,9 @@ return 1; } -#ifdef XLOGGING -static int issafe(ch) char ch; -{ - if (ch == '.') return 1; - if (ch == '@') return 1; - if (ch == '%') return 1; - if (ch == '+') return 1; - if (ch == '/') return 1; - if (ch == '=') return 1; - if (ch == ':') return 1; - if (ch == '-') return 1; - if ((ch >= 'a') && (ch <= 'z')) return 1; - if ((ch >= 'A') && (ch <= 'Z')) return 1; - if ((ch >= '0') && (ch <= '9')) return 1; - return 0; -} - -static void safeErr(s) char *s; -{ - char ch; - while (ch = *s++) { - if (!issafe(ch)) ch = '?'; - substdio_BPUTC(subfderr, ch); - } -} -#ifdef BADRCPT -static void log_brt(s) char *s; -{ - substdio_bputs(subfderr, "BRT: check failed ("); - safeErr(s); - substdio_bputs(subfderr, ")\n"); - substdio_flush(subfderr); -} -#endif -static void log_bmf() -{ - substdio_bputs(subfderr, "BMF: check failed ("); - safeErr(mailfrom.s); - substdio_bputs(subfderr, ")\n"); - substdio_flush(subfderr); -} -#ifdef DENYSPAM -static void log_deny(m,f,t) char *m,*f,*t; -{ - substdio_bputs(subfderr, "DENYMAIL: "); safeErr(m); - substdio_bputs(subfderr, " check failed ("); safeErr(f); - substdio_bputs(subfderr, ") -> ("); safeErr(t); - substdio_bputs(subfderr, ")\n"); - substdio_flush(subfderr); -} -#endif -static void log_helo() -{ - substdio_bputs(subfderr, "Received: from "); - safeErr(remotehost); - substdio_bputs(subfderr, " (HELO "); - safeErr(helohost.s); - substdio_bputs(subfderr, ")\n"); - substdio_flush(subfderr); -} -#endif - int addrallowed() { int j; -#ifdef BADRCPT - if (brtok) - if (constmap(&mapbadrcptto, addr.s, addr.len - 1)) - {log_brt(addr.s); return 0;} -#endif if (!rhok) return 1; j = byte_rchr(addr.s,addr.len,'@'); if (j >= addr.len) return 1; /* can be taken care of by envnoathost */ @@ -336,15 +251,7 @@ if (constmap(&mapbmf,addr.s,addr.len - 1)) { flagbarf = 1; return; } j = byte_rchr(addr.s,addr.len,'@'); if (j < addr.len) -#ifdef DENYSPAM - { -#endif - if (constmap(&mapbmf,addr.s + j,addr.len - j - 1)) { flagbarf = 1; return; } -#ifdef DENYSPAM - /* allow for bulkemailer@ checking */ - if (constmap(&mapbmf,addr.s, j + 1)) { flagbarf = 1; return; } - } -#endif + if (constmap(&mapbmf,addr.s + j,addr.len - j - 1)) flagbarf = 1; } void smtp_greet(code) char *code; { @@ -353,10 +260,7 @@ void smtp_quit() { smtp_greet("221 "); out("\r\n"); die(); } void smtp_help() { out("214-qmail home page: http://pobox.com/~djb/qmail.html\r\n214 send comments to qmail@pobox.com\r\n"); } void err_syntax() { out("555 syntax error (#5.5.4)\r\n"); } -/* zzz - void err_bmf() { out("553 sorry, your envelope sender is in my badmailfrom list (#5.7.1)\r\n"); } -*/ -void err_bmf() { out("553 syntax error, please forward to your postmaster (#5.7.1)\r\n"); } +void err_bmf() { out("553 sorry, your envelope sender is in my badmailfrom list (#5.7.1)\r\n"); } void err_nogateway() { out("553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)\r\n"); } void err_unimpl() { out("502 unimplemented (#5.5.1)\r\n"); } void err_seenmail() { out("503 one MAIL per message (#5.5.1)\r\n"); } @@ -385,7 +289,7 @@ if (!seenmail) { err_wantmail(); return; } if (!arg) { err_syntax(); return; } if (!addrparse(arg)) { err_syntax(); return; } - if (flagbarf) { err_bmf(); log_bmf(); return; } + if (flagbarf) { err_bmf(); return; } if (relayclient) { --addr.len; @@ -394,24 +298,10 @@ } else if (!addrallowed()) { err_nogateway(); return; } -#ifdef DENYSPAM - if (denymail) - /* DENYMAIL is set, so heavy checking of mailfrom and rcptto */ - { - /* at the least they must be rfc compliant sender = user@host */ - if (byte_chr(mailfrom.s,mailfrom.len,'@') >= mailfrom.len) {flagbarf=1;}; - if (!str_diff("SPAM", denymail)) flagbarf=1; - if (!str_diff("NOBOUNCE", denymail)) if (!mailfrom.s[0]) flagbarf=1; - - if (flagbarf) - {log_deny(denymail, mailfrom.s, addr.s); err_bmf(); return;} - } -#endif out("250 ok\r\n"); if (!stralloc_cats(&rcptto,"T")) outofmem(); if (!stralloc_cats(&rcptto,addr.s)) outofmem(); - if (!stralloc_0(&rcptto)) outofmem(); -} + if (!stralloc_0(&rcptto)) outofmem(); } char accept_buf[FMT_ULONG]; void acceptmessage(qp) unsigned long qp; @@ -436,8 +326,7 @@ qp = qqtalk_qp(&qqt); out("354 go ahead\r\n"); - received(&qqt,"SMTP",local,remoteip,remotehost,remoteinfo,(r=case_diffs(remotehost,helohost.s)) ? helohost.s : 0); - if (r) log_helo(); + received(&qqt,"SMTP",local,remoteip,remotehost,remoteinfo,case_diffs(remotehost,helohost.s) ? helohost.s : 0); blast(&ssin,&hops); hops = (hops >= MAXHOPS); if (hops) qqtalk_fail(&qqt); @@ -527,15 +416,6 @@ bmfok = 1; if (!constmap_init(&mapbmf,bmf.s,bmf.len,0)) die(); } -#ifdef BADRCPT - switch(control_readfile(&brt,"control/badrcptto",0)) - { - case -1: die(); - case 1: - brtok = 1; - if (!constmap_init(&mapbadrcptto,brt.s,brt.len,0)) die(); - } -#endif } void main() --FL5UXtIhxfXey3p5-- .