diff -ruN ucspi-tcp-0.88-factory/rblsmtpd.c ucspi-tcp-0.88-rss2/rblsmtpd.c --- ucspi-tcp-0.88-factory/rblsmtpd.c 2000-03-18 10:18:42.000000000 -0500 +++ ucspi-tcp-0.88-rss2/rblsmtpd.c 2008-12-08 22:54:40.000000000 -0500 @@ -60,16 +60,54 @@ void rbl(char *base) { + int i; + char *altreply = 0; if (decision) return; if (!stralloc_copy(&tmp,&ip_reverse)) nomem(); + i = str_chr(base, ':'); + if (base[i]) { + base[i] = 0; + altreply = base+i+1; + } if (!stralloc_cats(&tmp,base)) nomem(); - if (dns_txt(&text,&tmp) == -1) { - flagmustnotbounce = 1; - if (flagfailclosed) { - if (!stralloc_copys(&text,"temporary RBL lookup error")) nomem(); - decision = 2; + if (altreply) { + if (dns_ip4(&text,&tmp) == -1) { + flagmustnotbounce = 1; + if (flagfailclosed) { + if (!stralloc_copys(&text,"temporary RBL lookup error")) nomem(); + decision = 2; + } + return; + } + if (text.len) { + if(!stralloc_copys(&text, "")) nomem(); + while(*altreply) { + char *x; + i = str_chr(altreply, '%'); + if(!stralloc_catb(&text, altreply, i)) nomem(); + if(altreply[i] && + altreply[i+1]=='I' && + altreply[i+2]=='P' && + altreply[i+3]=='%') { + if(!stralloc_catb(&text, ip_env, str_len(ip_env))) nomem(); + altreply+=i+4; + } else if(altreply[i]) { + if(!stralloc_cats(&text, "%")) nomem(); + altreply+=i+1; + } else { + altreply+=i; + } + } + } + } else { + if (dns_txt(&text,&tmp) == -1) { + flagmustnotbounce = 1; + if (flagfailclosed) { + if (!stralloc_copys(&text,"temporary RBL lookup error")) nomem(); + decision = 2; + } + return; } - return; } if (text.len) if (flagrblbounce) @@ -157,7 +195,7 @@ { int flagwantdefaultrbl = 1; char *x; - int opt; + int opt, i; ip_init(); @@ -174,6 +212,24 @@ decision = 2; } } + if (text.len) { + if(!stralloc_copy(&tmp,&text)) nomem(); + if(!stralloc_0(&tmp)) nomem(); + if(!stralloc_copys(&text, "")) nomem(); + for(x=tmp.s;*x;) { + i = str_chr(x, '%'); + if(!stralloc_catb(&text, x, i)) nomem(); + if(x[i] && x[i+1]=='I' && x[i+2]=='P' && x[i+3]=='%') { + if(!stralloc_catb(&text, ip_env, str_len(ip_env))) nomem(); + x+=i+4; + } else if(x[i]) { + if(!stralloc_cats(&text, "%")) nomem(); + x+=i+1; + } else { + x+=i; + } + } + } while ((opt = getopt(argc,argv,"bBcCt:r:a:")) != opteof) switch(opt) {