src.quota-ignore
changeset 18 cacfba0189d0
parent 6 d2183655483b
child 19 e86d83f17b1c
equal deleted inserted replaced
17:b0076c5c7eec 18:cacfba0189d0
     1 # HG changeset patch
     1 # HG changeset patch
     2 # Parent 717fd3d2296015e18687e4b3ecb259f7ded5e15f
     2 # Parent 525ee4a1a637802b655f286de8cd9c737025ed37
     3 
     3 
     4 diff -r 717fd3d22960 src/transports/appendfile.c
     4 diff -r 525ee4a1a637 doc/spec.txt
     5 --- a/src/transports/appendfile.c	Sun Feb 13 14:05:44 2011 +0100
     5 --- a/doc/spec.txt	Fri Apr 01 14:06:59 2011 +0200
     6 +++ b/src/transports/appendfile.c	Tue Feb 15 11:18:53 2011 +0100
     6 +++ b/doc/spec.txt	Fri Apr 01 16:08:04 2011 +0200
     7 @@ -31,6 +31,8 @@
     7 @@ -18340,6 +18340,9 @@
     8  #define THRESHOLD_CHECK  (ob->quota_warn_threshold_value > 0 && \
     8  large file support (Linux and FreeBSD have this), mailboxes larger than 2G can
     9    (!ob->quota_warn_threshold_is_percent || ob->quota_value > 0))
     9  be handled.
    10  
    10  
    11 +#define QUOTA_CHECK      (ob->quota_value > 0 && !ob->quota_no_check)
    11 +If there is "/no_check" appended, then all processing is done as usual, but the
       
    12 +over quota condition is not checked.
    12 +
    13 +
       
    14  Note: A value of zero is interpreted as "no quota".
    13  
    15  
    14  /* Options specific to the appendfile transport. They must be in alphabetic
    16  The expansion happens while Exim is running as root, before it changes uid for
    15  order (note that "_" comes before the lower case letters). Some of them are
    17 @@ -18378,6 +18381,9 @@
    16 @@ -236,7 +238,9 @@
    18  failure causes delivery to be deferred. A value of zero is interpreted as "no
       
    19  quota".
       
    20  
       
    21 +if there is "/no_check" appended, then all processing is done as usual, but
       
    22 +the over quota condition is not checked.
       
    23 +
       
    24  +--------------------------------------------------------------+
       
    25  |quota_is_inclusive|Use: appendfile|Type: boolean|Default: true|
       
    26  +--------------------------------------------------------------+
       
    27 diff -r 525ee4a1a637 src/transports/appendfile.c
       
    28 --- a/src/transports/appendfile.c	Fri Apr 01 14:06:59 2011 +0200
       
    29 +++ b/src/transports/appendfile.c	Fri Apr 01 16:08:04 2011 +0200
       
    30 @@ -237,7 +237,9 @@
    17    FALSE,          /* mailstore_format */
    31    FALSE,          /* mailstore_format */
    18    FALSE,          /* mbx_format */
    32    FALSE,          /* mbx_format */
    19    FALSE,          /* quota_warn_threshold_is_percent */
    33    FALSE,          /* quota_warn_threshold_is_percent */
    20 -  TRUE            /* quota_is_inclusive */
    34 -  TRUE            /* quota_is_inclusive */
    21 +  TRUE,           /* quota_is_inclusive */
    35 +  TRUE,           /* quota_is_inclusive */
    22 +  FALSE,          /* quota_no_check */
    36 +  FALSE,          /* quota_no_check */
    23 +  FALSE           /* quota_filecount_no_check */
    37 +  FALSE           /* quota_filecount_no_check */
    24  };
    38  };
    25  
    39  
       
    40  void hs12_lock(int fd, int type, const char* msg)
       
    41 @@ -312,6 +314,7 @@
       
    42  for (i = 0; i < 5; i++)
       
    43    {
       
    44    double d;
       
    45 +  int no_check = 0;
       
    46    uschar *which = NULL;
    26  
    47  
    27 @@ -270,6 +274,7 @@
    48    if (q == NULL) d = default_value; else
    28    (appendfile_transport_options_block *)(tblock->options_block);
    49 @@ -348,12 +351,21 @@
    29  uschar *q = ob->quota;
       
    30  double default_value = 0.0;
       
    31 +int no_check = 0;
       
    32  int i;
       
    33  
       
    34  addrlist = addrlist;    /* Keep picky compilers happy */
       
    35 @@ -323,6 +328,15 @@
       
    36        rest++;
    50        rest++;
    37        }
    51        }
    38  
    52  
    39 +
    53 +
    40 +    /* For quota and quota_filecount there may be options
    54 +    /* For quota and quota_filecount there may be options
    41 +    appended. Currently only "no_check", so we can be lazy parsing it */
    55 +    appended. Currently only "no_check", so we can be lazy parsing it */
    42 +    if (i < 2 && Ustrstr(rest, "/no_check") == rest)
    56 +    if (i < 2 && Ustrstr(rest, "/no_check") == rest)
    43 +      {
    57 +      {
    44 +	 no_check = 1;
    58 +	 no_check = 1;
    45 +	 rest += strlen("/no_check");
    59 +	 rest += sizeof("/no_check") - 1;
    46 +      }
    60 +      }
    47 +
    61 +
    48      while (isspace(*rest)) rest++;
    62      while (isspace(*rest)) rest++;
    49  
    63  
    50      if (*rest != 0)
    64      if (*rest != 0)
    51 @@ -340,12 +354,14 @@
    65        {
       
    66        *errmsg = string_sprintf("Malformed value \"%s\" (expansion of \"%s\") "
       
    67 -        "in %s transport", s, q, tblock->name);
       
    68 +        "in %s transport [%s]", s, q, tblock->name);
       
    69        return FAIL;
       
    70        }
       
    71      }
       
    72 @@ -365,12 +377,14 @@
    52      case 0:
    73      case 0:
    53      if (d >= 2.0*1024.0*1024.0*1024.0 && sizeof(off_t) <= 4) which = US"quota";
    74      if (d >= 2.0*1024.0*1024.0*1024.0 && sizeof(off_t) <= 4) which = US"quota";
    54      ob->quota_value = (off_t)d;
    75      ob->quota_value = (off_t)d;
    55 +    ob->quota_no_check = no_check;
    76 +    ob->quota_no_check = no_check;
    56      q = ob->quota_filecount;
    77      q = ob->quota_filecount;
    61      ob->quota_filecount_value = (int)d;
    82      ob->quota_filecount_value = (int)d;
    62 +    ob->quota_filecount_no_check = no_check;
    83 +    ob->quota_filecount_no_check = no_check;
    63      q = ob->quota_warn_threshold;
    84      q = ob->quota_warn_threshold;
    64      break;
    85      break;
    65  
    86  
    66 @@ -1382,10 +1398,12 @@
    87 @@ -1406,10 +1420,12 @@
    67  DEBUG(D_transport)
    88  DEBUG(D_transport)
    68    {
    89    {
    69    debug_printf("appendfile: mode=%o notify_comsat=%d quota=" OFF_T_FMT
    90    debug_printf("appendfile: mode=%o notify_comsat=%d quota=" OFF_T_FMT
    70 +    "%s"
    91 +    "%s"
    71      " warning=" OFF_T_FMT "%s\n"
    92      " warning=" OFF_T_FMT "%s\n"
    72      "  %s=%s format=%s\n  message_prefix=%s\n  message_suffix=%s\n  "
    93      "  %s=%s format=%s\n  message_prefix=%s\n  message_suffix=%s\n  "
    73      "maildir_use_size_file=%s\n",
    94      "maildir_use_size_file=%s\n",
    74      mode, ob->notify_comsat, ob->quota_value,
    95      mode, ob->notify_comsat, ob->quota_value,
    75 +    ob->quota_no_check? " (no_check)" : ""
    96 +    ob->quota_no_check? " (no_check)" : "",
    76      ob->quota_warn_threshold_value,
    97      ob->quota_warn_threshold_value,
    77      ob->quota_warn_threshold_is_percent? "%" : "",
    98      ob->quota_warn_threshold_is_percent? "%" : "",
    78      isdirectory? "directory" : "file",
    99      isdirectory? "directory" : "file",
    79 @@ -2274,7 +2292,7 @@
   100 @@ -2771,15 +2787,23 @@
    80    create the file. When maildir support is not compiled,
   101      debug_printf("  file count quota = %d count = %d\n",
    81    ob->maildir_use_size_file is always FALSE. */
   102        ob->quota_filecount_value, mailbox_filecount);
    82  
   103      }
    83 -  if (ob->quota_value > 0 || THRESHOLD_CHECK || ob->maildir_use_size_file)
   104 -  if (mailbox_size + (ob->quota_is_inclusive? message_size:0) > ob->quota_value)
    84 +  if (QUOTA_CHECK || THRESHOLD_CHECK || ob->maildir_use_size_file)
   105 +  DEBUG(D_transport) {
       
   106 +	if (ob->quota_no_check) 
       
   107 +		debug_printf("not checking quota (/no_check seen)\n");
       
   108 +	if (ob->quota_filecount_no_check) 
       
   109 +		debug_printf("not checking quota filecount (/no_check seen)\n");
       
   110 +  }
       
   111 +  if (!ob->quota_no_check 
       
   112 +      && mailbox_size + (ob->quota_is_inclusive? message_size:0) > ob->quota_value)
    85      {
   113      {
    86      const uschar *error;
   114      DEBUG(D_transport) debug_printf("mailbox quota exceeded\n");
    87      int offset;
   115      yield = DEFER;
    88 diff -r 717fd3d22960 src/transports/appendfile.h
   116      errno = ERRNO_EXIMQUOTA;
    89 --- a/src/transports/appendfile.h	Sun Feb 13 14:05:44 2011 +0100
   117      }
    90 +++ b/src/transports/appendfile.h	Tue Feb 15 11:18:53 2011 +0100
   118 -  else if (ob->quota_filecount_value > 0 &&
       
   119 -           mailbox_filecount + (ob->quota_is_inclusive ? 1:0) >
       
   120 -             ob->quota_filecount_value)
       
   121 +  else if (!ob->quota_filecount_no_check 
       
   122 +           && ob->quota_filecount_value > 0
       
   123 +           && mailbox_filecount + (ob->quota_is_inclusive ? 1:0) >
       
   124 +              ob->quota_filecount_value)
       
   125      {
       
   126      DEBUG(D_transport) debug_printf("mailbox file count quota exceeded\n");
       
   127      yield = DEFER;
       
   128 diff -r 525ee4a1a637 src/transports/appendfile.h
       
   129 --- a/src/transports/appendfile.h	Fri Apr 01 14:06:59 2011 +0200
       
   130 +++ b/src/transports/appendfile.h	Fri Apr 01 16:08:04 2011 +0200
    91 @@ -72,6 +72,8 @@
   131 @@ -72,6 +72,8 @@
    92    BOOL  mbx_format;
   132    BOOL  mbx_format;
    93    BOOL  quota_warn_threshold_is_percent;
   133    BOOL  quota_warn_threshold_is_percent;
    94    BOOL  quota_is_inclusive;
   134    BOOL  quota_is_inclusive;
    95 +  BOOL  quota_no_check;
   135 +  BOOL  quota_no_check;