[exim-cvs] cvs commit: exim/exim-src/src EDITME acl.c confi…

Página Inicial
Delete this message
Reply to this message
Autor: Tom Kistner
Data:  
Para: exim-cvs
Assunto: [exim-cvs] cvs commit: exim/exim-src/src EDITME acl.c config.h.defaults deliver.c exim.c exim.h expand.c globals.c globals.h local_scan.h readconf.c receive.c route.c smtp_in.c spool_in.c spool_out
tom 2004/12/10 14:59:08 GMT

  Modified files:        (Branch: EXISCAN)
    exim-src/src         EDITME acl.c config.h.defaults deliver.c 
                         exim.c exim.h expand.c globals.c 
                         globals.h local_scan.h readconf.c 
                         receive.c route.c smtp_in.c spool_in.c 
                         spool_out.c structs.h 
    exim-src/src/routers redirect.c redirect.h 
  Log:
  Added experimental features


  Revision  Changes    Path
  1.4.2.3   +24 -0     exim/exim-src/src/EDITME
  1.5.2.5   +90 -7     exim/exim-src/src/acl.c
  1.2.2.4   +5 -0      exim/exim-src/src/config.h.defaults
  1.2.2.1   +20 -0     exim/exim-src/src/deliver.c
  1.9.2.3   +9 -0      exim/exim-src/src/exim.c
  1.2.2.3   +10 -0     exim/exim-src/src/exim.h
  1.7.2.2   +20 -0     exim/exim-src/src/expand.c
  1.6.2.5   +32 -0     exim/exim-src/src/globals.c
  1.6.2.4   +24 -1     exim/exim-src/src/globals.h
  1.1.2.2   +3 -0      exim/exim-src/src/local_scan.h
  1.2.2.2   +6 -0      exim/exim-src/src/readconf.c
  1.4.2.4   +13 -0     exim/exim-src/src/receive.c
  1.1.2.1   +50 -0     exim/exim-src/src/route.c
  1.2.2.1   +79 -0     exim/exim-src/src/routers/redirect.c
  1.1.2.1   +7 -0      exim/exim-src/src/routers/redirect.h
  1.5.2.3   +15 -0     exim/exim-src/src/smtp_in.c
  1.1.2.2   +10 -1     exim/exim-src/src/spool_in.c
  1.1.2.2   +4 -0      exim/exim-src/src/spool_out.c
  1.1.2.1   +8 -0      exim/exim-src/src/structs.h


  Index: EDITME
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/EDITME,v
  retrieving revision 1.4.2.2
  retrieving revision 1.4.2.3
  diff -u -r1.4.2.2 -r1.4.2.3
  --- EDITME    2 Dec 2004 09:15:11 -0000    1.4.2.2
  +++ EDITME    10 Dec 2004 14:59:08 -0000    1.4.2.3
  @@ -1,4 +1,4 @@
  -# $Cambridge: exim/exim-src/src/EDITME,v 1.4.2.2 2004/12/02 09:15:11 tom Exp $
  +# $Cambridge: exim/exim-src/src/EDITME,v 1.4.2.3 2004/12/10 14:59:08 tom Exp $


   ##################################################
   #          The Exim mail transport agent         #
  @@ -330,6 +330,30 @@


#WITH_OLD_DEMIME=yes

