diff --new-file -rc ucspi-tcp-0.88.orig/rblsmtpd.c ucspi-tcp-0.88/rblsmtpd.c
*** ucspi-tcp-0.88.orig/rblsmtpd.c	Sat Mar 18 16:18:42 2000
--- ucspi-tcp-0.88/rblsmtpd.c	Mon Jun 18 11:24:16 2001
***************
*** 22,28 ****
  }
  void usage(void)
  {
!   strerr_die1x(100,"rblsmtpd: usage: rblsmtpd [ -b ] [ -R ] [ -t timeout ] [ -r base ] [ -a base ] smtpd [ arg ... ]");
  }
  
  char *ip_env;
--- 22,28 ----
  }
  void usage(void)
  {
!   strerr_die1x(100,"rblsmtpd: usage: rblsmtpd [ -b ] [ -R ] [ -t timeout ] [ -r base[:mesg] ] [ -a base ] [-T trap] smtpd [ arg ... ]");
  }
  
  char *ip_env;
***************
*** 57,75 ****
  static stralloc text; /* defined if decision is 2 or 3 */
  
  static stralloc tmp;
  
  void rbl(char *base)
  {
    if (decision) return;
    if (!stralloc_copy(&tmp,&ip_reverse)) nomem();
    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;
      }
-     return;
    }
    if (text.len)
      if (flagrblbounce)
--- 57,114 ----
  static stralloc text; /* defined if decision is 2 or 3 */
  
  static stralloc tmp;
+ static char *spamtrap = 0;
  
  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 (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;
      }
    }
    if (text.len)
      if (flagrblbounce)
***************
*** 115,124 ****
  , { 0, reject, 0 }
  } ;
  
! void rblsmtpd(void)
  {
    int i;
  
    if (flagmustnotbounce || (decision == 2)) {
      if (!stralloc_copys(&message,"451 ")) nomem();
    }
--- 154,169 ----
  , { 0, reject, 0 }
  } ;
  
! void rblsmtpd(char **argv)
  {
    int i;
  
+   if (spamtrap) {
+     pathexec_env("RELAYCLIENT", spamtrap);
+     pathexec(argv);
+     strerr_die4sys(111,FATAL,"unable to run ",*argv,": ");
+   }
+ 
    if (flagmustnotbounce || (decision == 2)) {
      if (!stralloc_copys(&message,"451 ")) nomem();
    }
***************
*** 175,181 ****
      }
    }
  
!   while ((opt = getopt(argc,argv,"bBcCt:r:a:")) != opteof)
      switch(opt) {
        case 'b': flagrblbounce = 1; break;
        case 'B': flagrblbounce = 0; break;
--- 220,226 ----
      }
    }
  
!   while ((opt = getopt(argc,argv,"bBcCt:r:a:T:")) != opteof)
      switch(opt) {
        case 'b': flagrblbounce = 1; break;
        case 'B': flagrblbounce = 0; break;
***************
*** 184,189 ****
--- 229,235 ----
        case 't': scan_ulong(optarg,&timeout); break;
        case 'r': rbl(optarg); flagwantdefaultrbl = 0; break;
        case 'a': antirbl(optarg); break;
+       case 'T': spamtrap = optarg && *optarg ? optarg : 0; break;
        default: usage();
      }
  
***************
*** 191,197 ****
    if (!*argv) usage();
  
!   if (flagwantdefaultrbl) rbl("rbl.maps.vix.com");
!   if (decision >= 2) rblsmtpd();
  
    pathexec_run(*argv,argv,envp);
    strerr_die4sys(111,FATAL,"unable to run ",*argv,": ");
--- 237,243 ----
    if (!*argv) usage();
  
!   if (flagwantdefaultrbl) rbl("blackholes.mail-abuse.org");
!   if (decision >= 2) rblsmtpd(argv);
  
    pathexec_run(*argv,argv,envp);
    strerr_die4sys(111,FATAL,"unable to run ",*argv,": ");

