Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Quota for LDAP account is working #2957

Open
Marsu31 opened this issue Dec 25, 2022 · 5 comments
Open

[FR] Quota for LDAP account is working #2957

Marsu31 opened this issue Dec 25, 2022 · 5 comments
Labels
area/features area/scripts kind/improvement Improve an existing feature, configuration file or the documentation kind/new feature A new feature is requested in this issue or implemeted with this PR priority/low service/dovecot service/ldap stale-bot/ignore Indicates that this issue / PR shall not be closed by our stale-checking CI

Comments

@Marsu31
Copy link
Contributor

Marsu31 commented Dec 25, 2022

Feature Request

Context

Quota with LDAP configuration.

Is your Feature Request related to a Problem?

Yes. Quota is disabled if LDAP.

Describe the Solution you'd like

Permit quota if LDAP.

Are you going to implement it?

No but ...

What are you going to contribute?? What have you done already?

I tried to configure quota with LDAP and it works :

  1. activate quota like in account provisioner of type file (default behaviour). This is done inside running container.
  2. configure quota in LDAP. I'm using postfix-book schema within OenLDAP.
    1. create a user with object class PostfixBookMailAccount (for mail attributes)
    2. fill mailQuota attribute, for example 100M.
  3. add the following attribute to DOVECOT_USER_ATTRS : =quota_rule=*:storage=%{ldap:mailQuota}

I tested this configuration sending mail mails which are bigger than quota, they were rejected. Thunderbird detects too the mail box quota.

What you have to do, almost nothing 😉 :

  1. Allow quota for LDAP account provisioner
  2. Add few lines to documentation with my sample.

Regards.

@Marsu31 Marsu31 added meta/needs triage This issue / PR needs checks and verification from maintainers priority/low labels Dec 25, 2022
@Marsu31
Copy link
Contributor Author

Marsu31 commented Dec 25, 2022

Waiting for your work, this is the user patches which activates quotas. Big copy/paste from setup-stack.sh.

echo 'user-patches.sh starting...'

source /usr/local/bin/helpers/index.sh

_log 'debug' 'Setting up Dovecot quota'

if [[ -f /etc/dovecot/conf.d/90-quota.conf.disab ]]
then
  mv /etc/dovecot/conf.d/90-quota.conf.disab /etc/dovecot/conf.d/90-quota.conf
  sed -i \
    "s|mail_plugins = \$mail_plugins|mail_plugins = \$mail_plugins quota|g" \
    /etc/dovecot/conf.d/10-mail.conf
  sed -i \
    "s|mail_plugins = \$mail_plugins|mail_plugins = \$mail_plugins imap_quota|g" \
    /etc/dovecot/conf.d/20-imap.conf
fi

MESSAGE_SIZE_LIMIT_MB=$((POSTFIX_MESSAGE_SIZE_LIMIT / 1000000))
MAILBOX_LIMIT_MB=$((POSTFIX_MAILBOX_SIZE_LIMIT / 1000000))

sed -i \
  "s|quota_max_mail_size =.*|quota_max_mail_size = ${MESSAGE_SIZE_LIMIT_MB}$([[ ${MESSAGE_SIZE_LIMIT_MB} -eq 0 ]] && echo "" || echo "M")|g" \
  /etc/dovecot/conf.d/90-quota.conf

sed -i \
  "s|quota_rule = \*:storage=.*|quota_rule = *:storage=${MAILBOX_LIMIT_MB}$([[ ${MAILBOX_LIMIT_MB} -eq 0 ]] && echo "" || echo "M")|g" \
  /etc/dovecot/conf.d/90-quota.conf

if [[ -d /tmp/docker-mailserver ]] && [[ ! -f /tmp/docker-mailserver/dovecot-quotas.cf ]]
then
  _log 'trace' "'/tmp/docker-mailserver/dovecot-quotas.cf' is not provided. Using default quotas."
  : >/tmp/docker-mailserver/dovecot-quotas.cf
fi

# enable quota policy check in postfix
sed -i \
  "s|reject_unknown_recipient_domain, reject_rbl_client zen.spamhaus.org|reject_unknown_recipient_domain, check_policy_service inet:localhost:65265, reject_rbl_client zen.spamhaus.org|g" \
  /etc/postfix/main.cf

echo 'user-patches.sh successfully executed'

@polarathene polarathene added kind/new feature A new feature is requested in this issue or implemeted with this PR service/dovecot area/scripts service/ldap area/features kind/improvement Improve an existing feature, configuration file or the documentation stale-bot/ignore Indicates that this issue / PR shall not be closed by our stale-checking CI and removed meta/needs triage This issue / PR needs checks and verification from maintainers labels Dec 25, 2022
@casperklein
Copy link
Member

Non of the current maintainers is using a LDAP setup. So the chances that someone will pick it up is pretty low.

Unless you want to implement this feature yourself, the best solution for now is probably to document it. Feel free to do so, any support is highly appreciated.

@williamdes
Copy link
Contributor

williamdes commented Jul 11, 2023

I might be interested to look into this one as I have an LDAP setup running in production

@williamdes
Copy link
Contributor

Hi @Marsu31
Reading your patch, the line after # enable quota policy check in postfix seems not to have any use for quota, right ?

@reneploetz
Copy link
Contributor

reneploetz commented Jul 19, 2023

It does insofar as enabling the policy service of dovecot (see https://github.com/docker-mailserver/docker-mailserver/blob/master/target/dovecot/90-quota.conf#L46) to be used so that postfix does enforce the quota too.
I'm currently using a modified patch in my system with that line changed as it is currently: https://github.com/docker-mailserver/docker-mailserver/blob/master/target/scripts/startup/setup.d/dovecot.sh#L130

Note that I think that removing the check for [ ${ACCOUNT_PROVISIONER} != 'FILE' ] in line 88 of dovecot.sh is already enough for the whole feature to work: https://github.com/docker-mailserver/docker-mailserver/blob/master/target/scripts/startup/setup.d/dovecot.sh#L88
For safety we might want to move the ACCOUNT_PROVISIONER check to line 124 as the dovecot-quotas.cf is not applicable to LDAP setups: https://github.com/docker-mailserver/docker-mailserver/blob/master/target/scripts/startup/setup.d/dovecot.sh#L124

I also thought about providing a pull request for this but never had time to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/features area/scripts kind/improvement Improve an existing feature, configuration file or the documentation kind/new feature A new feature is requested in this issue or implemeted with this PR priority/low service/dovecot service/ldap stale-bot/ignore Indicates that this issue / PR shall not be closed by our stale-checking CI
Projects
None yet
Development

No branches or pull requests

5 participants