1 (edited by vsolomatin 2015-10-09 23:21:02)

Topic: Additional services for mail user

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

iRedAdmin-Pro v2.3.1 (LDAP)

1. Create a new user in iRedAdmin-Pro.
2. Go to the profile new user, to "Advanced" properties
3. Check "jira" service in "Enabled Services"
4. Create a second user and I receive an error:

Error: {'info': 'enabledService: value #33 provided more than once', 'desc': 'Type or value exists'}

5. Logs and setings

/var/www/iRedAdmin-Pro-LDAP-2.3.1/settings.py

ADDITIONAL_ENABLED_USER_SERVICES = ['gitlab','redmine']
ADDITIONAL_DISABLED_USER_SERVICES = ['jira','vpn']


/var/log/nginx/access.log
192.168.0.37 - - [09/Oct/2015:17:02:47 +0300] "POST /iredadmin/create/user HTTP/1.1" 303 5 "https://mx.example.org/iredadmin/create … xample.org" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:41.0) Gecko/20100101 Firefox/41.0"
192.168.0.37 - - [09/Oct/2015:17:02:49 +0300] "GET /iredadmin/create/user/example.org?msg=%7B%27info%27%3A%20%27enabledService%3A%20value%20%2333%20provided%20more%20than%20once%27%2C%20%27desc%27%3A%20%27Type%20or%20value%20exists%27%7D HTTP/1.1" 200 17277 "https://mx.example.org/iredadmin/create … xample.org" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:41.0) Gecko/20100101 Firefox/41.0"

6. After restarting uwsgi service everything works fine.

Post's attachments

iredadminpro.png
iredadminpro.png 84.04 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

----

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

2

Re: Additional services for mail user

I will try to reproduce this issue later and come back with a fix. sorry about this trouble.

3

Re: Additional services for mail user

Dear vsolomatin,

Please try below patch, it works for me. please do let me know whether or not it works for you.

diff -r f2a1e8a7972f libs/ldaplib/iredldif.py
--- a/libs/ldaplib/iredldif.py    Fri Oct 09 09:22:39 2015 +0800
+++ b/libs/ldaplib/iredldif.py    Sun Oct 11 01:25:18 2015 +0800
@@ -157,6 +157,7 @@
         passwd = [str(passwd)]
 
     enabled_services = attrs.USER_SERVICES_OF_NORMAL_USER + settings.ADDITIONAL_ENABLED_USER_SERVICES
+    enabled_services = list(set(enabled_services))
 
     # Generate basic LDIF.
     ldif = [('objectClass', ['inetOrgPerson', 'mailUser', 'shadowAccount', 'amavisAccount']),

4

Re: Additional services for mail user

This patch fixed it, thanks! But for the next added users  all additional services is enabled.

/var/www/iRedAdmin-Pro-LDAP-2.3.1/settings.py

ADDITIONAL_ENABLED_USER_SERVICES = ['gitlab','redmine']
ADDITIONAL_DISABLED_USER_SERVICES = ['jira','vpn']
Post's attachments

iredmail-services.png
iredmail-services.png 48.57 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

5

Re: Additional services for mail user

That's weird. I will check again and come back to you with a fix. Thanks for the feedback.

6

Re: Additional services for mail user

Fixed, eventually. Please reverse previous patch (or simply remove the new line added by previous patch), then apply this one:

diff -Naur libs/ldaplib/attrs.py iRedAdmin-Pro-LDAP-2.3.1-new/libs/ldaplib/attrs.py
--- a/libs/ldaplib/attrs.py    2015-06-03 01:09:16.000000000 -0600
+++ b/libs/ldaplib/attrs.py    2015-10-12 09:39:13.340887138 -0600
@@ -94,7 +94,7 @@
 USER_ATTR_PASSWORD = 'userPassword'
 
 # Services for normal user
-USER_SERVICES_OF_NORMAL_USER = [
+USER_SERVICES_OF_NORMAL_USER = (
     'internal', 'doveadm', 'lib-storage', 'indexer-worker', 'mail', 'dsync',
     'smtp', 'smtpsecured',
     'pop3', 'pop3secured',
@@ -104,7 +104,7 @@
     'managesieve', 'managesievesecured', 'sieve', 'sievesecured',
     'forward', 'shadowaddress',
     'displayedInGlobalAddressBook',
-]
+)
 
 # All attributes needed in user list page.
 USER_SEARCH_ATTRS = [
diff -Naur libs/ldaplib/iredldif.py iRedAdmin-Pro-LDAP-2.3.1-new/libs/ldaplib/iredldif.py
--- a/libs/ldaplib/iredldif.py    2015-06-03 01:09:17.000000000 -0600
+++ b/libs/ldaplib/iredldif.py    2015-10-12 09:39:13.340887138 -0600
@@ -156,7 +156,7 @@
     if not isinstance(passwd, list):
         passwd = [str(passwd)]
 
-    enabled_services = attrs.USER_SERVICES_OF_NORMAL_USER + settings.ADDITIONAL_ENABLED_USER_SERVICES
+    enabled_services = list(attrs.USER_SERVICES_OF_NORMAL_USER) + settings.ADDITIONAL_ENABLED_USER_SERVICES
 
     # Generate basic LDIF.
     ldif = [('objectClass', ['inetOrgPerson', 'mailUser', 'shadowAccount', 'amavisAccount']),
diff -Naur iRedAdmin-Pro-LDAP-2.3.1/libs/ldaplib/user.py iRedAdmin-Pro-LDAP-2.3.1-new/libs/ldaplib/user.py
--- a/libs/ldaplib/user.py    2015-06-03 01:09:17.000000000 -0600
+++ b/libs/ldaplib/user.py    2015-10-12 09:39:13.340887138 -0600
@@ -1248,7 +1248,7 @@
             mod_attrs += [(ldap.MOD_REPLACE, 'userRecipientBccAddress', self.userRecipientBccAddress)]
 
             # Enabled services.
-            all_services = attrs.USER_SERVICES_OF_NORMAL_USER
+            all_services = list(attrs.USER_SERVICES_OF_NORMAL_USER)
             all_services += settings.ADDITIONAL_ENABLED_USER_SERVICES
             all_services += settings.ADDITIONAL_DISABLED_USER_SERVICES
             self.enabledService = [str(v)

7

Re: Additional services for mail user

FYI, if you're interested why it happens: this is a common but "hard to find" programming error by developer, for example:

$ python
>>> L = [1, 2, 3]
>>> L
[1, 2, 3]

>>> NL = L                           # <- this improper variable assignment causes this iRedAdmin-Pro issue.
>>> NL
[1, 2, 3]
>>> NL += [4, 5, 6]
>>> NL
[1, 2, 3, 4, 5, 6]
>>> L
[1, 2, 3, 4, 5, 6]

"NL = L" line is not proper, because if you update NL, both NL and L will be updated. This improper variable assignment causes this iRedAdmin-Pro issue.

I changed all variables (which are Python list) defined in libs/ldaplib/attrs.py to 'tuple' (immutable after defined) type to prevent similar issue. Although we can use "NL = L[:]" for the same purpose, but a immutable variable (tuple) is better.

8

Re: Additional services for mail user

Thank you, now all works fine!