From: Tom Kistner Date: Fri, 10 Dec 2004 14:59:08 +0000 (+0000) Subject: Added experimental features X-Git-Url: https://git.exim.org/users/jgh/exim.git/commitdiff_plain/7c7d48285d0dcf3b963322fb5ecd32e96f4bbbf6 Added experimental features --- diff --git a/src/src/EDITME b/src/src/EDITME index b8c39d12e..da275b2a6 100644 --- a/src/src/EDITME +++ b/src/src/EDITME @@ -1,4 +1,4 @@ -# $Cambridge: exim/src/src/EDITME,v 1.4.2.2 2004/12/02 09:15:11 tom Exp $ +# $Cambridge: 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 @@ EXIM_MONITOR=eximon.bin #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 diff --git a/src/src/acl.c b/src/src/acl.c index 6c0a209c7..18629a1af 100644 --- a/src/src/acl.c +++ b/src/src/acl.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/acl.c,v 1.5.2.4 2004/12/10 09:24:38 tom Exp $ */ +/* $Cambridge: 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 @@ static int msgcond[] = { FAIL, OK, OK, FAIL, OK, FAIL, OK }; /* 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 @@ -58,6 +62,9 @@ enum { ACLC_ACL, ACLC_AUTHENTICATED, ACLC_CONDITION, ACLC_CONTROL, ACLC_SENDER_DOMAINS, ACLC_SENDERS, ACLC_SET, #ifdef WITH_CONTENT_SCAN ACLC_SPAM, +#endif +#ifdef EXPERIMENTAL_SPF + ACLC_SPF, #endif ACLC_VERIFY }; @@ -65,7 +72,11 @@ enum { ACLC_ACL, ACLC_AUTHENTICATED, ACLC_CONDITION, ACLC_CONTROL, "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", @@ -90,6 +101,9 @@ static uschar *conditions[] = { US"acl", US"authenticated", US"condition", US"sender_domains", US"senders", US"set", #ifdef WITH_CONTENT_SCAN US"spam", +#endif +#ifdef EXPERIMENTAL_SPF + US"spf", #endif US"verify" }; @@ -106,6 +120,9 @@ checking functions. */ 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 @@ -139,6 +156,9 @@ static uschar cond_expand_at_top[] = { TRUE, /* set */ #ifdef WITH_CONTENT_SCAN TRUE, /* spam */ +#endif +#ifdef EXPERIMENTAL_SPF + TRUE, /* spf */ #endif TRUE /* verify */ }; @@ -148,6 +168,9 @@ static uschar cond_expand_at_top[] = { static uschar cond_modifiers[] = { FALSE, /* acl */ FALSE, /* authenticated */ +#ifdef EXPERIMENTAL_BRIGHTMAIL + TRUE, /* bmi_optin */ +#endif FALSE, /* condition */ TRUE, /* control */ #ifdef WITH_CONTENT_SCAN @@ -181,6 +204,9 @@ static uschar cond_modifiers[] = { TRUE, /* set */ #ifdef WITH_CONTENT_SCAN FALSE, /* spam */ +#endif +#ifdef EXPERIMENTAL_SPF + FALSE, /* spf */ #endif FALSE /* verify */ }; @@ -192,13 +218,24 @@ static unsigned int cond_forbids[] = { 0, /* acl */ (1< 0) 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 @@ for (; cb != NULL; cb = cb->next) 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 @@ for (; cb != NULL; cb = cb->next) 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 @@ for (; cb != NULL; cb = cb->next) switch(control_type) { +#ifdef EXPERIMENTAL_BRIGHTMAIL + case CONTROL_BMI_RUN: + bmi_run = 1; + break; +#endif + case CONTROL_ERROR: return ERROR; @@ -1825,6 +1902,12 @@ for (; cb != NULL; cb = cb->next) break; #endif +#ifdef EXPERIMENTAL_SPF + case ACLC_SPF: + rc = spf_process(&arg, sender_address); + break; +#endif + /* If the verb is WARN, discard any user message from verification, because such messages are SMTP responses, not header additions. The latter come only from explicit "message" modifiers. */ diff --git a/src/src/config.h.defaults b/src/src/config.h.defaults index afeaefe2f..23e21fb5b 100644 --- a/src/src/config.h.defaults +++ b/src/src/config.h.defaults @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/config.h.defaults,v 1.2.2.3 2004/12/02 16:33:30 tom Exp $ */ +/* $Cambridge: 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 * @@ -141,6 +141,11 @@ in config.h unless some value is defined in Local/Makefile. */ #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. */ diff --git a/src/src/deliver.c b/src/src/deliver.c index b2e9ea58c..5fc569322 100644 --- a/src/src/deliver.c +++ b/src/src/deliver.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/deliver.c,v 1.3 2004/11/24 14:38:13 ph10 Exp $ */ +/* $Cambridge: 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_localpart_data = addr->p.localpart_data; 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 @@ if (addr->next == NULL) 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 @@ -6315,21 +6335,14 @@ if (addr_defer == NULL) } /* Remove the two message files. */ - + sprintf(CS spoolname, "%s/input/%s/%s-D", spool_directory, message_subdir, id); if (Uunlink(spoolname) < 0) log_write(0, LOG_MAIN|LOG_PANIC_DIE, "failed to unlink %s", spoolname); sprintf(CS spoolname, "%s/input/%s/%s-H", spool_directory, message_subdir, id); if (Uunlink(spoolname) < 0) log_write(0, LOG_MAIN|LOG_PANIC_DIE, "failed to unlink %s", spoolname); - - /* Log the end of this message, with queue time if requested. */ - - if ((log_extra_selector & LX_queue_time_overall) != 0) - log_write(0, LOG_MAIN, "Completed QT=%s", - readconf_printtime(time(NULL) - received_time)); - else - log_write(0, LOG_MAIN, "Completed"); + log_write(0, LOG_MAIN, "Completed"); } /* If there are deferred addresses, we are keeping this message because it is diff --git a/src/src/exim.c b/src/src/exim.c index 189d5ef31..3e558b823 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/exim.c,v 1.9.2.2 2004/12/02 16:33:30 tom Exp $ */ +/* $Cambridge: exim/src/src/exim.c,v 1.9.2.3 2004/12/10 14:59:08 tom Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -845,6 +845,15 @@ fprintf(f, "Support for:"); #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"); fprintf(f, "Lookups:"); diff --git a/src/src/exim.h b/src/src/exim.h index 48aa2d903..e66f744f9 100644 --- a/src/src/exim.h +++ b/src/src/exim.h @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/exim.h,v 1.2.2.2 2004/12/02 16:33:30 tom Exp $ */ +/* $Cambridge: exim/src/src/exim.h,v 1.2.2.3 2004/12/10 14:59:08 tom Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -396,6 +396,16 @@ scanning dependencies. */ #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. */ diff --git a/src/src/expand.c b/src/src/expand.c index 6c7890861..de0a80bf1 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/expand.c,v 1.7.2.1 2004/12/02 09:15:11 tom Exp $ */ +/* $Cambridge: 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 @@ static var_entry var_table[] = { { "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 }, @@ -460,10 +466,24 @@ static var_entry var_table[] = { { "spam_report", vtype_stringptr, &spam_report }, { "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 }, diff --git a/src/src/globals.c b/src/src/globals.c index 4566947f5..c36f47c4d 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/globals.c,v 1.6.2.4 2004/12/10 09:24:38 tom Exp $ */ +/* $Cambridge: 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 *base62_chars= 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 @@ router_instance router_defaults = { 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 @@ router_instance router_defaults = { 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_report = NULL; 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; diff --git a/src/src/globals.h b/src/src/globals.h index 2b36a8aa7..84c95e45b 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/globals.h,v 1.6.2.3 2004/12/10 09:24:38 tom Exp $ */ +/* $Cambridge: 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 *base62_chars; /* Table of base-62 characters */ 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_report; /* the spamd report (multiline) */ 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 */ diff --git a/src/src/local_scan.h b/src/src/local_scan.h index fd95643a5..4cfe0b7e6 100644 --- a/src/src/local_scan.h +++ b/src/src/local_scan.h @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/local_scan.h,v 1.1.2.1 2004/12/02 09:15:11 tom Exp $ */ +/* $Cambridge: 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 @@ typedef struct recipient_item { 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; diff --git a/src/src/readconf.c b/src/src/readconf.c index e1ca32ebc..aba99a732 100644 --- a/src/src/readconf.c +++ b/src/src/readconf.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/readconf.c,v 1.2.2.1 2004/12/02 09:15:11 tom Exp $ */ +/* $Cambridge: 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 @@ static optionlist optionlist_config[] = { { "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 @@ static optionlist optionlist_config[] = { #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 }, diff --git a/src/src/receive.c b/src/src/receive.c index dfe14076f..72554f719 100644 --- a/src/src/receive.c +++ b/src/src/receive.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/receive.c,v 1.4.2.3 2004/12/10 09:24:38 tom Exp $ */ +/* $Cambridge: 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 @@ if (recipients_count >= recipients_list_max) 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; } @@ -3095,6 +3100,14 @@ signal(SIGINT, SIG_IGN); 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 processing is complete. */ diff --git a/src/src/route.c b/src/src/route.c index 427570ef7..b272d0ec2 100644 --- a/src/src/route.c +++ b/src/src/route.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/route.c,v 1.1 2004/10/07 10:39:01 ph10 Exp $ */ +/* $Cambridge: 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 @@ optionlist optionlist_routers[] = { (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, @@ -982,6 +992,46 @@ if (r->condition != NULL) } } +#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. */ return OK; diff --git a/src/src/routers/redirect.c b/src/src/routers/redirect.c index 0e23bb0b3..5bd6adbef 100644 --- a/src/src/routers/redirect.c +++ b/src/src/routers/redirect.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/routers/redirect.c,v 1.2 2004/11/04 10:42:11 ph10 Exp $ */ +/* $Cambridge: 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 @@ optionlist redirect_router_options[] = { (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 @@ redirect_router_options_block redirect_router_option_defaults = { 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 @@ if (!ugid.gid_set && pw != NULL) 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 @@ -749,6 +795,39 @@ else (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 attached to it get processed. */ diff --git a/src/src/routers/redirect.h b/src/src/routers/redirect.h index 4a6400743..28b17a5b9 100644 --- a/src/src/routers/redirect.h +++ b/src/src/routers/redirect.h @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/routers/redirect.h,v 1.1 2004/10/07 13:10:02 ph10 Exp $ */ +/* $Cambridge: 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 * @@ -33,6 +33,13 @@ typedef struct { 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; BOOL check_ancestor; diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c index 755b2bacc..8126ec844 100644 --- a/src/src/smtp_in.c +++ b/src/src/smtp_in.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/smtp_in.c,v 1.5.2.2 2004/12/02 16:33:30 tom Exp $ */ +/* $Cambridge: 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 @@ sender_verified_list = NULL; /* No senders verified */ 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; @@ -2351,6 +2361,11 @@ while (done <= 0) } } +#ifdef EXPERIMENTAL_SPF + /* set up SPF context */ + spf_init(sender_helo_name, sender_host_address); +#endif + /* Apply an ACL check if one is defined */ if (acl_smtp_helo != NULL) diff --git a/src/src/spool_in.c b/src/src/spool_in.c index 29996f697..22b1af210 100644 --- a/src/src/spool_in.c +++ b/src/src/spool_in.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/spool_in.c,v 1.1.2.1 2004/12/02 09:15:11 tom Exp $ */ +/* $Cambridge: 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_local = FALSE; 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 @@ for (;;) #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) diff --git a/src/src/spool_out.c b/src/src/spool_out.c index 8514edfd3..837083982 100644 --- a/src/src/spool_out.c +++ b/src/src/spool_out.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/spool_out.c,v 1.1.2.1 2004/12/02 09:15:11 tom Exp $ */ +/* $Cambridge: 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 * @@ -222,6 +222,10 @@ if (spam_score_int != NULL) fprintf(f,"-spam_score_int %s\n", spam_score_int); 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"); if (tls_cipher != NULL) fprintf(f, "-tls_cipher %s\n", tls_cipher); diff --git a/src/src/structs.h b/src/src/structs.h index 453582766..03c8b26b3 100644 --- a/src/src/structs.h +++ b/src/src/structs.h @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/structs.h,v 1.1 2004/10/07 10:39:01 ph10 Exp $ */ +/* $Cambridge: 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 @@ typedef struct router_instance { 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 @@ typedef struct router_instance { 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 */