ph10 2005/04/06 15:40:24 BST
Modified files:
exim-doc/doc-txt ChangeLog NewStuff
exim-src/src deliver.c filtertest.c functions.h rda.c
sieve.c
exim-src/src/routers queryprogram.c redirect.c redirect.h
Log:
Michael Haardt's patch for support for :user and :subaddress in Sieve
filters by means of two new redirect router options.
Revision Changes Path
1.116 +3 -0 exim/exim-doc/doc-txt/ChangeLog
1.35 +6 -0 exim/exim-doc/doc-txt/NewStuff
1.11 +2 -0 exim/exim-src/src/deliver.c
1.5 +1 -1 exim/exim-src/src/filtertest.c
1.14 +5 -4 exim/exim-src/src/functions.h
1.5 +14 -6 exim/exim-src/src/rda.c
1.3 +2 -0 exim/exim-src/src/routers/queryprogram.c
1.9 +10 -3 exim/exim-src/src/routers/redirect.c
1.4 +2 -0 exim/exim-src/src/routers/redirect.h
1.9 +13 -10 exim/exim-src/src/sieve.c
Index: ChangeLog
===================================================================
RCS file: /home/cvs/exim/exim-doc/doc-txt/ChangeLog,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -r1.115 -r1.116
--- ChangeLog 6 Apr 2005 14:09:17 -0000 1.115
+++ ChangeLog 6 Apr 2005 14:40:23 -0000 1.116
@@ -1,4 +1,4 @@
-$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.115 2005/04/06 14:09:17 ph10 Exp $
+$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.116 2005/04/06 14:40:23 ph10 Exp $
Change log file for Exim from version 4.21
-------------------------------------------
@@ -175,6 +175,9 @@
to make Exim compile on kfreebsd-gnu. (I'm totally confused about the
nomenclature these days.)
+
+PH/29 Installed patch from the Sieve maintainer that adds the options
+ sieve_useraddress and sieve_subaddress to the redirect router.
Index: NewStuff
===================================================================
RCS file: /home/cvs/exim/exim-doc/doc-txt/NewStuff,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- NewStuff 6 Apr 2005 14:03:53 -0000 1.34
+++ NewStuff 6 Apr 2005 14:40:23 -0000 1.35
@@ -1,4 +1,4 @@
-$Cambridge: exim/exim-doc/doc-txt/NewStuff,v 1.34 2005/04/06 14:03:53 ph10 Exp $
+$Cambridge: exim/exim-doc/doc-txt/NewStuff,v 1.35 2005/04/06 14:40:23 ph10 Exp $
New Features in Exim
--------------------
@@ -140,6 +140,12 @@
Previously, $acl_verify_message was set only while expanding "message"
and "log_message" when a very denied access.
+PH/08 The redirect router has two new options, sieve_useraddress and
+ sieve_subaddress. These are passed to a Sieve filter to specify the :user
+ and :subaddress parts of an address. Both options are unset by default.
+ However, when a Sieve filter is run, if sieve_useraddress is unset, the
+ entire original local part (including any prefix or suffix) is used for
+ :user. An unset subaddress is treated as an empty subaddress.
Version 4.50
Index: deliver.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/deliver.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- deliver.c 5 Apr 2005 15:47:50 -0000 1.10
+++ deliver.c 6 Apr 2005 14:40:24 -0000 1.11
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/deliver.c,v 1.10 2005/04/05 15:47:50 ph10 Exp $ */
+/* $Cambridge: exim/exim-src/src/deliver.c,v 1.11 2005/04/06 14:40:24 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -4662,6 +4662,8 @@
RDO_REWRITE,
NULL, /* No :include: restriction (not used in filter) */
NULL, /* No sieve vacation directory (not sieve!) */
+ NULL, /* No sieve user address (not sieve!) */
+ NULL, /* No sieve subaddress (not sieve!) */
&ugid, /* uid/gid data */
&addr_new, /* Where to hang generated addresses */
&filter_message, /* Where to put error message */
Index: filtertest.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/filtertest.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- filtertest.c 17 Feb 2005 11:58:26 -0000 1.4
+++ filtertest.c 6 Apr 2005 14:40:24 -0000 1.5
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/filtertest.c,v 1.4 2005/02/17 11:58:26 ph10 Exp $ */
+/* $Cambridge: exim/exim-src/src/filtertest.c,v 1.5 2005/04/06 14:40:24 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -271,7 +271,7 @@
else
{
yield = (filter_type == FILTER_SIEVE)?
- sieve_interpret(filebuf, RDO_REWRITE, NULL, &generated, &error)
+ sieve_interpret(filebuf, RDO_REWRITE, NULL, NULL, NULL, &generated, &error)
:
filter_interpret(filebuf, RDO_REWRITE, &generated, &error);
}
Index: functions.h
===================================================================
RCS file: /home/cvs/exim/exim-src/src/functions.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- functions.h 4 Apr 2005 10:33:49 -0000 1.13
+++ functions.h 6 Apr 2005 14:40:24 -0000 1.14
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/functions.h,v 1.13 2005/04/04 10:33:49 ph10 Exp $ */
+/* $Cambridge: exim/exim-src/src/functions.h,v 1.14 2005/04/06 14:40:24 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -184,8 +184,9 @@
#ifdef WITH_CONTENT_SCAN
extern int recv_line(int, uschar *, int);
#endif
-extern int rda_interpret(redirect_block *, int, uschar *, uschar *, ugid_block *,
- address_item **, uschar **, error_block **, int *, uschar *);
+extern int rda_interpret(redirect_block *, int, uschar *, uschar *,
+ uschar *, uschar *, ugid_block *, address_item **, uschar **,
+ error_block **, int *, uschar *);
extern int rda_is_filter(const uschar *);
extern BOOL readconf_depends(driver_instance *, uschar *);
extern void readconf_driver_init(uschar *, driver_instance **,
@@ -247,8 +248,8 @@
extern void sha1_end(sha1 *, const uschar *, int, uschar *);
extern void sha1_mid(sha1 *, const uschar *);
extern void sha1_start(sha1 *);
-extern int sieve_interpret(uschar *, int, uschar *, address_item **,
- uschar **);
+extern int sieve_interpret(uschar *, int, uschar *, uschar *, uschar *,
+ address_item **, uschar **);
extern void sigalrm_handler(int);
extern void smtp_closedown(uschar *);
extern int smtp_connect(host_item *, int, int, uschar *, int, BOOL);
Index: rda.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/rda.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- rda.c 17 Feb 2005 11:58:26 -0000 1.4
+++ rda.c 6 Apr 2005 14:40:24 -0000 1.5
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/rda.c,v 1.4 2005/02/17 11:58:26 ph10 Exp $ */
+/* $Cambridge: exim/exim-src/src/rda.c,v 1.5 2005/04/06 14:40:24 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -333,6 +333,8 @@
options the options bits
include_directory restrain to this directory
sieve_vacation_directory passed to sieve_interpret
+ sieve_useraddress passed to sieve_interpret
+ sieve_subaddress passed to sieve_interpret
generated where to hang generated addresses
error for error messages
eblockp for details of skipped syntax errors
@@ -348,7 +350,8 @@
static int
rda_extract(redirect_block *rdata, int options, uschar *include_directory,
- uschar *sieve_vacation_directory, address_item **generated, uschar **error,
+ uschar *sieve_vacation_directory, uschar *sieve_useraddress,
+ uschar *sieve_subaddress, address_item **generated, uschar **error,
error_block **eblockp, int *filtertype)
{
uschar *data;
@@ -407,8 +410,8 @@
*error = US"Sieve filtering not enabled";
return FF_ERROR;
}
- frc = sieve_interpret(data, options, sieve_vacation_directory, generated,
- error);
+ frc = sieve_interpret(data, options, sieve_vacation_directory,
+ sieve_useraddress, sieve_subaddress, generated, error);
}
expand_forbid = old_expand_forbid;
@@ -515,6 +518,8 @@
plus ENOTDIR and EACCES handling bits
include_directory restrain :include: to this directory
sieve_vacation_directory directory passed to sieve_interpret()
+ sieve_useraddress passed to sieve_interpret
+ sieve_subaddress passed to sieve_interpret
ugid uid/gid to run under - if NULL, no change
generated where to hang generated addresses, initially NULL
error pointer for error message
@@ -541,7 +546,8 @@
int
rda_interpret(redirect_block *rdata, int options, uschar *include_directory,
- uschar *sieve_vacation_directory, ugid_block *ugid, address_item **generated,
+ uschar *sieve_vacation_directory, uschar *sieve_useraddress,
+ uschar *sieve_subaddress, ugid_block *ugid, address_item **generated,
uschar **error, error_block **eblockp, int *filtertype, uschar *rname)
{
int fd, rc, pfd[2];
@@ -586,7 +592,8 @@
Ustrstr(data, ":include:") == NULL)) /* and there's no :include: */
{
return rda_extract(rdata, options, include_directory,
- sieve_vacation_directory, generated, error, eblockp, filtertype);
+ sieve_vacation_directory, sieve_useraddress, sieve_subaddress,
+ generated, error, eblockp, filtertype);
}
/* We need to run the processing code in a sub-process. However, if we can
@@ -631,7 +638,8 @@
/* Now do the business */
yield = rda_extract(rdata, options, include_directory,
- sieve_vacation_directory, generated, error, eblockp, filtertype);
+ sieve_vacation_directory, sieve_useraddress, sieve_subaddress, generated,
+ error, eblockp, filtertype);
/* Pass back whether it was a filter, and the return code and any overall
error text via the pipe. */
Index: sieve.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/sieve.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- sieve.c 1 Mar 2005 10:21:44 -0000 1.8
+++ sieve.c 6 Apr 2005 14:40:24 -0000 1.9
@@ -1,10 +1,10 @@
-/* $Cambridge: exim/exim-src/src/sieve.c,v 1.8 2005/03/01 10:21:44 ph10 Exp $ */
+/* $Cambridge: exim/exim-src/src/sieve.c,v 1.9 2005/04/06 14:40:24 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) Michael Haardt 2003,2004 */
+/* Copyright (c) Michael Haardt 2003-2005 */
/* See the file NOTICE for conditions of use and distribution. */
/* This code was contributed by Michael Haardt. */
@@ -61,6 +61,8 @@
int vacation_ran;
#endif
uschar *vacation_directory;
+ const uschar *subaddress;
+ const uschar *useraddress;
int require_copy;
int require_iascii_numeric;
};
@@ -1711,10 +1713,8 @@
case ADDRPART_LOCALPART: part=extracted_addr; part[domain-1]='\0'; break;
case ADDRPART_DOMAIN: part=extracted_addr+domain; break;
#ifdef SUBADDRESS
- case ADDRPART_DETAIL:
- part=NULL;
+ case ADDRPART_DETAIL: part=NULL; break;
#endif
- break;
}
*end_addr = saveend;
@@ -2019,9 +2019,7 @@
case ADDRPART_LOCALPART: envelopeExpr=CUS "${local_part:$sender_address}"; break;
case ADDRPART_DOMAIN: envelopeExpr=CUS "${domain:$sender_address}"; break;
#ifdef SUBADDRESS
- case ADDRPART_DETAIL:
- envelopeExpr=CUS 0;
- break;
+ case ADDRPART_DETAIL: envelopeExpr=CUS 0; break;
#endif
}
}
@@ -2031,8 +2029,8 @@
{
case ADDRPART_ALL: envelopeExpr=CUS "$local_part_prefix$local_part$local_part_suffix@$domain"; break;
#ifdef SUBADDRESS
- case ADDRPART_USER: envelopeExpr=CUS "$local_part_prefix$local_part"; break;
- case ADDRPART_DETAIL: envelopeExpr=CUS "$local_part_suffix"; break;
+ case ADDRPART_USER: envelopeExpr=filter->useraddress; break;
+ case ADDRPART_DETAIL: envelopeExpr=filter->subaddress; break;
#endif
case ADDRPART_LOCALPART: envelopeExpr=CUS "$local_part_prefix$local_part$local_part_suffix"; break;
case ADDRPART_DOMAIN: envelopeExpr=CUS "$domain"; break;
@@ -2724,6 +2722,8 @@
options controls whether various special things are allowed, and requests
special actions (not currently used)
sieve_vacation_directory where to store vacation "once" files
+ useraddress string expression for :user part of address
+ subaddress string expression for :subaddress part of address
generated where to hang newly-generated addresses
error where to pass back an error text
@@ -2737,7 +2737,7 @@
int
sieve_interpret(uschar *filter, int options, uschar *vacation_directory,
- address_item **generated, uschar **error)
+ uschar *useraddress, uschar *subaddress, address_item **generated, uschar **error)
{
struct Sieve sieve;
int r;
@@ -2762,6 +2762,9 @@
return FF_ERROR;
}
}
+
+sieve.useraddress = useraddress == NULL ? CUS "$local_part_prefix$local_part$local_part_suffix" : useraddress;
+sieve.subaddress = subaddress;
#ifdef COMPILE_SYNTAX_CHECKER
if (parse_start(&sieve,0,generated)==1)
Index: queryprogram.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/routers/queryprogram.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- queryprogram.c 4 Jan 2005 10:00:44 -0000 1.2
+++ queryprogram.c 6 Apr 2005 14:40:24 -0000 1.3
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/routers/queryprogram.c,v 1.2 2005/01/04 10:00:44 ph10 Exp $ */
+/* $Cambridge: exim/exim-src/src/routers/queryprogram.c,v 1.3 2005/04/06 14:40:24 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -356,6 +356,8 @@
RDO_REWRITE, /* rewrite generated addresses */
NULL, /* :include: directory not relevant */
NULL, /* sieve vacation directory not relevant */
+ NULL, /* sieve useraddress not relevant */
+ NULL, /* sieve subaddress not relevant */
&ugid, /* uid/gid (but not set) */
&generated, /* where to hang the results */
&(addr->message), /* where to put messages */
Index: redirect.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/routers/redirect.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- redirect.c 22 Mar 2005 15:02:34 -0000 1.8
+++ redirect.c 6 Apr 2005 14:40:24 -0000 1.9
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/routers/redirect.c,v 1.8 2005/03/22 15:02:34 ph10 Exp $ */
+/* $Cambridge: exim/exim-src/src/routers/redirect.c,v 1.9 2005/04/06 14:40:24 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -97,6 +97,10 @@
(void *)offsetof(redirect_router_options_block, reply_transport_name) },
{ "rewrite", opt_bit | (RDON_REWRITE << 16),
(void *)offsetof(redirect_router_options_block, bit_options) },
+ { "sieve_subaddress", opt_stringptr,
+ (void *)offsetof(redirect_router_options_block, sieve_subaddress) },
+ { "sieve_useraddress", opt_stringptr,
+ (void *)offsetof(redirect_router_options_block, sieve_useraddress) },
{ "sieve_vacation_directory", opt_stringptr,
(void *)offsetof(redirect_router_options_block, sieve_vacation_directory) },
{ "skip_syntax_errors", opt_bool,
@@ -138,6 +142,8 @@
NULL, /* include_directory */
NULL, /* pipe_transport_name */
NULL, /* reply_transport_name */
+ NULL, /* sieve_subaddress */
+ NULL, /* sieve_useraddress */
NULL, /* sieve_vacation_directory */
NULL, /* syntax_errors_text */
NULL, /* syntax_errors_to */
@@ -613,9 +619,10 @@
}
frc = rda_interpret(&redirect, options, ob->include_directory,
- ob->sieve_vacation_directory, &ugid, &generated, &(addr->message),
- ob->skip_syntax_errors? &eblock : NULL, &filtertype,
- string_sprintf("%s router (recipient is %s)", rblock->name, addr->address));
+ ob->sieve_vacation_directory, ob->sieve_useraddress, ob->sieve_subaddress,
+ &ugid, &generated, &(addr->message), ob->skip_syntax_errors? &eblock : NULL,
+ &filtertype, string_sprintf("%s router (recipient is %s)", rblock->name,
+ addr->address));
qualify_domain_recipient = save_qualify_domain_recipient;
Index: redirect.h
===================================================================
RCS file: /home/cvs/exim/exim-src/src/routers/redirect.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- redirect.h 4 Jan 2005 10:00:44 -0000 1.3
+++ redirect.h 6 Apr 2005 14:40:24 -0000 1.4
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/routers/redirect.h,v 1.3 2005/01/04 10:00:44 ph10 Exp $ */
+/* $Cambridge: exim/exim-src/src/routers/redirect.h,v 1.4 2005/04/06 14:40:24 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -25,6 +25,8 @@
uschar *include_directory;
uschar *pipe_transport_name;
uschar *reply_transport_name;
+ uschar *sieve_subaddress;
+ uschar *sieve_useraddress;
uschar *sieve_vacation_directory;
uschar *syntax_errors_text;
uschar *syntax_errors_to;