Re: [exim] quota check at smtp_data time

Página Principal
Apagar esta mensagem
Responder a esta mensagem
Autor: Jeremy Harris
Data:  
Para: exim-users @ exim. org
Assunto: Re: [exim] quota check at smtp_data time
kig@??? wrote:
> 1. Is there a way to check quota on mailbox at smtp_data time.
>    Checks: is account over quota (which can be MTA-imposed) and whether 
> it will be over when writing message.


Yes, but it's quite involved.

Here's the core of a checker;
call it as a sub-acl from both your rcpt-time and data-time acls.
It assumes maildir format and use_message_size_file, and requires that
your acls can discover the deliver directory.

rcpt_chk_quota:
   # OK if no local deliveries
   require       set acl_c7 =    1000M
                 set acl_c5 =    0
   accept        condition =     ${if !match {$acl_c9}{/(,|\$)}}


   # Get the deliver directory
   require       set acl_c8 =    ${sg {$acl_c9} \
            {([^/],)*(.*/(,|\$))} {\$2}}
   require       set acl_c8 =    ${sg {$acl_c8} \
            {(.*/Maildir/).*\$} {\$1}}
   # If it doesn't exist either it's never been created or
   # we're on a 2MX.  Check the DB for an over-quota flag.
   accept        condition =     ${if !exists{$acl_c8}}
                 acl =           quota_db_flag
   # Get the path to the maildirsize file; if it's not present
   # then either it's
   # never been created, or it's been temporarily deleted.
   accept        condition =     ${if !exists{${acl_c8}maildirsize}}
                 acl =           quota_longform
   # read the size file
   require       set acl_c8 =    ${readfile{${acl_c8}maildirsize}{!}}
   # empty first line means infinite quota
   accept        condition =     ${if match {$acl_c8}{^\\s*(!.*)?\$}}
                 set acl_c7 =    0
   # quota: first line, first number
   require       set acl_c7 =    ${sg {$acl_c8} \
            {^(\\s*)(\\d+).*\$} {\$2}}
   # zero means infinite quota
   accept        condition =     ${if = {$acl_c7}{0}}
   # drop the first line
   warn          set acl_c8 =    ${sg {$acl_c8}{^[^!]*!(.*)\$} {\$1}}
   # convert 2nd number & linebreak into addition, on each line
                 set acl_c8 =    ${sg {$acl_c8}{\\s*(-?\\d+)[^!]*!?} \
            {\$1 +}}
   # evaluate the sum (and leave around for the data-time check)
                 set acl_c5 =    ${eval:$acl_c8 +0}
   # add this message (10k default if no SIZE=)
                 set acl_c8 =    ${eval:$acl_c5 + <
                    ${if < {$message_size}{0} \
                                         {10K} {$message_size}}}
   # ok if within quota
   accept        condition =     ${if <= {$acl_c8}{$acl_c7}}
   defer         message =       quota exceeded