+#------------------------------------------------------------------------------
+# Compiling Exim with experimental features. These are documented in
+# experimental-spec.txt. "Experimental" means that the way these features are
+# implemented may still change. Backward compatability is not guaranteed.
+
+# Uncomment the following lines to add SPF support. You need to have libspf2
+# installed on your system (www.libspf2.org). Depending on where it is installed
+# you may have to edit the EXPERIMENTAL_CFLAGS line.
+#EXPERIMENTAL_SPF=yes
+#EXPERIMENTAL_CFLAGS=$EXPERIMENTAL_CFLAGS -lspf2 -I/usr/local/include
+
+# Uncommend the following lines to add SRS (Sender rewriting scheme) support.
+# You need to have libsrs_alt installed on your system (srs.mirtol.com).
+# Depending on where it is installed you may have to edit the EXPERIMENTAL_CFLAGS
+# line.
+#EXPERIMENTAL_SRS=yes
+#EXPERIMENTAL_CFLAGS=$EXPERIMENTAL_CFLAGS -lsrs_alt -I/usr/local/include
+
+# Uncommend the following lines to add Brightmail AntiSpam support. You need
+# to have the Brightmail client SDK installed. Please check the experimental
+# documentation for implementation details. You need to edit the EXPERIMENTAL_CFLAGS
+# line.
+#EXPERIMENTAL_BRIGHTMAIL=yes
+#EXPERIMENTAL_CFLAGS=$EXPERIMENTAL_CFLAGS -lxml2 -lbmiclient_single -I/path/to/include -L/path/to/lib




  Index: acl.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/acl.c,v
  retrieving revision 1.5.2.4
  retrieving revision 1.5.2.5
  diff -u -r1.5.2.4 -r1.5.2.5
  --- acl.c    10 Dec 2004 09:24:38 -0000    1.5.2.4
  +++ acl.c    10 Dec 2004 14:59:08 -0000    1.5.2.5
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/acl.c,v 1.5.2.4 2004/12/10 09:24:38 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/acl.c,v 1.5.2.5 2004/12/10 14:59:08 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -34,7 +34,11 @@
   /* ACL condition and modifier codes - keep in step with the table that
   follows. */


  -enum { ACLC_ACL, ACLC_AUTHENTICATED, ACLC_CONDITION, ACLC_CONTROL,
  +enum { ACLC_ACL, ACLC_AUTHENTICATED,
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +       ACLC_BMI_OPTIN,
  +#endif
  +ACLC_CONDITION, ACLC_CONTROL,
   #ifdef WITH_CONTENT_SCAN
          ACLC_DECODE,
   #endif
  @@ -59,13 +63,20 @@
   #ifdef WITH_CONTENT_SCAN
          ACLC_SPAM,       
   #endif
  +#ifdef EXPERIMENTAL_SPF
  +       ACLC_SPF,
  +#endif
          ACLC_VERIFY };


/* ACL conditions/modifiers: "delay", "control", "endpass", "message",
"log_message", "logwrite", and "set" are modifiers that look like conditions
but always return TRUE. They are used for their side effects. */

  -static uschar *conditions[] = { US"acl", US"authenticated", US"condition",
  +static uschar *conditions[] = { US"acl", US"authenticated",
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +  US"bmi_optin",
  +#endif
  +  US"condition",
     US"control", 
   #ifdef WITH_CONTENT_SCAN
     US"decode",
  @@ -91,6 +102,9 @@
   #ifdef WITH_CONTENT_SCAN
     US"spam",
   #endif
  +#ifdef EXPERIMENTAL_SPF
  +  US"spf",
  +#endif
     US"verify" };


   /* ACL control names */
  @@ -106,6 +120,9 @@
   static uschar cond_expand_at_top[] = {
     TRUE,    /* acl */
     FALSE,   /* authenticated */
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +  TRUE,    /* bmi_optin */
  +#endif  
     TRUE,    /* condition */
     TRUE,    /* control */
   #ifdef WITH_CONTENT_SCAN
  @@ -140,6 +157,9 @@
   #ifdef WITH_CONTENT_SCAN
     TRUE,    /* spam */
   #endif
  +#ifdef EXPERIMENTAL_SPF
  +  TRUE,    /* spf */
  +#endif
     TRUE     /* verify */
   };


  @@ -148,6 +168,9 @@
   static uschar cond_modifiers[] = {
     FALSE,   /* acl */
     FALSE,   /* authenticated */
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +  TRUE,    /* bmi_optin */
  +#endif  
     FALSE,   /* condition */
     TRUE,    /* control */
   #ifdef WITH_CONTENT_SCAN
  @@ -182,6 +205,9 @@
   #ifdef WITH_CONTENT_SCAN
     FALSE,   /* spam */
   #endif
  +#ifdef EXPERIMENTAL_SPF
  +  FALSE,   /* spf */
  +#endif
     FALSE    /* verify */
   };


  @@ -192,13 +218,24 @@
     0,                                               /* acl */
     (1<<ACL_WHERE_NOTSMTP)|(1<<ACL_WHERE_CONNECT)|   /* authenticated */
       (1<<ACL_WHERE_HELO),
  +  
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +  (1<<ACL_WHERE_NOTSMTP)|(1<<ACL_WHERE_AUTH)|      /* bmi_optin */
  +    (1<<ACL_WHERE_CONNECT)|(1<<ACL_WHERE_HELO)|
  +    (1<<ACL_WHERE_DATA)|(1<<ACL_WHERE_MIME)|
  +    (1<<ACL_WHERE_ETRN)|(1<<ACL_WHERE_EXPN)|                                       
  +    (1<<ACL_WHERE_MAILAUTH)|
  +    (1<<ACL_WHERE_MAIL)|(1<<ACL_WHERE_STARTTLS)|
  +    (1<<ACL_WHERE_VRFY)|(1<<ACL_WHERE_PREDATA),
  +#endif
  +  
     0,                                               /* condition */
  -
  +  
     /* Certain types of control are always allowed, so we let it through
     always and check in the control processing itself */
  -
  +  
     0,                                               /* control */
  -
  +  
   #ifdef WITH_CONTENT_SCAN
     (1<<ACL_WHERE_NOTSMTP)|(1<<ACL_WHERE_AUTH)|      /* decode */
       (1<<ACL_WHERE_CONNECT)|(1<<ACL_WHERE_HELO)|
  @@ -311,6 +348,14 @@
       (1<<ACL_WHERE_VRFY)|(1<<ACL_WHERE_MIME),
   #endif


  +#ifdef EXPERIMENTAL_SPF
  +  (1<<ACL_WHERE_AUTH)|(1<<ACL_WHERE_CONNECT)|      /* spf */
  +    (1<<ACL_WHERE_HELO)|
  +    (1<<ACL_WHERE_MAILAUTH)|
  +    (1<<ACL_WHERE_ETRN)|(1<<ACL_WHERE_EXPN)|
  +    (1<<ACL_WHERE_STARTTLS)|(1<<ACL_WHERE_VRFY),
  +#endif
  +
     /* Certain types of verify are always allowed, so we let it through
     always and check in the verify function itself */


@@ -320,7 +365,11 @@

/* Return values from decode_control() */

  -enum { CONTROL_ERROR, CONTROL_CASEFUL_LOCAL_PART, CONTROL_CASELOWER_LOCAL_PART,
  +enum { 
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +  CONTROL_BMI_RUN,
  +#endif  
  +  CONTROL_ERROR, CONTROL_CASEFUL_LOCAL_PART, CONTROL_CASELOWER_LOCAL_PART,
     CONTROL_ENFORCE_SYNC, CONTROL_NO_ENFORCE_SYNC, CONTROL_FREEZE,
     CONTROL_QUEUE_ONLY, CONTROL_SUBMISSION,
   #ifdef WITH_CONTENT_SCAN
  @@ -333,6 +382,9 @@
   specify the negation of a small number of allowed times. */


   static unsigned int control_forbids[] = {
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +  0,                                               /* bmi_run */
  +#endif
     0,                                               /* error */
     ~(1<<ACL_WHERE_RCPT),                            /* caseful_local_part */
     ~(1<<ACL_WHERE_RCPT),                            /* caselower_local_part */
  @@ -367,6 +419,9 @@
   } control_def;


   static control_def controls_list[] = {
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +  { US"bmi_run",                CONTROL_BMI_RUN, FALSE},
  +#endif
     { US"caseful_local_part",     CONTROL_CASEFUL_LOCAL_PART, FALSE},
     { US"caselower_local_part",   CONTROL_CASELOWER_LOCAL_PART, FALSE},
     { US"enforce_sync",           CONTROL_ENFORCE_SYNC, FALSE},
  @@ -703,6 +758,11 @@
           newtype = htype_add_rec;
           p += 16;
           }
  +      else if (strncmpic(p, US":at_start_rfc:", 14) == 0)
  +        {
  +        newtype = htype_add_rfc;
  +        p += 14;
  +        }        
         else if (strncmpic(p, US":at_start:", 10) == 0)
           {
           newtype = htype_add_top;
  @@ -1519,6 +1579,17 @@
           TRUE, NULL);
       break;


  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +    case ACLC_BMI_OPTIN:
  +      {
  +      int old_pool = store_pool;
  +      store_pool = POOL_PERM;
  +      bmi_current_optin = string_copy(arg);
  +      store_pool = old_pool;
  +      }
  +    break;
  +#endif
  +
       case ACLC_CONDITION:
       if (Ustrspn(arg, "0123456789") == Ustrlen(arg))     /* Digits, or empty */
         rc = (Uatoi(arg) == 0)? FAIL : OK;
  @@ -1534,7 +1605,7 @@
       case ACLC_CONTROL:
       control_type = decode_control(arg, &p, where, log_msgptr);


  -    /* Check this control makes sense at this time */
  +    /* Check if this control makes sense at this time */


       if ((control_forbids[control_type] & (1 << where)) != 0)
         {
  @@ -1545,6 +1616,12 @@


       switch(control_type)
         {
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +      case CONTROL_BMI_RUN:
  +      bmi_run = 1;
  +      break;
  +#endif
  +      
         case CONTROL_ERROR:
         return ERROR;


  @@ -1822,6 +1899,12 @@
             }
           }
         }
  +    break;
  +#endif
  +
  +#ifdef EXPERIMENTAL_SPF
  +    case ACLC_SPF:
  +      rc = spf_process(&arg, sender_address);
       break;
   #endif



  Index: config.h.defaults
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/config.h.defaults,v
  retrieving revision 1.2.2.3
  retrieving revision 1.2.2.4
  diff -u -r1.2.2.3 -r1.2.2.4
  --- config.h.defaults    2 Dec 2004 16:33:30 -0000    1.2.2.3
  +++ config.h.defaults    10 Dec 2004 14:59:08 -0000    1.2.2.4
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/config.h.defaults,v 1.2.2.3 2004/12/02 16:33:30 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/config.h.defaults,v 1.2.2.4 2004/12/10 14:59:08 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -140,6 +140,11 @@


#define WITH_CONTENT_SCAN
#define WITH_OLD_DEMIME
+
+/* EXPERIMENTAL features */
+#define EXPERIMENTAL_SPF
+#define EXPERIMENTAL_SRS
+#define EXPERIMENTAL_BRIGHTMAIL

/* Things that are not routinely changed but are nevertheless configurable
just in case. */

  Index: deliver.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/deliver.c,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- deliver.c    18 Nov 2004 10:35:19 -0000    1.2
  +++ deliver.c    10 Dec 2004 14:59:08 -0000    1.2.2.1
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/deliver.c,v 1.2 2004/11/18 10:35:19 ph10 Exp $ */
  +/* $Cambridge: exim/exim-src/src/deliver.c,v 1.2.2.1 2004/12/10 14:59:08 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -156,6 +156,13 @@
   deliver_domain = addr->domain;
   self_hostname = addr->self_hostname;


  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +bmi_deliver = 1;    /* deliver by default */
  +bmi_alt_location = NULL;
  +bmi_base64_verdict = NULL;
  +bmi_base64_tracker_verdict = NULL;
  +#endif
  +
   /* If there's only one address we can set everything. */


   if (addr->next == NULL)
  @@ -205,6 +212,19 @@
         deliver_localpart_suffix = addr->parent->suffix;
         }
       }
  +
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +    /* Set expansion variables related to Brightmail AntiSpam */
  +    bmi_base64_verdict = bmi_get_base64_verdict(deliver_localpart_orig, deliver_domain_orig);
  +    bmi_base64_tracker_verdict = bmi_get_base64_tracker_verdict(bmi_base64_verdict);
  +    /* get message delivery status (0 - don't deliver | 1 - deliver) */
  +    bmi_deliver = bmi_get_delivery_status(bmi_base64_verdict);
  +    /* if message is to be delivered, get eventual alternate location */
  +    if (bmi_deliver == 1) {
  +      bmi_alt_location = bmi_get_alt_location(bmi_base64_verdict);
  +    };
  +#endif
  +
     }


