expand the maildir_overquota_file option, documented
authorHeiko Schlittermann (I24) <hs@schlittermann.de>
Thu, 07 Apr 2011 16:06:04 +0200
changeset 22 aab32b922fa2
parent 21 385a89e503c7
child 23 d9d5bb696645
expand the maildir_overquota_file option, documented
series
src.overquota
src.quota-ignore
src.quota-no-check
--- a/series	Thu Apr 07 15:30:09 2011 +0200
+++ b/series	Thu Apr 07 16:06:04 2011 +0200
@@ -4,5 +4,5 @@
 src.maildir_use_size_file #+4.74
 src.fixed_ensure_maildirsize #+4.74
 src.lock_maildirsize #+4.74
-src.quota-ignore #+4.74
+src.quota-no-check #+4.74
 src.overquota #+4.74
--- a/src.overquota	Thu Apr 07 15:30:09 2011 +0200
+++ b/src.overquota	Thu Apr 07 16:06:04 2011 +0200
@@ -1,9 +1,29 @@
 # HG changeset patch
-# Parent 70d48c9a5cfe16fac997537f3e902328212548a5
+# Parent e5aaf8e99b1e7f5ff16649a4b8a69716b82b9cc2
 
-diff -r 70d48c9a5cfe src/transports/appendfile.c
---- a/src/transports/appendfile.c	Fri Apr 01 16:36:30 2011 +0200
-+++ b/src/transports/appendfile.c	Thu Apr 07 15:29:50 2011 +0200
+diff -r e5aaf8e99b1e doc/spec.txt
+--- a/doc/spec.txt	Thu Apr 07 15:38:24 2011 +0200
++++ b/doc/spec.txt	Thu Apr 07 16:05:46 2011 +0200
+@@ -18143,6 +18143,16 @@
+ or not it ends with "/". This option is available only if SUPPORT_MAILDIR is
+ present in Local/Makefile. See section 26.5 below for further details.
+ 
+++-------------------------------------------------------------------+
++|maildir_overquota_file|Use: appendfile|Type: string*|Default: unset|
+++-------------------------------------------------------------------+
++
++If this option is set, Exim will create a timestamp file with this name (after
++expansion) as soon as the the MTA imposed quota limit is hit. If Exim finds
++this file, but the quota is not reached, the file gets removed.
++
++The filename is taken relative to the mailir directory.
++
+ +-----------------------------------------------------------------------------+
+ |maildir_quota_directory_regex|Use: appendfile|Type: string|Default: See below|
+ +-----------------------------------------------------------------------------+
+diff -r e5aaf8e99b1e src/transports/appendfile.c
+--- a/src/transports/appendfile.c	Thu Apr 07 15:38:24 2011 +0200
++++ b/src/transports/appendfile.c	Thu Apr 07 16:05:46 2011 +0200
 @@ -104,6 +104,8 @@
  #ifdef SUPPORT_MAILDIR
    { "maildir_format",    opt_bool,
@@ -98,7 +118,7 @@
 +   * to record this overquota event */
 +  if (ob->maildir_overquota_file)
 +    {
-+    uschar *overquota_file = string_sprintf("%s/%s", path, ob->maildir_overquota_file);
++    uschar *overquota_file = string_sprintf("%s/%s", path, expand_string(ob->maildir_overquota_file));
 +    if (overquota) 
 +      {
 +        int _errno = errno;
@@ -120,9 +140,9 @@
      }
    }
  
-diff -r 70d48c9a5cfe src/transports/appendfile.h
---- a/src/transports/appendfile.h	Fri Apr 01 16:36:30 2011 +0200
-+++ b/src/transports/appendfile.h	Thu Apr 07 15:29:50 2011 +0200
+diff -r e5aaf8e99b1e src/transports/appendfile.h
+--- a/src/transports/appendfile.h	Thu Apr 07 15:38:24 2011 +0200
++++ b/src/transports/appendfile.h	Thu Apr 07 16:05:46 2011 +0200
 @@ -24,6 +24,7 @@
    uschar *mailbox_size_string;
    uschar *mailbox_filecount_string;
--- a/src.quota-ignore	Thu Apr 07 15:30:09 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-# HG changeset patch
-# Parent 525ee4a1a637802b655f286de8cd9c737025ed37
-
-diff -r 525ee4a1a637 doc/spec.txt
---- a/doc/spec.txt	Fri Apr 01 14:06:59 2011 +0200
-+++ b/doc/spec.txt	Fri Apr 01 16:33:35 2011 +0200
-@@ -18340,6 +18340,9 @@
- large file support (Linux and FreeBSD have this), mailboxes larger than 2G can
- be handled.
- 
-+If there is "/no_check" appended, then all processing is done as usual, but the
-+over quota condition is not checked.
-+
- Note: A value of zero is interpreted as "no quota".
- 
- The expansion happens while Exim is running as root, before it changes uid for
-@@ -18378,6 +18381,9 @@
- failure causes delivery to be deferred. A value of zero is interpreted as "no
- quota".
- 
-+if there is "/no_check" appended, then all processing is done as usual, but
-+the over quota condition is not checked.
-+
- +--------------------------------------------------------------+
- |quota_is_inclusive|Use: appendfile|Type: boolean|Default: true|
- +--------------------------------------------------------------+
-diff -r 525ee4a1a637 src/transports/appendfile.c
---- a/src/transports/appendfile.c	Fri Apr 01 14:06:59 2011 +0200
-+++ b/src/transports/appendfile.c	Fri Apr 01 16:33:35 2011 +0200
-@@ -237,7 +237,9 @@
-   FALSE,          /* mailstore_format */
-   FALSE,          /* mbx_format */
-   FALSE,          /* quota_warn_threshold_is_percent */
--  TRUE            /* quota_is_inclusive */
-+  TRUE,           /* quota_is_inclusive */
-+  FALSE,          /* quota_no_check */
-+  FALSE           /* quota_filecount_no_check */
- };
- 
- void hs12_lock(int fd, int type, const char* msg)
-@@ -312,6 +314,7 @@
- for (i = 0; i < 5; i++)
-   {
-   double d;
-+  int no_check = 0;
-   uschar *which = NULL;
- 
-   if (q == NULL) d = default_value; else
-@@ -348,12 +351,21 @@
-       rest++;
-       }
- 
-+
-+    /* For quota and quota_filecount there may be options
-+    appended. Currently only "no_check", so we can be lazy parsing it */
-+    if (i < 2 && Ustrstr(rest, "/no_check") == rest)
-+      {
-+	 no_check = 1;
-+	 rest += sizeof("/no_check") - 1;
-+      }
-+
-     while (isspace(*rest)) rest++;
- 
-     if (*rest != 0)
-       {
-       *errmsg = string_sprintf("Malformed value \"%s\" (expansion of \"%s\") "
--        "in %s transport", s, q, tblock->name);
-+        "in %s transport [%s]", s, q, tblock->name);
-       return FAIL;
-       }
-     }
-@@ -365,12 +377,14 @@
-     case 0:
-     if (d >= 2.0*1024.0*1024.0*1024.0 && sizeof(off_t) <= 4) which = US"quota";
-     ob->quota_value = (off_t)d;
-+    ob->quota_no_check = no_check;
-     q = ob->quota_filecount;
-     break;
- 
-     case 1:
-     if (d >= 2.0*1024.0*1024.0*1024.0) which = US"quota_filecount";
-     ob->quota_filecount_value = (int)d;
-+    ob->quota_filecount_no_check = no_check;
-     q = ob->quota_warn_threshold;
-     break;
- 
-@@ -1406,10 +1420,12 @@
- DEBUG(D_transport)
-   {
-   debug_printf("appendfile: mode=%o notify_comsat=%d quota=" OFF_T_FMT
-+    "%s"
-     " warning=" OFF_T_FMT "%s\n"
-     "  %s=%s format=%s\n  message_prefix=%s\n  message_suffix=%s\n  "
-     "maildir_use_size_file=%s\n",
-     mode, ob->notify_comsat, ob->quota_value,
-+    ob->quota_no_check? " (no_check)" : "",
-     ob->quota_warn_threshold_value,
-     ob->quota_warn_threshold_is_percent? "%" : "",
-     isdirectory? "directory" : "file",
-@@ -2773,18 +2789,31 @@
-     }
-   if (mailbox_size + (ob->quota_is_inclusive? message_size:0) > ob->quota_value)
-     {
--    DEBUG(D_transport) debug_printf("mailbox quota exceeded\n");
--    yield = DEFER;
--    errno = ERRNO_EXIMQUOTA;
-+      DEBUG(D_transport) if (ob->quota_no_check) 
-+            debug_printf("mailbox quota exceeded but ignored\n");
-+
-+      if (!ob->quota_no_check) 
-+        {
-+            DEBUG(D_transport) debug_printf("mailbox quota exceeded\n");
-+            yield = DEFER;
-+            errno = ERRNO_EXIMQUOTA;
-+        }
-+
-     }
--  else if (ob->quota_filecount_value > 0 &&
--           mailbox_filecount + (ob->quota_is_inclusive ? 1:0) >
--             ob->quota_filecount_value)
-+  else if (ob->quota_filecount_value > 0
-+           && mailbox_filecount + (ob->quota_is_inclusive ? 1:0) >
-+              ob->quota_filecount_value)
-     {
--    DEBUG(D_transport) debug_printf("mailbox file count quota exceeded\n");
--    yield = DEFER;
--    errno = ERRNO_EXIMQUOTA;
--    filecount_msg = US" filecount";
-+        DEBUG(D_transport) if (ob->quota_filecount_no_check)
-+                debug_printf("mailbox file count quota exceeded but ignored\n");
-+
-+        if(!ob->quota_filecount_no_check) 
-+          {
-+            DEBUG(D_transport) debug_printf("mailbox file count quota exceeded\n");
-+            yield = DEFER;
-+            errno = ERRNO_EXIMQUOTA;
-+            filecount_msg = US" filecount";
-+          }
-     }
-   }
- 
-diff -r 525ee4a1a637 src/transports/appendfile.h
---- a/src/transports/appendfile.h	Fri Apr 01 14:06:59 2011 +0200
-+++ b/src/transports/appendfile.h	Fri Apr 01 16:33:35 2011 +0200
-@@ -72,6 +72,8 @@
-   BOOL  mbx_format;
-   BOOL  quota_warn_threshold_is_percent;
-   BOOL  quota_is_inclusive;
-+  BOOL  quota_no_check;
-+  BOOL  quota_filecount_no_check;
- } appendfile_transport_options_block;
- 
- /* Restricted creation options */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src.quota-no-check	Thu Apr 07 16:06:04 2011 +0200
@@ -0,0 +1,153 @@
+# HG changeset patch
+# Parent 4b02e3191467ca0f3dbad9fd5ed1a8e5e61d3f0a
+
+diff -r 4b02e3191467 doc/spec.txt
+--- a/doc/spec.txt	Fri Apr 01 16:36:30 2011 +0200
++++ b/doc/spec.txt	Thu Apr 07 15:38:24 2011 +0200
+@@ -18340,6 +18340,9 @@
+ large file support (Linux and FreeBSD have this), mailboxes larger than 2G can
+ be handled.
+ 
++If there is "/no_check" appended, then quota updating is done as usual, but the
++over quota condition does not prevent the delivery.
++
+ Note: A value of zero is interpreted as "no quota".
+ 
+ The expansion happens while Exim is running as root, before it changes uid for
+@@ -18378,6 +18381,9 @@
+ failure causes delivery to be deferred. A value of zero is interpreted as "no
+ quota".
+ 
++If there is "/no_check" appended, then quota updating is done as usual, but the
++over quota condition does not prevent the delivery.
++
+ +--------------------------------------------------------------+
+ |quota_is_inclusive|Use: appendfile|Type: boolean|Default: true|
+ +--------------------------------------------------------------+
+diff -r 4b02e3191467 src/transports/appendfile.c
+--- a/src/transports/appendfile.c	Fri Apr 01 16:36:30 2011 +0200
++++ b/src/transports/appendfile.c	Thu Apr 07 15:38:24 2011 +0200
+@@ -237,7 +237,9 @@
+   FALSE,          /* mailstore_format */
+   FALSE,          /* mbx_format */
+   FALSE,          /* quota_warn_threshold_is_percent */
+-  TRUE            /* quota_is_inclusive */
++  TRUE,           /* quota_is_inclusive */
++  FALSE,          /* quota_no_check */
++  FALSE           /* quota_filecount_no_check */
+ };
+ 
+ void hs12_lock(int fd, int type, const char* msg)
+@@ -312,6 +314,7 @@
+ for (i = 0; i < 5; i++)
+   {
+   double d;
++  int no_check = 0;
+   uschar *which = NULL;
+ 
+   if (q == NULL) d = default_value; else
+@@ -348,12 +351,21 @@
+       rest++;
+       }
+ 
++
++    /* For quota and quota_filecount there may be options
++    appended. Currently only "no_check", so we can be lazy parsing it */
++    if (i < 2 && Ustrstr(rest, "/no_check") == rest)
++      {
++	 no_check = 1;
++	 rest += sizeof("/no_check") - 1;
++      }
++
+     while (isspace(*rest)) rest++;
+ 
+     if (*rest != 0)
+       {
+       *errmsg = string_sprintf("Malformed value \"%s\" (expansion of \"%s\") "
+-        "in %s transport", s, q, tblock->name);
++        "in %s transport [%s]", s, q, tblock->name);
+       return FAIL;
+       }
+     }
+@@ -365,12 +377,14 @@
+     case 0:
+     if (d >= 2.0*1024.0*1024.0*1024.0 && sizeof(off_t) <= 4) which = US"quota";
+     ob->quota_value = (off_t)d;
++    ob->quota_no_check = no_check;
+     q = ob->quota_filecount;
+     break;
+ 
+     case 1:
+     if (d >= 2.0*1024.0*1024.0*1024.0) which = US"quota_filecount";
+     ob->quota_filecount_value = (int)d;
++    ob->quota_filecount_no_check = no_check;
+     q = ob->quota_warn_threshold;
+     break;
+ 
+@@ -1406,10 +1420,12 @@
+ DEBUG(D_transport)
+   {
+   debug_printf("appendfile: mode=%o notify_comsat=%d quota=" OFF_T_FMT
++    "%s"
+     " warning=" OFF_T_FMT "%s\n"
+     "  %s=%s format=%s\n  message_prefix=%s\n  message_suffix=%s\n  "
+     "maildir_use_size_file=%s\n",
+     mode, ob->notify_comsat, ob->quota_value,
++    ob->quota_no_check? " (no_check)" : "",
+     ob->quota_warn_threshold_value,
+     ob->quota_warn_threshold_is_percent? "%" : "",
+     isdirectory? "directory" : "file",
+@@ -2773,18 +2789,31 @@
+     }
+   if (mailbox_size + (ob->quota_is_inclusive? message_size:0) > ob->quota_value)
+     {
+-    DEBUG(D_transport) debug_printf("mailbox quota exceeded\n");
+-    yield = DEFER;
+-    errno = ERRNO_EXIMQUOTA;
++      DEBUG(D_transport) if (ob->quota_no_check) 
++            debug_printf("mailbox quota exceeded but ignored\n");
++
++      if (!ob->quota_no_check) 
++        {
++            DEBUG(D_transport) debug_printf("mailbox quota exceeded\n");
++            yield = DEFER;
++            errno = ERRNO_EXIMQUOTA;
++        }
++
+     }
+-  else if (ob->quota_filecount_value > 0 &&
+-           mailbox_filecount + (ob->quota_is_inclusive ? 1:0) >
+-             ob->quota_filecount_value)
++  else if (ob->quota_filecount_value > 0
++           && mailbox_filecount + (ob->quota_is_inclusive ? 1:0) >
++              ob->quota_filecount_value)
+     {
+-    DEBUG(D_transport) debug_printf("mailbox file count quota exceeded\n");
+-    yield = DEFER;
+-    errno = ERRNO_EXIMQUOTA;
+-    filecount_msg = US" filecount";
++        DEBUG(D_transport) if (ob->quota_filecount_no_check)
++                debug_printf("mailbox file count quota exceeded but ignored\n");
++
++        if(!ob->quota_filecount_no_check) 
++          {
++            DEBUG(D_transport) debug_printf("mailbox file count quota exceeded\n");
++            yield = DEFER;
++            errno = ERRNO_EXIMQUOTA;
++            filecount_msg = US" filecount";
++          }
+     }
+   }
+ 
+diff -r 4b02e3191467 src/transports/appendfile.h
+--- a/src/transports/appendfile.h	Fri Apr 01 16:36:30 2011 +0200
++++ b/src/transports/appendfile.h	Thu Apr 07 15:38:24 2011 +0200
+@@ -72,6 +72,8 @@
+   BOOL  mbx_format;
+   BOOL  quota_warn_threshold_is_percent;
+   BOOL  quota_is_inclusive;
++  BOOL  quota_no_check;
++  BOOL  quota_filecount_no_check;
+ } appendfile_transport_options_block;
+ 
+ /* Restricted creation options */