diff -ur postfix-2.5-20071111/src/global/mail_params.h postfix-2.5-20071111-patched-2/src/global/mail_params.h --- postfix-2.5-20071111/src/global/mail_params.h 2007-11-16 22:12:26.000000000 +0000 +++ postfix-2.5-20071111-patched-2/src/global/mail_params.h 2007-11-16 22:14:43.000000000 +0000 @@ -2803,6 +2803,13 @@ extern bool var_qmqpd_client_port_log; /* + * Store all the recipients of a mail for use by the access delegation daemon + */ +#define VAR_SMTPD_ACCESS_DELEGATION_RECIPIENTS "access_delegation_recipients" +#define DEF_SMTPD_ACCESS_DELEGATION_RECIPIENTS 0 +extern bool var_access_delegation_recipients; + + /* * Header/body checks in delivery agents. */ #define VAR_SMTP_HEAD_CHKS "smtp_header_checks" diff -ur postfix-2.5-20071111/src/global/mail_proto.h postfix-2.5-20071111-patched-2/src/global/mail_proto.h --- postfix-2.5-20071111/src/global/mail_proto.h 2007-10-03 22:35:04.000000000 +0100 +++ postfix-2.5-20071111-patched-2/src/global/mail_proto.h 2007-11-16 16:27:31.000000000 +0000 @@ -102,6 +102,7 @@ #define MAIL_ATTR_RCPT_COUNT "recipient_count" #define MAIL_ATTR_ORCPT "original_recipient" #define MAIL_ATTR_RECIP "recipient" +#define MAIL_ATTR_RECIPS "recipients" #define MAIL_ATTR_WHY "reason" #define MAIL_ATTR_VERPDL "verp_delimiters" #define MAIL_ATTR_SITE "site" diff -ur postfix-2.5-20071111/src/smtpd/smtpd.c postfix-2.5-20071111-patched-2/src/smtpd/smtpd.c --- postfix-2.5-20071111/src/smtpd/smtpd.c 2007-10-17 16:17:36.000000000 +0100 +++ postfix-2.5-20071111-patched-2/src/smtpd/smtpd.c 2007-11-16 22:18:03.000000000 +0000 @@ -1130,6 +1130,7 @@ char *var_milt_eod_macros; char *var_milt_unk_macros; bool var_smtpd_client_port_log; +bool var_access_delegation_recipients; /* * Silly little macros. @@ -2232,6 +2233,7 @@ const char *dsn_orcpt_type = 0; int dsn_notify = 0; const char *coded_addr; + VSTRING *recipients; /* * Sanity checks. @@ -2414,6 +2416,18 @@ state->rcpt_count++; if (state->recipient == 0) state->recipient = mystrdup(STR(state->addr_buf)); + if (var_access_delegation_recipients) { + if (state->recipients == 0) { + state->recipients = mystrdup(STR(state->addr_buf)); + } else { + recipients = vstring_alloc(100); + recipients = vstring_strcat(recipients,state->recipients); + recipients = vstring_strcat(recipients,"\r"); + recipients = vstring_strcat(recipients, STR(state->addr_buf)); + state->recipients = mystrdup(STR(recipients)); + vstring_free(recipients); + } + } if (state->cleanup) { /* Note: RFC(2)821 externalized address! */ if (dsn_orcpt_addr == 0) { @@ -2447,6 +2461,12 @@ myfree(state->recipient); state->recipient = 0; } + if (var_access_delegation_recipients) { + if (state->recipients) { + myfree(state->recipients); + state->recipients = 0; + } + } state->rcpt_count = 0; /* XXX Must flush the command history. */ state->rcpt_overshoot = 0; @@ -4649,6 +4669,7 @@ VAR_SMTPD_PEERNAME_LOOKUP, DEF_SMTPD_PEERNAME_LOOKUP, &var_smtpd_peername_lookup, VAR_SMTPD_DELAY_OPEN, DEF_SMTPD_DELAY_OPEN, &var_smtpd_delay_open, VAR_SMTPD_CLIENT_PORT_LOG, DEF_SMTPD_CLIENT_PORT_LOG, &var_smtpd_client_port_log, + VAR_SMTPD_ACCESS_DELEGATION_RECIPIENTS, DEF_SMTPD_ACCESS_DELEGATION_RECIPIENTS, &var_access_delegation_recipients, 0, }; static CONFIG_STR_TABLE str_table[] = { @@ -4756,3 +4777,4 @@ MAIL_SERVER_POST_INIT, post_jail_init, 0); } + diff -ur postfix-2.5-20071111/src/smtpd/smtpd_check.c postfix-2.5-20071111-patched-2/src/smtpd/smtpd_check.c --- postfix-2.5-20071111/src/smtpd/smtpd_check.c 2007-09-11 15:16:17.000000000 +0100 +++ postfix-2.5-20071111-patched-2/src/smtpd/smtpd_check.c 2007-11-16 22:29:38.000000000 +0000 @@ -3353,6 +3353,8 @@ state->sender ? state->sender : "", ATTR_TYPE_STR, MAIL_ATTR_RECIP, state->recipient ? state->recipient : "", + ATTR_TYPE_STR, MAIL_ATTR_RECIPS, + state->recipients && (strcasecmp(state->where, SMTPD_CMD_DATA) == 0 || strcasecmp(state->where, SMTPD_CMD_EOD) == 0) ? state->recipients : "", ATTR_TYPE_INT, MAIL_ATTR_RCPT_COUNT, ((strcasecmp(state->where, SMTPD_CMD_DATA) == 0) || (strcasecmp(state->where, SMTPD_AFTER_DOT) == 0)) ? diff -ur postfix-2.5-20071111/src/smtpd/smtpd.h postfix-2.5-20071111-patched-2/src/smtpd/smtpd.h --- postfix-2.5-20071111/src/smtpd/smtpd.h 2007-10-04 00:46:06.000000000 +0100 +++ postfix-2.5-20071111-patched-2/src/smtpd/smtpd.h 2007-11-16 16:27:58.000000000 +0000 @@ -99,6 +99,7 @@ char *encoding; /* owned by mail_cmd() */ char *verp_delims; /* owned by mail_cmd() */ char *recipient; /* recipient address */ + char *recipients; /* all the recipients seen in the mail */ char *etrn_name; /* client ETRN argument */ char *protocol; /* SMTP or ESMTP */ char *where; /* protocol stage */ diff -ur postfix-2.5-20071111/src/smtpd/smtpd_state.c postfix-2.5-20071111-patched-2/src/smtpd/smtpd_state.c --- postfix-2.5-20071111/src/smtpd/smtpd_state.c 2007-04-05 17:57:43.000000000 +0100 +++ postfix-2.5-20071111-patched-2/src/smtpd/smtpd_state.c 2007-11-16 16:28:38.000000000 +0000 @@ -99,6 +99,7 @@ state->sender = 0; state->verp_delims = 0; state->recipient = 0; + state->recipients = 0; state->etrn_name = 0; state->protocol = mystrdup(MAIL_PROTO_SMTP); state->where = SMTPD_AFTER_CONNECT;