/* For multiple addresses, don't set local part, and leave the domain and

  Index: exim.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/exim.c,v
  retrieving revision 1.9.2.2
  retrieving revision 1.9.2.3
  diff -u -r1.9.2.2 -r1.9.2.3
  --- exim.c    2 Dec 2004 16:33:30 -0000    1.9.2.2
  +++ exim.c    10 Dec 2004 14:59:08 -0000    1.9.2.3
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/exim.c,v 1.9.2.2 2004/12/02 16:33:30 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/exim.c,v 1.9.2.3 2004/12/10 14:59:08 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -844,6 +844,15 @@
   #endif
   #ifdef WITH_OLD_DEMIME
     fprintf(f, " Old_Demime");
  +#endif
  +#ifdef EXPERIMENTAL_SPF
  +  fprintf(f, " Experimental_SPF");
  +#endif
  +#ifdef EXPERIMENTAL_SRS
  +  fprintf(f, " Experimental_SRS");
  +#endif
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +  fprintf(f, " Experimental_Brightmail");
   #endif
   fprintf(f, "\n");



  Index: exim.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/exim.h,v
  retrieving revision 1.2.2.2
  retrieving revision 1.2.2.3
  diff -u -r1.2.2.2 -r1.2.2.3
  --- exim.h    2 Dec 2004 16:33:30 -0000    1.2.2.2
  +++ exim.h    10 Dec 2004 14:59:08 -0000    1.2.2.3
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/exim.h,v 1.2.2.2 2004/12/02 16:33:30 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/exim.h,v 1.2.2.3 2004/12/10 14:59:08 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -395,6 +395,16 @@
   #include "functions.h"
   #include "dbfunctions.h"
   #include "osfunctions.h"
  +
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +#include "bmi_spam.h"
  +#endif
  +#ifdef EXPERIMENTAL_SPF
  +#include "spf.h"
  +#endif
  +#ifdef EXPERIMENTAL_SRS
  +#include "srs.h"
  +#endif


/* The following stuff must follow the inclusion of config.h because it
requires various things that are set therein. */

  Index: expand.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/expand.c,v
  retrieving revision 1.7.2.1
  retrieving revision 1.7.2.2
  diff -u -r1.7.2.1 -r1.7.2.2
  --- expand.c    2 Dec 2004 09:15:11 -0000    1.7.2.1
  +++ expand.c    10 Dec 2004 14:59:08 -0000    1.7.2.2
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/expand.c,v 1.7.2.1 2004/12/02 09:15:11 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/expand.c,v 1.7.2.2 2004/12/10 14:59:08 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -318,6 +318,12 @@
     { "authenticated_id",    vtype_stringptr,   &authenticated_id },
     { "authenticated_sender",vtype_stringptr,   &authenticated_sender },
     { "authentication_failed",vtype_int,        &authentication_failed },
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +  { "bmi_alt_location",    vtype_stringptr,   &bmi_alt_location },
  +  { "bmi_base64_tracker_verdict", vtype_stringptr, &bmi_base64_tracker_verdict },
  +  { "bmi_base64_verdict",  vtype_stringptr,   &bmi_base64_verdict },
  +  { "bmi_deliver",         vtype_int,         &bmi_deliver },
  +#endif
     { "body_linecount",      vtype_int,         &body_linecount },
     { "body_zerocount",      vtype_int,         &body_zerocount },
     { "bounce_recipient",    vtype_stringptr,   &bounce_recipient },
  @@ -461,9 +467,23 @@
     { "spam_score",          vtype_stringptr,   &spam_score },
     { "spam_score_int",      vtype_stringptr,   &spam_score_int },
   #endif
  +#ifdef EXPERIMENTAL_SPF
  +  { "spf_header_comment",  vtype_stringptr,   &spf_header_comment },
  +  { "spf_received",        vtype_stringptr,   &spf_received },
  +  { "spf_result",          vtype_stringptr,   &spf_result },
  +  { "spf_smtp_comment",    vtype_stringptr,   &spf_smtp_comment },
  +#endif
     { "spool_directory",     vtype_stringptr,   &spool_directory },
     { "spool_inodes",        vtype_pinodes,     (void *)TRUE },
     { "spool_space",         vtype_pspace,      (void *)TRUE },  
  +#ifdef EXPERIMENTAL_SRS
  +  { "srs_db_address",      vtype_stringptr,   &srs_db_address },
  +  { "srs_db_key",          vtype_stringptr,   &srs_db_key },
  +  { "srs_orig_recipient",  vtype_stringptr,   &srs_orig_recipient },
  +  { "srs_orig_sender",     vtype_stringptr,   &srs_orig_sender },
  +  { "srs_recipient",       vtype_stringptr,   &srs_recipient },
  +  { "srs_status",          vtype_stringptr,   &srs_status },
  +#endif
     { "thisaddress",         vtype_stringptr,   &filter_thisaddress },
     { "tls_certificate_verified", vtype_int,    &tls_certificate_verified },
     { "tls_cipher",          vtype_stringptr,   &tls_cipher },


  Index: globals.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/globals.c,v
  retrieving revision 1.6.2.4
  retrieving revision 1.6.2.5
  diff -u -r1.6.2.4 -r1.6.2.5
  --- globals.c    10 Dec 2004 09:24:38 -0000    1.6.2.4
  +++ globals.c    10 Dec 2004 14:59:08 -0000    1.6.2.5
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/globals.c,v 1.6.2.4 2004/12/10 09:24:38 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/globals.c,v 1.6.2.5 2004/12/10 14:59:08 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -328,6 +328,15 @@
   uschar *bi_command             = NULL;
   uschar *big_buffer             = NULL;
   int     big_buffer_size        = BIG_BUFFER_SIZE;
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +uschar *bmi_alt_location       = NULL;
  +uschar *bmi_base64_tracker_verdict = NULL;
  +uschar *bmi_base64_verdict     = NULL;
  +uschar *bmi_config_file        = US"/opt/brightmail/etc/brightmail.cfg";
  +int     bmi_deliver            = 1;
  +int     bmi_run                = 0;
  +uschar *bmi_verdicts           = NULL;
  +#endif
   int     body_linecount         = 0;
   int     body_zerocount         = 0;
   uschar *bounce_message_file    = NULL;
  @@ -834,6 +843,9 @@
       NULL,                      /* driver name */


       NULL,                      /* address_data */
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +    NULL,                      /* bmi_rule */
  +#endif    
       NULL,                      /* cannot_route_message */
       NULL,                      /* condition */
       NULL,                      /* current_directory */
  @@ -862,6 +874,11 @@
       NULL,                      /* transport_name */


       TRUE,                      /* address_test */
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +    FALSE,                     /* bmi_deliver_alternate */
  +    FALSE,                     /* bmi_deliver_default */
  +    FALSE,                     /* bmi_dont_deliver */
  +#endif
       TRUE,                      /* expn */
       FALSE,                     /* caseful_local_part */
       FALSE,                     /* check_local_user */
  @@ -998,10 +1015,25 @@
   uschar *spam_score             = NULL;
   uschar *spam_score_int         = NULL;
   #endif
  +#ifdef EXPERIMENTAL_SPF
  +uschar *spf_header_comment     = NULL;
  +uschar *spf_received           = NULL;
  +uschar *spf_result             = NULL;
  +uschar *spf_smtp_comment       = NULL;
  +#endif


   BOOL    split_spool_directory  = FALSE;
   uschar *spool_directory        = US SPOOL_DIRECTORY
                              "\0<--------------Space to patch spool_directory->";
  +#ifdef EXPERIMENTAL_SRS
  +uschar *srs_config             = NULL;
  +uschar *srs_db_address         = NULL;
  +uschar *srs_db_key             = NULL;
  +uschar *srs_orig_recipient     = NULL;
  +uschar *srs_orig_sender        = NULL;
  +uschar *srs_recipient          = NULL;
  +uschar *srs_status             = NULL;
  +#endif      
   int     string_datestamp_offset= -1;
   BOOL    strip_excess_angle_brackets = FALSE;
   BOOL    strip_trailing_dot     = FALSE;


  Index: globals.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/globals.h,v
  retrieving revision 1.6.2.3
  retrieving revision 1.6.2.4
  diff -u -r1.6.2.3 -r1.6.2.4
  --- globals.h    10 Dec 2004 09:24:38 -0000    1.6.2.3
  +++ globals.h    10 Dec 2004 14:59:08 -0000    1.6.2.4
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/globals.h,v 1.6.2.3 2004/12/10 09:24:38 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/globals.h,v 1.6.2.4 2004/12/10 14:59:08 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -156,6 +156,15 @@
   extern uschar *bi_command;             /* Command for -bi option */
   extern uschar *big_buffer;             /* Used for various temp things */
   extern int     big_buffer_size;        /* Current size (can expand) */
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +extern uschar *bmi_alt_location;       /* expansion variable that contains the alternate location for the rcpt (available during routing) */
  +extern uschar *bmi_base64_tracker_verdict; /* expansion variable with base-64 encoded OLD verdict string (available during routing) */
  +extern uschar *bmi_base64_verdict;     /* expansion variable with base-64 encoded verdict string (available during routing) */
  +extern uschar *bmi_config_file;        /* Brightmail config file */
  +extern int     bmi_deliver;            /* Flag that determines if the message should be delivered to the rcpt (available during routing) */
  +extern int     bmi_run;                /* Flag that determines if message should be run through Brightmail server */
  +extern uschar *bmi_verdicts;           /* BASE64-encoded verdicts with recipient lists */
  +#endif
   extern int     body_linecount;         /* Line count in body */
   extern int     body_zerocount;         /* Binary zero count in body */
   extern uschar *bounce_message_file;    /* Template file */
  @@ -612,9 +621,23 @@
   extern uschar *spam_score;             /* the spam score (float) */
   extern uschar *spam_score_int;         /* spam_score * 10 (int) */
   #endif
  -
  +#ifdef EXPERIMENTAL_SPF
  +extern uschar *spf_header_comment;     /* spf header comment */
  +extern uschar *spf_received;           /* SPF-Received: header */
  +extern uschar *spf_result;             /* spf result in string form */
  +extern uschar *spf_smtp_comment;       /* spf comment to include in SMTP reply */
  +#endif
   extern BOOL    split_spool_directory;  /* TRUE to use multiple subdirs */
   extern uschar *spool_directory;        /* Name of spool directory */
  +#ifdef EXPERIMENTAL_SRS
  +extern uschar *srs_config;             /* SRS config secret:max age:hash length:use timestamp:use hash */
  +extern uschar *srs_db_address;         /* SRS db address */
  +extern uschar *srs_db_key;             /* SRS db key */
  +extern uschar *srs_orig_sender;        /* SRS original sender */
  +extern uschar *srs_orig_recipient;     /* SRS original recipient */
  +extern uschar *srs_recipient;          /* SRS recipient */
  +extern uschar *srs_status;             /* SRS staus */
  +#endif
   extern int     string_datestamp_offset;/* After insertion by string_format */
   extern BOOL    strip_excess_angle_brackets; /* Surrounding route-addrs */
   extern BOOL    strip_trailing_dot;     /* Remove dots at ends of domains */


  Index: local_scan.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/local_scan.h,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- local_scan.h    2 Dec 2004 09:15:11 -0000    1.1.2.1
  +++ local_scan.h    10 Dec 2004 14:59:08 -0000    1.1.2.2
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/local_scan.h,v 1.1.2.1 2004/12/02 09:15:11 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/local_scan.h,v 1.1.2.2 2004/12/10 14:59:08 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -109,6 +109,9 @@
     uschar *address;              /* the recipient address */
     int     pno;                  /* parent number for "one_time" alias, or -1 */
     uschar *errors_to;            /* the errors_to address or NULL */
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +  uschar *bmi_optin;
  +#endif
   } recipient_item;




  Index: readconf.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/readconf.c,v
  retrieving revision 1.2.2.1
  retrieving revision 1.2.2.2
  diff -u -r1.2.2.1 -r1.2.2.2
  --- readconf.c    2 Dec 2004 09:15:11 -0000    1.2.2.1
  +++ readconf.c    10 Dec 2004 14:59:08 -0000    1.2.2.2
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/readconf.c,v 1.2.2.1 2004/12/02 09:15:11 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/readconf.c,v 1.2.2.2 2004/12/10 14:59:08 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -163,6 +163,9 @@
     { "av_scanner",               opt_stringptr,   &av_scanner },
   #endif
     { "bi_command",               opt_stringptr,   &bi_command },
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +  { "bmi_config_file",          opt_stringptr,   &bmi_config_file },
  +#endif
     { "bounce_message_file",      opt_stringptr,   &bounce_message_file },
     { "bounce_message_text",      opt_stringptr,   &bounce_message_text },
     { "bounce_return_body",       opt_bool,        &bounce_return_body },
  @@ -329,6 +332,9 @@
   #endif
     { "split_spool_directory",    opt_bool,        &split_spool_directory },
     { "spool_directory",          opt_stringptr,   &spool_directory },
  +#ifdef EXPERIMENTAL_SRS
  +  { "srs_config",               opt_stringptr,   &srs_config },
  +#endif
     { "strip_excess_angle_brackets", opt_bool,     &strip_excess_angle_brackets },
     { "strip_trailing_dot",       opt_bool,        &strip_trailing_dot },
     { "syslog_duplication",       opt_bool,        &syslog_duplication },


  Index: receive.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/receive.c,v
  retrieving revision 1.4.2.3
  retrieving revision 1.4.2.4
  diff -u -r1.4.2.3 -r1.4.2.4
  --- receive.c    10 Dec 2004 09:24:38 -0000    1.4.2.3
  +++ receive.c    10 Dec 2004 14:59:08 -0000    1.4.2.4
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/receive.c,v 1.4.2.3 2004/12/10 09:24:38 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/receive.c,v 1.4.2.4 2004/12/10 14:59:08 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -470,6 +470,11 @@


