src.quota-no-check
changeset 22 aab32b922fa2
parent 19 e86d83f17b1c
child 24 053ea8d7305d
equal deleted inserted replaced
21:385a89e503c7 22:aab32b922fa2
       
     1 # HG changeset patch
       
     2 # Parent 4b02e3191467ca0f3dbad9fd5ed1a8e5e61d3f0a
       
     3 
       
     4 diff -r 4b02e3191467 doc/spec.txt
       
     5 --- a/doc/spec.txt	Fri Apr 01 16:36:30 2011 +0200
       
     6 +++ b/doc/spec.txt	Thu Apr 07 15:38:24 2011 +0200
       
     7 @@ -18340,6 +18340,9 @@
       
     8  large file support (Linux and FreeBSD have this), mailboxes larger than 2G can
       
     9  be handled.
       
    10  
       
    11 +If there is "/no_check" appended, then quota updating is done as usual, but the
       
    12 +over quota condition does not prevent the delivery.
       
    13 +
       
    14  Note: A value of zero is interpreted as "no quota".
       
    15  
       
    16  The expansion happens while Exim is running as root, before it changes uid for
       
    17 @@ -18378,6 +18381,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 quota updating is done as usual, but the
       
    22 +over quota condition does not prevent the delivery.
       
    23 +
       
    24  +--------------------------------------------------------------+
       
    25  |quota_is_inclusive|Use: appendfile|Type: boolean|Default: true|
       
    26  +--------------------------------------------------------------+
       
    27 diff -r 4b02e3191467 src/transports/appendfile.c
       
    28 --- a/src/transports/appendfile.c	Fri Apr 01 16:36:30 2011 +0200
       
    29 +++ b/src/transports/appendfile.c	Thu Apr 07 15:38:24 2011 +0200
       
    30 @@ -237,7 +237,9 @@
       
    31    FALSE,          /* mailstore_format */
       
    32    FALSE,          /* mbx_format */
       
    33    FALSE,          /* quota_warn_threshold_is_percent */
       
    34 -  TRUE            /* quota_is_inclusive */
       
    35 +  TRUE,           /* quota_is_inclusive */
       
    36 +  FALSE,          /* quota_no_check */
       
    37 +  FALSE           /* quota_filecount_no_check */
       
    38  };
       
    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;
       
    47  
       
    48    if (q == NULL) d = default_value; else
       
    49 @@ -348,12 +351,21 @@
       
    50        rest++;
       
    51        }
       
    52  
       
    53 +
       
    54 +    /* For quota and quota_filecount there may be options
       
    55 +    appended. Currently only "no_check", so we can be lazy parsing it */
       
    56 +    if (i < 2 && Ustrstr(rest, "/no_check") == rest)
       
    57 +      {
       
    58 +	 no_check = 1;
       
    59 +	 rest += sizeof("/no_check") - 1;
       
    60 +      }
       
    61 +
       
    62      while (isspace(*rest)) rest++;
       
    63  
       
    64      if (*rest != 0)
       
    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 @@
       
    73      case 0:
       
    74      if (d >= 2.0*1024.0*1024.0*1024.0 && sizeof(off_t) <= 4) which = US"quota";
       
    75      ob->quota_value = (off_t)d;
       
    76 +    ob->quota_no_check = no_check;
       
    77      q = ob->quota_filecount;
       
    78      break;
       
    79  
       
    80      case 1:
       
    81      if (d >= 2.0*1024.0*1024.0*1024.0) which = US"quota_filecount";
       
    82      ob->quota_filecount_value = (int)d;
       
    83 +    ob->quota_filecount_no_check = no_check;
       
    84      q = ob->quota_warn_threshold;
       
    85      break;
       
    86  
       
    87 @@ -1406,10 +1420,12 @@
       
    88  DEBUG(D_transport)
       
    89    {
       
    90    debug_printf("appendfile: mode=%o notify_comsat=%d quota=" OFF_T_FMT
       
    91 +    "%s"
       
    92      " warning=" OFF_T_FMT "%s\n"
       
    93      "  %s=%s format=%s\n  message_prefix=%s\n  message_suffix=%s\n  "
       
    94      "maildir_use_size_file=%s\n",
       
    95      mode, ob->notify_comsat, ob->quota_value,
       
    96 +    ob->quota_no_check? " (no_check)" : "",
       
    97      ob->quota_warn_threshold_value,
       
    98      ob->quota_warn_threshold_is_percent? "%" : "",
       
    99      isdirectory? "directory" : "file",
       
   100 @@ -2773,18 +2789,31 @@
       
   101      }
       
   102    if (mailbox_size + (ob->quota_is_inclusive? message_size:0) > ob->quota_value)
       
   103      {
       
   104 -    DEBUG(D_transport) debug_printf("mailbox quota exceeded\n");
       
   105 -    yield = DEFER;
       
   106 -    errno = ERRNO_EXIMQUOTA;
       
   107 +      DEBUG(D_transport) if (ob->quota_no_check) 
       
   108 +            debug_printf("mailbox quota exceeded but ignored\n");
       
   109 +
       
   110 +      if (!ob->quota_no_check) 
       
   111 +        {
       
   112 +            DEBUG(D_transport) debug_printf("mailbox quota exceeded\n");
       
   113 +            yield = DEFER;
       
   114 +            errno = ERRNO_EXIMQUOTA;
       
   115 +        }
       
   116 +
       
   117      }
       
   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_value > 0
       
   122 +           && mailbox_filecount + (ob->quota_is_inclusive ? 1:0) >
       
   123 +              ob->quota_filecount_value)
       
   124      {
       
   125 -    DEBUG(D_transport) debug_printf("mailbox file count quota exceeded\n");
       
   126 -    yield = DEFER;
       
   127 -    errno = ERRNO_EXIMQUOTA;
       
   128 -    filecount_msg = US" filecount";
       
   129 +        DEBUG(D_transport) if (ob->quota_filecount_no_check)
       
   130 +                debug_printf("mailbox file count quota exceeded but ignored\n");
       
   131 +
       
   132 +        if(!ob->quota_filecount_no_check) 
       
   133 +          {
       
   134 +            DEBUG(D_transport) debug_printf("mailbox file count quota exceeded\n");
       
   135 +            yield = DEFER;
       
   136 +            errno = ERRNO_EXIMQUOTA;
       
   137 +            filecount_msg = US" filecount";
       
   138 +          }
       
   139      }
       
   140    }
       
   141  
       
   142 diff -r 4b02e3191467 src/transports/appendfile.h
       
   143 --- a/src/transports/appendfile.h	Fri Apr 01 16:36:30 2011 +0200
       
   144 +++ b/src/transports/appendfile.h	Thu Apr 07 15:38:24 2011 +0200
       
   145 @@ -72,6 +72,8 @@
       
   146    BOOL  mbx_format;
       
   147    BOOL  quota_warn_threshold_is_percent;
       
   148    BOOL  quota_is_inclusive;
       
   149 +  BOOL  quota_no_check;
       
   150 +  BOOL  quota_filecount_no_check;
       
   151  } appendfile_transport_options_block;
       
   152  
       
   153  /* Restricted creation options */