src.quota-no-check
changeset 22 aab32b922fa2
parent 19 e86d83f17b1c
child 24 053ea8d7305d
--- /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 */