recipients_list[recipients_count].address = recipient;
recipients_list[recipients_count].pno = pno;
+#ifdef EXPERIMENTAL_BRIGHTMAIL
+recipients_list[recipients_count].bmi_optin = bmi_current_optin;
+/* reset optin string pointer for next recipient */
+bmi_current_optin = NULL;
+#endif
recipients_list[recipients_count++].errors_to = NULL;
}

@@ -3094,6 +3099,14 @@
/* Ensure the first time flag is set in the newly-received message. */

deliver_firsttime = TRUE;
+
+#ifdef EXPERIMENTAL_BRIGHTMAIL
+if (bmi_run == 1) {
+ /* rewind data file */
+ lseek(data_fd, (long int)SPOOL_DATA_START_OFFSET, SEEK_SET);
+ bmi_verdicts = bmi_process_message(header_list, data_fd);
+};
+#endif

/* Update the timstamp in our Received: header to account for any time taken by
an ACL or by local_scan(). The new time is the time that all reception

  Index: route.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/route.c,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- route.c    7 Oct 2004 10:39:01 -0000    1.1
  +++ route.c    10 Dec 2004 14:59:08 -0000    1.1.2.1
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/route.c,v 1.1 2004/10/07 10:39:01 ph10 Exp $ */
  +/* $Cambridge: exim/exim-src/src/route.c,v 1.1.2.1 2004/12/10 14:59:08 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -34,6 +34,16 @@
                    (void *)(offsetof(router_instance, address_data)) },
     { "address_test",       opt_bool|opt_public,
                    (void *)(offsetof(router_instance, address_test)) },
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +  { "bmi_deliver_alternate",   opt_bool | opt_public,
  +                 (void *)(offsetof(router_instance, bmi_deliver_alternate)) },
  +  { "bmi_deliver_default",   opt_bool | opt_public,
  +                 (void *)(offsetof(router_instance, bmi_deliver_default)) },
  +  { "bmi_dont_deliver",   opt_bool | opt_public,
  +                 (void *)(offsetof(router_instance, bmi_dont_deliver)) },
  +  { "bmi_rule",           opt_stringptr|opt_public,
  +                 (void *)(offsetof(router_instance, bmi_rule)) },
  +#endif
     { "cannot_route_message", opt_stringptr | opt_public,
                    (void *)(offsetof(router_instance, cannot_route_message)) },
     { "caseful_local_part", opt_bool | opt_public,
  @@ -981,6 +991,46 @@
       return SKIP;
       }
     }
  +
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +/* check if a specific Brightmail AntiSpam rule fired on the message */
  +if (r->bmi_rule != NULL) {
  +  DEBUG(D_route) debug_printf("checking bmi_rule\n");
  +  if (bmi_check_rule(bmi_base64_verdict, r->bmi_rule) == 0) {
  +    /* none of the rules fired */
  +    DEBUG(D_route)
  +      debug_printf("%s router skipped: none of bmi_rule rules fired\n", r->name);
  +    return SKIP;
  +  };
  +};
  +
  +/* check if message should not be delivered */
  +if (r->bmi_dont_deliver) {
  +  if (bmi_deliver == 1) {
  +    DEBUG(D_route)
  +      debug_printf("%s router skipped: bmi_dont_deliver is FALSE\n", r->name);
  +    return SKIP;
  +  };
  +};
  +
  +/* check if message should go to an alternate location */
  +if (r->bmi_deliver_alternate) {
  +  if ((bmi_deliver == 0) || (bmi_alt_location == NULL)) {
  +    DEBUG(D_route)
  +      debug_printf("%s router skipped: bmi_deliver_alternate is FALSE\n", r->name);
  +    return SKIP;
  +  };
  +};
  +
  +/* check if message should go to default location */
  +if (r->bmi_deliver_default) {
  +  if ((bmi_deliver == 0) || (bmi_alt_location != NULL)) {
  +    DEBUG(D_route)
  +      debug_printf("%s router skipped: bmi_deliver_default is FALSE\n", r->name);
  +    return SKIP;
  +  };
  +};
  +#endif


