summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>2017-06-25 22:54:08 +0200
committerHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>2017-06-25 23:00:18 +0200
commitd291c7670e4c370cdc4f631ea58f82c7f4f87823 (patch)
treea31abed23e38d6071b40b311420a31491edce01b /src
parent53d77ba6ef973fcbb4b0c17a60bc9229e45aa1ae (diff)
Add quota/quota_filecount transport option modifier "no_check" Bug 1115
This option modifier allows to ignore the quota limits, but update the maildirsize file.
Diffstat (limited to 'src')
-rw-r--r--src/src/transports/appendfile.c60
-rw-r--r--src/src/transports/appendfile.h2
2 files changed, 47 insertions, 15 deletions
diff --git a/src/src/transports/appendfile.c b/src/src/transports/appendfile.c
index da5d8aa0a..56200710f 100644
--- a/src/src/transports/appendfile.c
+++ b/src/src/transports/appendfile.c
@@ -234,7 +234,9 @@ appendfile_transport_options_block appendfile_transport_option_defaults = {
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 */
};
@@ -285,9 +287,11 @@ mailbox_filecount */
for (i = 0; i < 5; i++)
{
double d;
+ int no_check = 0;
uschar *which = NULL;
- if (q == NULL) d = default_value; else
+ if (q == NULL) d = default_value;
+ else
{
uschar *rest;
uschar *s = expand_string(q);
@@ -321,12 +325,21 @@ for (i = 0; i < 5; i++)
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;
}
}
@@ -338,12 +351,14 @@ for (i = 0; i < 5; i++)
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;
@@ -1383,10 +1398,13 @@ else
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_filecount_no_check? " (no_check_filecount)" : "",
ob->quota_warn_threshold_value,
ob->quota_warn_threshold_is_percent? "%" : "",
isdirectory? "directory" : "file",
@@ -2777,21 +2795,33 @@ if (!disable_quota && ob->quota_value > 0)
debug_printf(" file count quota = %d count = %d\n",
ob->quota_filecount_value, mailbox_filecount);
}
+
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;
- }
- 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";
+
+ if (!ob->quota_no_check)
+ {
+ DEBUG(D_transport) debug_printf("mailbox quota exceeded\n");
+ yield = DEFER;
+ errno = ERRNO_EXIMQUOTA;
+ }
+ else DEBUG(D_transport) debug_printf("mailbox quota exceeded but ignored\n");
+
}
+
+ if (ob->quota_filecount_value > 0
+ && mailbox_filecount + (ob->quota_is_inclusive ? 1:0) >
+ ob->quota_filecount_value)
+ 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";
+ }
+ else DEBUG(D_transport) if (ob->quota_filecount_no_check)
+ debug_printf("mailbox file count quota exceeded but ignored\n");
+
}
/* If we are writing in MBX format, what we actually do is to write the message
diff --git a/src/src/transports/appendfile.h b/src/src/transports/appendfile.h
index 52dc3baca..70330857d 100644
--- a/src/src/transports/appendfile.h
+++ b/src/src/transports/appendfile.h
@@ -70,6 +70,8 @@ typedef struct {
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 */