Problem getting quota-warning script to function.

Ted ted at easydns.com
Wed Sep 19 00:19:53 EEST 2018


Hello,

I'm trying to implement quota enforcement in our mailservers, and it is
all working properly except that the quota warnings are not firing when
the quota levels are passed.  the server stops accepting email when the
quota is reached, and you can see tyhe quota usage through the email
client connected through, but as the quota passes the set levels the
/usr/local/bin/quota-warning.sh script is not called.  I checked from
the appropriate user and the script executes from the command line with
no problem, but dovecot does not invoke it when the quota levels are
crossed.  The relevant configs are below, any ideas about what the
problem may be or how I should approach this?

/etc/dovecot/dovecot.conf

## Dovecot configuration file


# Protocols we want to be serving.
protocols = imap pop3 lmtp sieve

mailbox_list_index = yes
# Avoid spending excessive time waiting for the quota calculation to
finish when
# mails' vsizes aren't already cached. If this many mails are opened,
finish the
# quota calculation on background in indexer-worker process. Mail
deliveries will
# be assumed to succeed, and explicit quota lookups will return internal
error.
# (v2.2.28+)
# mail_vsize_bg_after_count = 100

plugin {
    quota_grace = 10%%
    # 10% is the default
#    quota_status_success = DUNNO
#    quota_status_nouser = DUNNO
    quota_status_overquota = "552 5.2.2 Mailbox is full"
    quota_vsizes = yes
}

service quota-status {
    executable = quota-status -p postfix
    inet_listener {
        port = 10070
        # You can choose any port you want
    }
    client_limit = 1
}

mail_plugins = $mail_plugins quota mail_log notify

protocol imap {
  # Space separated list of plugins to load (default is global
mail_plugins).
  mail_plugins = $mail_plugins imap_quota
}


# Greeting message for clients.
login_greeting = Welcome to easyMail.


# Show more verbose process titles (in ps). Currently shows user name and
# IP address. Useful for seeing who are actually using the IMAP processes
# (eg. shared mailboxes or if same uid is used for multiple accounts).
verbose_proctitle = yes

# Should all processes be killed when Dovecot master process shuts down.
# Setting this to "no" means that Dovecot can be upgraded without
# forcing existing client connections to close (although that could also be
# a problem if the upgrade is e.g. because of a security fix).
shutdown_clients = yes

# A config file can also tried to be included without giving an error if
# it's not found:
!include_try local.conf

service auth {
  unix_listener auth-master {
    mode = 0600
    user = vmail
  }
}


/etc/dovecot/dovecot-sql.conf.ext

# Database driver: mysql, pgsql, sqlite
driver = mysql

connect = host=redacted dbname=redacted user=redacted
password=reallyredacted

# Default password scheme.
#
# List of supported schemes is in
# http://wiki2.dovecot.org/Authentication/PasswordSchemes
#
default_pass_scheme = CRYPT

password_query = select email as user, crypt_password as password,
CONCAT('/',volume,'/',SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1))
AS home, 5000 AS uid, 5000 AS gid, concat('*:storage=', volume_limit
,'G') AS quota_rule from easymail_users where email = '%u' and banned =
'0' and active = '1'

user_query = SELECT
CONCAT('maildir:/',volume,'/',SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/Maildir')
AS mail,
CONCAT('/',volume,'/',SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1))
AS home, 5000 AS uid, 5000 AS gid, concat('*:storage=', volume_limit
,'G') AS quota_rule from easymail_users where email = '%u' and banned =
'0' and active = '1'


/etc/dovecot/conf.d/90-quota.conf

##
## Quota configuration.
##

##
## Quota warnings
##

# You can execute a given command when user exceeds a specified quota limit.
# Each quota root has separate limits. Only the command for the first
# exceeded limit is excecuted, so put the highest limit first.
# The commands are executed via script service by connecting to the named
# UNIX socket (quota-warning below).
# Note that % needs to be escaped as %%, otherwise "% " expands to empty.

plugin {
  quota_warning = storage=95%% quota-warning 95 %u
  quota_warning2 = storage=90%% quota-warning 90 %u
  quota_warning3 = storage=80%% quota-warning 80 %u
}

# Example quota-warning service. The unix listener's permissions should be
# set in a way that mail processes can connect to it. Below example assumes
# that mail processes run as vmail user. If you use mode=0666, all
system users
# can generate quota warnings to anyone.
service quota-warning {
  executable = script /usr/local/bin/quota-warning.sh
  user = dovecot
  unix_listener quota-warning {
    user = dovecot
    mode = 0666
  }
}

##
## Quota backends
##

# Multiple backends are supported:
#   dirsize: Find and sum all the files found from mail directory.
#            Extremely SLOW with Maildir. It'll eat your CPU and disk I/O.
#   dict: Keep quota stored in dictionary (eg. SQL)
#   maildir: Maildir++ quota
#   fs: Read-only support for filesystem quota

plugin {
  #quota = dirsize:User quota
  #quota = maildir:User quota
  #quota = dict:User quota::proxy::quota
  quota = count:User quota
  #quota = fs:User quota
}


/usr/local/bin/quota-warning.sh

#!/bin/sh
# warning email for approaching their quota

usage=$1
email=$2

/usr/bin/mailx -r "support at easydns.com" -s "Quota Usager Notification" 
"${email:?}"  < /home/vmail/quota"${usage:?}".txt

echo "$(date)  ${usage} : ${email}" >> /var/log/quotatest.log

Thank you
Ted
easyDNS Technologies


More information about the dovecot mailing list