Another ratelimit tweak. I didn't anticipate people using per_cmd
authorTony Finch <dot@dot.at>
Fri, 10 Jun 2005 19:27:05 +0000 (19:27 +0000)
committerTony Finch <dot@dot.at>
Fri, 10 Jun 2005 19:27:05 +0000 (19:27 +0000)
ratelimits more than once in the same ACL (e.g. to increase the
delay for higher rates) so the code didn't do the right thing in
that situation. There's now a per_cmd cache which is reset at the
start of each ACL run.

doc/doc-txt/ChangeLog
src/src/acl.c
src/src/globals.c
src/src/globals.h

index 37e13a4ff2f24d55d46aa5c730df670a31ebd421..e7951b33d422cb53da6f9c6452a7837c25657954 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.151 2005/06/10 13:39:52 tom Exp $
+$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.152 2005/06/10 19:27:05 fanf2 Exp $
 
 Change log file for Exim from version 4.21
 -------------------------------------------
 
 Change log file for Exim from version 4.21
 -------------------------------------------
@@ -35,7 +35,8 @@ PH/04 Installed a modified version of Tony Finch's patch to make submission
 
 TF/03 Added the control = fakedefer ACL modifier.
 
 
 TF/03 Added the control = fakedefer ACL modifier.
 
-TF/04 Added the ratelimit ACL condition. See NewStuff for details.
+TF/04 Added the ratelimit ACL condition. See NewStuff for details. Thanks to
+      Mark Lowes for thorough testing.
 
 TK/02 Rewrote SPF support to work with libspf2 versions >1.2.0.
 
 
 TK/02 Rewrote SPF support to work with libspf2 versions >1.2.0.
 
index bfd66e3bb2d4e18d966085370fdeed9520349cd4..980d3ab2dbd03e46319a41967e35bb31b6c02b64 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/acl.c,v 1.38 2005/06/10 18:59:34 fanf2 Exp $ */
+/* $Cambridge: exim/src/src/acl.c,v 1.39 2005/06/10 19:27:05 fanf2 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -2012,8 +2012,7 @@ if (!have_key && sender_host_address != NULL)
 HDEBUG(D_acl) debug_printf("ratelimit condition limit=%.0f period=%.0f key=%s\n",
   limit, period, key);
 
 HDEBUG(D_acl) debug_printf("ratelimit condition limit=%.0f period=%.0f key=%s\n",
   limit, period, key);
 
-/* If we are dealing with rate limits per connection, per message, or per byte,
-see if we have already computed the rate by looking in the relevant tree. For
+/* See if we have already computed the rate by looking in the relevant tree. For
 per-connection rate limiting, store tree nodes and dbdata in the permanent pool
 so that they survive across resets. */
 
 per-connection rate limiting, store tree nodes and dbdata in the permanent pool
 so that they survive across resets. */
 
@@ -2025,8 +2024,10 @@ if (per_conn)
   anchor = &ratelimiters_conn;
   store_pool = POOL_PERM;
   }
   anchor = &ratelimiters_conn;
   store_pool = POOL_PERM;
   }
-if (per_mail || per_byte)
+else if (per_mail || per_byte)
   anchor = &ratelimiters_mail;
   anchor = &ratelimiters_mail;
+else if (per_cmd)
+  anchor = &ratelimiters_cmd;
 
 if (anchor != NULL && (t = tree_search(*anchor, key)) != NULL)
   {
 
 if (anchor != NULL && (t = tree_search(*anchor, key)) != NULL)
   {
@@ -3326,6 +3327,7 @@ address_item *addr;
 
 *user_msgptr = *log_msgptr = NULL;
 sender_verified_failed = NULL;
 
 *user_msgptr = *log_msgptr = NULL;
 sender_verified_failed = NULL;
+ratelimiters_cmd = NULL;
 
 if (where == ACL_WHERE_RCPT)
   {
 
 if (where == ACL_WHERE_RCPT)
   {
index 2f6b5fdda27e0a63bbb0973b8d22a027db58229e..43d5feeec046f27417f160f34871ea28cfd824f8 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/globals.c,v 1.27 2005/05/24 08:15:02 tom Exp $ */
+/* $Cambridge: exim/src/src/globals.c,v 1.28 2005/06/10 19:27:05 fanf2 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -780,6 +780,7 @@ BOOL    queue_smtp             = FALSE;
 uschar *queue_smtp_domains     = NULL;
 
 unsigned int random_seed       = 0;
 uschar *queue_smtp_domains     = NULL;
 
 unsigned int random_seed       = 0;
+tree_node *ratelimiters_cmd    = NULL;
 tree_node *ratelimiters_conn   = NULL;
 tree_node *ratelimiters_mail   = NULL;
 uschar *raw_active_hostname    = NULL;
 tree_node *ratelimiters_conn   = NULL;
 tree_node *ratelimiters_mail   = NULL;
 uschar *raw_active_hostname    = NULL;
index 63f9059b639cd32846378ee690be6ea4396ef3a7..b4aa5b031fd6197b86aa30c03ef28278068d9747 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/globals.h,v 1.19 2005/05/24 08:15:02 tom Exp $ */
+/* $Cambridge: exim/src/src/globals.h,v 1.20 2005/06/10 19:27:05 fanf2 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -505,6 +505,7 @@ extern BOOL    queue_smtp;             /* Disable all immediate STMP (-odqs)*/
 extern uschar *queue_smtp_domains;     /* Ditto, for these domains */
 
 extern unsigned int random_seed;       /* Seed for random numbers */
 extern uschar *queue_smtp_domains;     /* Ditto, for these domains */
 
 extern unsigned int random_seed;       /* Seed for random numbers */
+extern tree_node *ratelimiters_cmd;    /* Results of command ratelimit checks */
 extern tree_node *ratelimiters_conn;   /* Results of connection ratelimit checks */
 extern tree_node *ratelimiters_mail;   /* Results of per-mail ratelimit checks */
 extern uschar *raw_active_hostname;    /* Pre-expansion */
 extern tree_node *ratelimiters_conn;   /* Results of connection ratelimit checks */
 extern tree_node *ratelimiters_mail;   /* Results of per-mail ratelimit checks */
 extern uschar *raw_active_hostname;    /* Pre-expansion */