src.overquota
changeset 20 b0915cb51881
parent 19 e86d83f17b1c
child 21 385a89e503c7
equal deleted inserted replaced
19:e86d83f17b1c 20:b0915cb51881
     1 # HG changeset patch
     1 # HG changeset patch
     2 # Parent 19657156fd0205d481cb4c2ceedd10fbed515dc8
     2 # Parent 70d48c9a5cfe16fac997537f3e902328212548a5
     3 
     3 
     4 diff -r 19657156fd02 src/transports/appendfile.c
     4 diff -r 70d48c9a5cfe src/transports/appendfile.c
     5 --- a/src/transports/appendfile.c	Fri Apr 01 16:08:04 2011 +0200
     5 --- a/src/transports/appendfile.c	Fri Apr 01 16:36:30 2011 +0200
     6 +++ b/src/transports/appendfile.c	Fri Apr 01 16:21:46 2011 +0200
     6 +++ b/src/transports/appendfile.c	Thu Apr 07 15:27:46 2011 +0200
     7 @@ -104,6 +104,8 @@
     7 @@ -104,6 +104,8 @@
     8  #ifdef SUPPORT_MAILDIR
     8  #ifdef SUPPORT_MAILDIR
     9    { "maildir_format",    opt_bool,
     9    { "maildir_format",    opt_bool,
    10        (void *)offsetof(appendfile_transport_options_block, maildir_format ) } ,
    10        (void *)offsetof(appendfile_transport_options_block, maildir_format ) } ,
    11 +  { "maildir_overquota_file",    opt_stringptr,
    11 +  { "maildir_overquota_file",    opt_stringptr,
    19    NULL,           /* expand_maildir_use_size_file */ 
    19    NULL,           /* expand_maildir_use_size_file */ 
    20 +  NULL,           /* maildir_overquota_file */
    20 +  NULL,           /* maildir_overquota_file */
    21    US"^(?:cur|new|\\..*)$",  /* maildir_dir_regex */
    21    US"^(?:cur|new|\\..*)$",  /* maildir_dir_regex */
    22    NULL,           /* maildir_tag */
    22    NULL,           /* maildir_tag */
    23    NULL,           /* maildirfolder_create_regex */
    23    NULL,           /* maildirfolder_create_regex */
    24 diff -r 19657156fd02 src/transports/appendfile.h
    24 @@ -308,6 +311,7 @@
    25 --- a/src/transports/appendfile.h	Fri Apr 01 16:08:04 2011 +0200
    25    ob->maildir_use_size_file = expand_check_condition(ob->expand_maildir_use_size_file, 
    26 +++ b/src/transports/appendfile.h	Fri Apr 01 16:21:46 2011 +0200
    26      US"`maildir_use_size_file` in transport", tblock->name);
       
    27  
       
    28 +//debug_printf("***>>>>>>>>>>>>> %s\n", ob->maildir_use_size_file);
       
    29  /* Loop for quota, quota_filecount, quota_warn_threshold, mailbox_size,
       
    30  mailbox_filecount */
       
    31  
       
    32 @@ -2776,9 +2780,10 @@
       
    33  is for the mailbox already being over quota (i.e. the current message is not
       
    34  included in the check). */
       
    35  
       
    36 -if (!disable_quota && ob->quota_value > 0)
       
    37 +if (!disable_quota && (ob->quota_value > 0 || ob->quota_filecount_value > 0))
       
    38    {
       
    39 -  DEBUG(D_transport)
       
    40 +    int overquota = 0;
       
    41 +    DEBUG(D_transport)
       
    42      {
       
    43      debug_printf("Exim quota = " OFF_T_FMT " old size = " OFF_T_FMT
       
    44        " this message = %d (%sincluded)\n",
       
    45 @@ -2789,31 +2794,62 @@
       
    46      }
       
    47    if (mailbox_size + (ob->quota_is_inclusive? message_size:0) > ob->quota_value)
       
    48      {
       
    49 -      DEBUG(D_transport) if (ob->quota_no_check) 
       
    50 -            debug_printf("mailbox quota exceeded but ignored\n");
       
    51 -
       
    52 -      if (!ob->quota_no_check) 
       
    53 +      overquota = 1;
       
    54 +      if (ob->quota_no_check)
       
    55 +        {
       
    56 +          DEBUG(D_transport) if (ob->quota_no_check) 
       
    57 +            debug_printf("mailbox quota exceeded (but ignored)\n");
       
    58 +        }
       
    59 +      else
       
    60          {
       
    61              DEBUG(D_transport) debug_printf("mailbox quota exceeded\n");
       
    62              yield = DEFER;
       
    63              errno = ERRNO_EXIMQUOTA;
       
    64          }
       
    65 -
       
    66      }
       
    67    else if (ob->quota_filecount_value > 0
       
    68             && mailbox_filecount + (ob->quota_is_inclusive ? 1:0) >
       
    69                ob->quota_filecount_value)
       
    70      {
       
    71 -        DEBUG(D_transport) if (ob->quota_filecount_no_check)
       
    72 -                debug_printf("mailbox file count quota exceeded but ignored\n");
       
    73 -
       
    74 -        if(!ob->quota_filecount_no_check) 
       
    75 -          {
       
    76 -            DEBUG(D_transport) debug_printf("mailbox file count quota exceeded\n");
       
    77 -            yield = DEFER;
       
    78 -            errno = ERRNO_EXIMQUOTA;
       
    79 -            filecount_msg = US" filecount";
       
    80 -          }
       
    81 +      overquota = 1;
       
    82 +      if (ob->quota_no_check)
       
    83 +        {
       
    84 +          DEBUG(D_transport) if (ob->quota_filecount_no_check)
       
    85 +              debug_printf("mailbox file count quota exceeded (but ignored)\n");
       
    86 +
       
    87 +        }
       
    88 +      else
       
    89 +        {
       
    90 +          DEBUG(D_transport) debug_printf("mailbox file count quota exceeded\n");
       
    91 +          yield = DEFER;
       
    92 +          errno = ERRNO_EXIMQUOTA;
       
    93 +          filecount_msg = US" filecount";
       
    94 +        }
       
    95 +    }
       
    96 +
       
    97 +  /* now we'll take care about the overquota file, using it as a timestamp
       
    98 +   * to record this overquota event */
       
    99 +  if (ob->maildir_overquota_file)
       
   100 +    {
       
   101 +    uschar *overquota_file = string_sprintf("%s/%s", path, ob->maildir_overquota_file);
       
   102 +    if (overquota) 
       
   103 +      {
       
   104 +        int _errno = errno;
       
   105 +        errno = 0;
       
   106 +        (void) open(overquota_file, O_CREAT|O_EXCL|O_RDWR, 0444);
       
   107 +        DEBUG(D_transport) debug_printf("attempt to create `%s': %s\n", 
       
   108 +          overquota_file, strerror(errno));
       
   109 +        errno = _errno;
       
   110 +      }
       
   111 +    else
       
   112 +      {
       
   113 +        int _errno = errno;
       
   114 +        errno = 0;
       
   115 +        (void) unlink(overquota_file);
       
   116 +        DEBUG(D_transport) debug_printf("attempt to remove `%s': %s\n", 
       
   117 +          overquota_file, strerror(errno));
       
   118 +        errno = _errno;
       
   119 +      }
       
   120      }
       
   121    }
       
   122  
       
   123 diff -r 70d48c9a5cfe src/transports/appendfile.h
       
   124 --- a/src/transports/appendfile.h	Fri Apr 01 16:36:30 2011 +0200
       
   125 +++ b/src/transports/appendfile.h	Thu Apr 07 15:27:46 2011 +0200
    27 @@ -24,6 +24,7 @@
   126 @@ -24,6 +24,7 @@
    28    uschar *mailbox_size_string;
   127    uschar *mailbox_size_string;
    29    uschar *mailbox_filecount_string;
   128    uschar *mailbox_filecount_string;
    30    uschar *expand_maildir_use_size_file;
   129    uschar *expand_maildir_use_size_file;
    31 +  uschar *maildir_overquota_file;
   130 +  uschar *maildir_overquota_file;