--- qmail-smtpd.c.orig Fri Apr 20 17:23:12 2001 +++ qmail-smtpd.c Fri Apr 20 17:24:54 2001 @@ -186,6 +186,9 @@ char *relayok; char *denymail; char *rblenabled; +#ifdef RBLTAG + char *rbltagenabled; +#endif int spamflag = 0; stralloc helohost = {0}; @@ -207,6 +210,10 @@ struct constmap maprmf; int rblok = 0; stralloc rbl = {0}; +#ifdef RBLTAG +int rbltagok = 0; +stralloc rbltag = {0}; +#endif int tarpitcount = 0; int tarpitdelay = 5; int maxrcptcount = 0; @@ -263,7 +270,14 @@ if (rblok == -1) die_control(); if (rblok) rblenabled = env_get("RBL"); - + +#ifdef RBLTAG + rbltagok = control_readfile(&rbltag,"control/rbltags",0); + if (rbltagok == -1) die_control(); + if (rbltagok) + rbltagenabled = "1"; +#endif + if (control_readint(&databytes,"control/databytes") == -1) die_control(); x = env_get("DATABYTES"); if (x) { scan_ulong(x,&u); databytes = u; } @@ -388,6 +402,9 @@ /* RBL */ stralloc ip_reverse; +#ifdef RBLTAG +stralloc tagrblid; +#endif void rbl_init() { @@ -470,6 +487,38 @@ return r; } +#ifdef RBLTAG +int rblcheck_tag() +{ + int r; + char *p; + rbl_init(); + + p = &rbltag.s[0]; + while(p < &rbltag.s[0]+rbltag.len) + { + logpid(2); logstring(2,"RBL check with '"); logstring(2,p); logstring(2,"':"); + r = rbl_lookup(p); + if (r == 2) + { + logstring(2,"temporary DNS error"); + } + if (r == 1 ) + { + logstring(2,"found match"); + if ( 0 != tagrblid.len ) if (!stralloc_cats(&tagrblid," ")) die_nomem(); + if (!stralloc_cats(&tagrblid,p)) die_nomem(); + } + /* continue */ + logstring(2,"continue"); logflush(); + p = p+strlen(p); + p++; + } + if ( 0 != tagrblid.len ) tagrblid.s[tagrblid.len]='\0'; + return r; +} +#endif + /* RBL */ int sizelimit(arg) @@ -638,7 +687,14 @@ logline(3,"RBL checking completed without match"); } } - +#ifdef RBLTAG + if (rbltagenabled) + { + logline(3,"RBL TAGGING enabled, going through list of RBLs"); + rblcheck_tag(); + } +#endif + /* DENYMAIL is set for this session from this client, so heavy checking * of mailfrom is done. If one of the following is set: * SPAM -> refuse all mail @@ -865,6 +921,37 @@ return r; } +#ifdef RBLTAG +void rblcheckfmt(qqt, rblid) +struct qmail *qqt; +char *rblid; +{ + unsigned int j,k; + + if (!rblid) return; + + j=0; + while ('\0'!=rblid[j] && ' '==rblid[j]) j++; /* eat up whitespace */ + k=j; + while ('\0' != rblid[j]) { + if (' ' == rblid[j]) { + rblid[j] = '\0'; + qmail_puts(qqt,"X-RBL-Check: "); + qmail_puts(qqt,rblid+k); + qmail_puts(qqt,"\n"); + rblid[j] = ' '; + while (' ' == rblid[++j]); /* eat up whitespace */ + k=j; + } else j++; + } + if (j!=k) { + qmail_puts(qqt,"X-RBL-Check: "); + qmail_puts(qqt,rblid+k); + qmail_puts(qqt,"\n"); + } +} +#endif + char ssinbuf[1024]; substdio ssin = SUBSTDIO_FDBUF(saferead,0,ssinbuf,sizeof ssinbuf); @@ -992,6 +1079,9 @@ #else received(&qqt,"SMTP",local,remoteip,remotehost,remoteinfo,fakehelo,mailfrom.s,&rcptto.s[1]); #endif +#ifdef RBLTAG + rblcheckfmt(&qqt, tagrblid.s); +#endif blast(&hops); receivedbytes[fmt_ulong(receivedbytes,(unsigned long) bytesreceived)] = 0;