# HG changeset patch # User Heiko Schlittermann (I24) # Date 1302182932 -7200 # Node ID b0915cb5188168d0916984bd5ced69dbc277eccf # Parent e86d83f17b1ce44447bc7042139befb73f50f264 overquota patch seems to work (creating the overquota file) diff -r e86d83f17b1c -r b0915cb51881 src.overquota --- a/src.overquota Fri Apr 01 16:36:54 2011 +0200 +++ b/src.overquota Thu Apr 07 15:28:52 2011 +0200 @@ -1,9 +1,9 @@ # HG changeset patch -# Parent 19657156fd0205d481cb4c2ceedd10fbed515dc8 +# Parent 70d48c9a5cfe16fac997537f3e902328212548a5 -diff -r 19657156fd02 src/transports/appendfile.c ---- a/src/transports/appendfile.c Fri Apr 01 16:08:04 2011 +0200 -+++ b/src/transports/appendfile.c Fri Apr 01 16:21:46 2011 +0200 +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:27:46 2011 +0200 @@ -104,6 +104,8 @@ #ifdef SUPPORT_MAILDIR { "maildir_format", opt_bool, @@ -21,9 +21,108 @@ US"^(?:cur|new|\\..*)$", /* maildir_dir_regex */ NULL, /* maildir_tag */ NULL, /* maildirfolder_create_regex */ -diff -r 19657156fd02 src/transports/appendfile.h ---- a/src/transports/appendfile.h Fri Apr 01 16:08:04 2011 +0200 -+++ b/src/transports/appendfile.h Fri Apr 01 16:21:46 2011 +0200 +@@ -308,6 +311,7 @@ + ob->maildir_use_size_file = expand_check_condition(ob->expand_maildir_use_size_file, + US"`maildir_use_size_file` in transport", tblock->name); + ++//debug_printf("***>>>>>>>>>>>>> %s\n", ob->maildir_use_size_file); + /* Loop for quota, quota_filecount, quota_warn_threshold, mailbox_size, + mailbox_filecount */ + +@@ -2776,9 +2780,10 @@ + is for the mailbox already being over quota (i.e. the current message is not + included in the check). */ + +-if (!disable_quota && ob->quota_value > 0) ++if (!disable_quota && (ob->quota_value > 0 || ob->quota_filecount_value > 0)) + { +- DEBUG(D_transport) ++ int overquota = 0; ++ DEBUG(D_transport) + { + debug_printf("Exim quota = " OFF_T_FMT " old size = " OFF_T_FMT + " this message = %d (%sincluded)\n", +@@ -2789,31 +2794,62 @@ + } + if (mailbox_size + (ob->quota_is_inclusive? message_size:0) > ob->quota_value) + { +- DEBUG(D_transport) if (ob->quota_no_check) +- debug_printf("mailbox quota exceeded but ignored\n"); +- +- if (!ob->quota_no_check) ++ overquota = 1; ++ if (ob->quota_no_check) ++ { ++ DEBUG(D_transport) if (ob->quota_no_check) ++ debug_printf("mailbox quota exceeded (but ignored)\n"); ++ } ++ else + { + 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) 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"; +- } ++ overquota = 1; ++ if (ob->quota_no_check) ++ { ++ DEBUG(D_transport) if (ob->quota_filecount_no_check) ++ debug_printf("mailbox file count quota exceeded (but ignored)\n"); ++ ++ } ++ else ++ { ++ DEBUG(D_transport) debug_printf("mailbox file count quota exceeded\n"); ++ yield = DEFER; ++ errno = ERRNO_EXIMQUOTA; ++ filecount_msg = US" filecount"; ++ } ++ } ++ ++ /* now we'll take care about the overquota file, using it as a timestamp ++ * to record this overquota event */ ++ if (ob->maildir_overquota_file) ++ { ++ uschar *overquota_file = string_sprintf("%s/%s", path, ob->maildir_overquota_file); ++ if (overquota) ++ { ++ int _errno = errno; ++ errno = 0; ++ (void) open(overquota_file, O_CREAT|O_EXCL|O_RDWR, 0444); ++ DEBUG(D_transport) debug_printf("attempt to create `%s': %s\n", ++ overquota_file, strerror(errno)); ++ errno = _errno; ++ } ++ else ++ { ++ int _errno = errno; ++ errno = 0; ++ (void) unlink(overquota_file); ++ DEBUG(D_transport) debug_printf("attempt to remove `%s': %s\n", ++ overquota_file, strerror(errno)); ++ errno = _errno; ++ } + } + } + +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:27:46 2011 +0200 @@ -24,6 +24,7 @@ uschar *mailbox_size_string; uschar *mailbox_filecount_string;