/* All the checks passed. */


  Index: smtp_in.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/smtp_in.c,v
  retrieving revision 1.5.2.2
  retrieving revision 1.5.2.3
  diff -u -r1.5.2.2 -r1.5.2.3
  --- smtp_in.c    2 Dec 2004 16:33:30 -0000    1.5.2.2
  +++ smtp_in.c    10 Dec 2004 14:59:08 -0000    1.5.2.3
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/smtp_in.c,v 1.5.2.2 2004/12/02 16:33:30 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/smtp_in.c,v 1.5.2.3 2004/12/10 14:59:08 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -819,6 +819,16 @@
   memset(sender_address_cache, 0, sizeof(sender_address_cache));
   memset(sender_domain_cache, 0, sizeof(sender_domain_cache));
   authenticated_sender = NULL;
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +bmi_run = 0;
  +bmi_verdicts = NULL;
  +#endif
  +#ifdef EXPERIMENTAL_SPF
  +spf_header_comment = NULL;
  +spf_received = NULL;
  +spf_result = NULL;  
  +spf_smtp_comment = NULL;
  +#endif
   body_linecount = body_zerocount = 0;


   for (i = 0; i < ACL_M_MAX; i++) acl_var[ACL_C_MAX + i] = NULL;
  @@ -2350,6 +2360,11 @@
             }
           }
         }
  +
  +#ifdef EXPERIMENTAL_SPF
  +    /* set up SPF context */
  +    spf_init(sender_helo_name, sender_host_address);
  +#endif


       /* Apply an ACL check if one is defined */



  Index: spool_in.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/spool_in.c,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- spool_in.c    2 Dec 2004 09:15:11 -0000    1.1.2.1
  +++ spool_in.c    10 Dec 2004 14:59:08 -0000    1.1.2.2
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/spool_in.c,v 1.1.2.1 2004/12/02 09:15:11 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/spool_in.c,v 1.1.2.2 2004/12/10 14:59:08 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -271,6 +271,11 @@
   sender_set_untrusted = FALSE;
   tree_nonrecipients = NULL;


  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +bmi_run = 0;
  +bmi_verdicts = NULL;
  +#endif
  +
   #ifdef SUPPORT_TLS
   tls_certificate_verified = FALSE;
   tls_cipher = NULL;
  @@ -377,7 +382,11 @@
   #ifdef WITH_CONTENT_SCAN    
     else if (Ustrncmp(big_buffer, "-spam_score_int ", 16) == 0)
       spam_score_int = string_copy(big_buffer + 16);  
  -#endif    
  +#endif
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +  else if (Ustrncmp(big_buffer, "-bmi_verdicts ", 14) == 0)
  +    bmi_verdicts = string_copy(big_buffer + 14);
  +#endif
     else if (Ustrcmp(big_buffer, "-host_lookup_failed") == 0)
       host_lookup_failed = TRUE;
     else if (Ustrncmp(big_buffer, "-body_linecount", 15) == 0)


  Index: spool_out.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/spool_out.c,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- spool_out.c    2 Dec 2004 09:15:11 -0000    1.1.2.1
  +++ spool_out.c    10 Dec 2004 14:59:08 -0000    1.1.2.2
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/spool_out.c,v 1.1.2.1 2004/12/02 09:15:11 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/spool_out.c,v 1.1.2.2 2004/12/10 14:59:08 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -221,6 +221,10 @@
   #endif
   if (deliver_manual_thaw) fprintf(f, "-manual_thaw\n");
   if (sender_set_untrusted) fprintf(f, "-sender_set_untrusted\n");
  +
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +if (bmi_verdicts != NULL) fprintf(f, "-bmi_verdicts %s\n", bmi_verdicts);
  +#endif


