1 (edited by tanikawa 2016-05-13 22:24:15)

Topic: Max quota of mail user seems not work.

I have few issues about "Max quota of mail user" setting of iRedAdmin-Pro.

Global admin added domain (e.g. domain.tld) it has 20MB "Domain quota size", and set the "Max quota of mail user" to 5MB.

Next, global admin added the domain admin "user1@domain.tld", and set the "Mailbox Quota" to 5MB.

Issue1: Domain admin(user1@domain.tld) added "user2@domain.tld", but it seems to be "Max quota of mail user" not work. Because of it is possible to set "Mailbox Quota" of user2@domain.tld to 15MB. Of course, it is not possible to set value over the "Domain quota size".

Issue2: Domain admin can modify the "Mailbox Quota" to 0MB of user2@domain.tld, so it seems to be possible user2@domain.tld can receive mail without limit of mail quota size.

I want to set iRedAdmin like below.
1. Domain admin can not set "Max quota" of mail user more than 5MB.
2. Domain admin can not modify "Mailbox Quota" to 0MB.

Is it possible? Thanks in advance.

==== Required information ====
- iRedMail version (check /etc/iredmail-release):  v2.6.0 (LDAP)
- Linux/BSD distribution name and version: Ubuntu 14
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): LDAP
- Web server (Apache or Nginx):Apache
- Manage mail accounts with iRedAdmin-Pro?
- Related log if you're reporting an issue:
====

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Max quota of mail user seems not work.

Dear tanikawa,

It's a bug in the latest iRedAdmin-Pro-LDAP, here's patch for iRedAdmin-Pro-LDAP-2.6.0:

--- a/libs/ldaplib/user.py    2016-05-13 06:51:44.726760372 -0600
+++ b/libs/ldaplib/user.py    2016-05-13 06:52:19.726296775 -0600
@@ -264,6 +264,12 @@
         else:
             self.mailQuota = defaultUserQuota
 
+        # Get max mailbox quota
+        max_quota = int(domainAccountSetting.get('maxUserQuota', 0))
+        if max_quota:
+            if self.mailQuota >= max_quota:
+                self.mailQuota = max_quota
+
         # 0 means unlimited.
         domainQuotaSize, domainQuotaUnit = domainAccountSetting.get('domainQuota', '0:GB').split(':')
         if int(domainQuotaSize) == 0:

3 (edited by tanikawa 2016-05-13 22:23:56)

Re: Max quota of mail user seems not work.

Many thanks!

But, isn't it better to write like below?

- if self.mailQuota >= max_quota:
+ if self.mailQuota >= max_quota or self.mailQuota == 0:

And I think it is also needed to add same code at line 900 (part of def update).

4

Re: Max quota of mail user seems not work.

tanikawa wrote:

And I think it is also needed to add same code at line 900 (part of def update).

Indeed.

Please apply above patch first, then apply this one:

--- a/libs/ldaplib/user.py    2016-05-13 09:27:13.424220461 -0600
+++ b/libs/ldaplib/user.py    2016-05-13 09:28:40.043101392 -0600
@@ -893,10 +893,15 @@
                 # Don't touch it, keep original value.
                 pass
             else:
-                #mod_attrs += [( ldap.MOD_REPLACE, 'mailQuota', str(int(mailQuota) * 1024 * 1024) )]
                 # Assign quota which got from web form.
                 mailQuota = int(quota)
 
+                # Get per-domain max mailbox quota
+                max_quota = int(domainAccountSetting.get('maxUserQuota', 0))
+                if max_quota:
+                    if mailQuota >= max_quota:
+                        mailQuota = max_quota
+
                 # If mailQuota > domainSpareQuotaSize, use domainSpareQuotaSize.
                 # if mailQuota < domainSpareQuotaSize, use mailQuota
                 # 0 means unlimited.