#ifdef SUPPORT_TLS
if (tls_certificate_verified) fprintf(f, "-tls_certificate_verified\n");

  Index: structs.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/structs.h,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- structs.h    7 Oct 2004 10:39:01 -0000    1.1
  +++ structs.h    10 Dec 2004 14:59:08 -0000    1.1.2.1
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/structs.h,v 1.1 2004/10/07 10:39:01 ph10 Exp $ */
  +/* $Cambridge: exim/exim-src/src/structs.h,v 1.1.2.1 2004/12/10 14:59:08 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -221,6 +221,9 @@
     uschar *driver_name;            /* Must be first */


     uschar *address_data;           /* Arbitrary data */
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +  uschar *bmi_rule;               /* Brightmail AntiSpam rule checking */
  +#endif  
     uschar *cannot_route_message;   /* Used when routing fails */
     uschar *condition;              /* General condition */
     uschar *current_directory;      /* For use during delivery */
  @@ -249,6 +252,11 @@
     uschar *transport_name;         /* Transport name */


     BOOL    address_test;           /* Use this router when testing addresses */
  +#ifdef EXPERIMENTAL_BRIGHTMAIL
  +  BOOL    bmi_deliver_alternate;  /* TRUE => BMI said that message should be delivered to alternate location */
  +  BOOL    bmi_deliver_default;    /* TRUE => BMI said that message should be delivered to default location */
  +  BOOL    bmi_dont_deliver;       /* TRUE => BMI said that message should not be delivered at all */
  +#endif
     BOOL    expn;                   /* Use this router when processing EXPN */
     BOOL    caseful_local_part;     /* TRUE => don't lowercase */
     BOOL    check_local_user;       /* TRUE => check local user */


  Index: redirect.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/routers/redirect.c,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- redirect.c    4 Nov 2004 10:42:11 -0000    1.2
  +++ redirect.c    10 Dec 2004 14:59:08 -0000    1.2.2.1
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/routers/redirect.c,v 1.2 2004/11/04 10:42:11 ph10 Exp $ */
  +/* $Cambridge: exim/exim-src/src/routers/redirect.c,v 1.2.2.1 2004/12/10 14:59:08 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -101,6 +101,16 @@
         (void *)offsetof(redirect_router_options_block, sieve_vacation_directory) },
     { "skip_syntax_errors", opt_bool,
         (void *)offsetof(redirect_router_options_block, skip_syntax_errors) },
  +#ifdef EXPERIMENTAL_SRS
  +  { "srs",                opt_stringptr,
  +      (void *)offsetof(redirect_router_options_block, srs) },
  +  { "srs_alias",          opt_stringptr,
  +      (void *)offsetof(redirect_router_options_block, srs_alias) },
  +  { "srs_condition",      opt_stringptr,
  +      (void *)offsetof(redirect_router_options_block, srs_condition) },
  +  { "srs_db",             opt_stringptr,
  +      (void *)offsetof(redirect_router_options_block, srs_db) },
  +#endif
     { "syntax_errors_text", opt_stringptr,
         (void *)offsetof(redirect_router_options_block, syntax_errors_text) },
     { "syntax_errors_to",   opt_stringptr,
  @@ -134,6 +144,12 @@
     NULL,        /* qualify_domain */
     NULL,        /* owners */
     NULL,        /* owngroups */
  +#ifdef EXPERIMENTAL_SRS
  +  NULL,        /* srs */
  +  NULL,        /* srs_condition */
  +  NULL,        /* srs_db */
  +  NULL,        /* srs_alias */
  +#endif
     022,         /* modemask */
     RDO_REWRITE, /* bit_options */
     FALSE,       /* check_ancestor */
  @@ -526,6 +542,36 @@
     ugid.gid_set = TRUE;
     }


  +#ifdef EXPERIMENTAL_SRS
  +  /* For reverse SRS, fill the srs_recipient expandsion variable,
  +  on failure, return decline/fail as relevant */
  +  if(ob->srs != NULL)
  +  {
  +    BOOL usesrs = TRUE;
  +    
  +    if(ob->srs_condition != NULL)
  +      usesrs = expand_check_condition(ob->srs_condition, "srs_condition expansion failed", NULL);
  +    
  +    if(usesrs)
  +      if(Ustrcmp(ob->srs, "reverse") == 0 || Ustrcmp(ob->srs, "reverseandforward") == 0)
  +      {
  +        uschar *res;
  +        int n_srs;
  +    
  +        srs_orig_recipient = addr->address;
  +        eximsrs_init();
  +        if(ob->srs_db)
  +          eximsrs_db_set(TRUE, ob->srs_db);
  +        if((n_srs = eximsrs_reverse(&res, addr->address)) != OK)
  +          return n_srs;
  +        srs_recipient = res;
  +        eximsrs_done();
  +        DEBUG(D_any)
  +          debug_printf("SRS: Recipient '%s' rewriteen to '%s'\n", srs_orig_recipient, srs_recipient);
  +      }
  +  }
  +#endif
  +
   /* Call the function that interprets redirection data, either inline or from a
   file. This is a separate function so that the system filter can use it. It will
   run the function in a subprocess if necessary. If qualify_preserve_domain is
  @@ -748,6 +794,39 @@
       (addr_prop.errors_address != NULL)? addr_prop.errors_address : US"",
       (addr_prop.errors_address != NULL)? "\n" : "");
     }
  +
  +#ifdef EXPERIMENTAL_SRS
  +  /* On successful redirection, check for SRS forwarding and adjust sender */
  +  if(ob->srs != NULL)
  +  {
  +    BOOL usesrs = TRUE;
  +    
  +    if(ob->srs_condition != NULL)
  +      usesrs = expand_check_condition(ob->srs_condition, "srs_condition expansion failed", NULL);
  +    
  +    if(usesrs)
  +      if((Ustrcmp(ob->srs, "forward") == 0 || Ustrcmp(ob->srs, "reverseandforward") == 0) && !verify)
  +      {
  +        uschar *res;
  +        uschar *usedomain;
  +        int n_srs;
  +      
  +        srs_orig_sender = sender_address;
  +        eximsrs_init();
  +        if(ob->srs_db)
  +          eximsrs_db_set(FALSE, ob->srs_db);
  +
  +        if(ob->srs_alias != NULL ? (usedomain = expand_string(ob->srs_alias)) == NULL : 1)
  +          usedomain = deliver_domain;
  +                
  +        if((n_srs = eximsrs_forward(&res, sender_address, usedomain)) != OK)
  +          return n_srs;
  +        sender_address = res;
  +        DEBUG(D_any)
  +          debug_printf("SRS: Sender '%s' rewritten to '%s'\n", srs_orig_sender, sender_address);
  +    }
  +  }
  +#endif


/* Control gets here only when the address has been completely handled. Put the
original address onto the succeed queue so that any retry items that get

  Index: redirect.h
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/routers/redirect.h,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- redirect.h    7 Oct 2004 13:10:02 -0000    1.1
  +++ redirect.h    10 Dec 2004 14:59:08 -0000    1.1.2.1
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/routers/redirect.h,v 1.1 2004/10/07 13:10:02 ph10 Exp $ */
  +/* $Cambridge: exim/exim-src/src/routers/redirect.h,v 1.1.2.1 2004/12/10 14:59:08 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -32,6 +32,13 @@


     uid_t  *owners;
     gid_t  *owngroups;
  +
  +#ifdef EXPERIMENTAL_SRS
  +  uschar *srs;
  +  uschar *srs_condition;
  +  uschar *srs_db;
  +  uschar *srs_alias;
  +#endif


     int   modemask;
     int   bit_options;