1

Topic: sync_profiles_to_db throws TypeError if Mailinglist has no owner

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 1.4.1
- Deployed with iRedMail Easy or the downloadable installer?: downloadable installer
- Linux/BSD distribution name and version: Ubuntu 20.04.3
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): LDAP
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? Yes
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Hello,

I tried to update mlmmjadmin from version 3.1 to 3.1.2 and got the following error message on one of the last steps:

* mlmmjadmin has been successfully upgraded.
* Restarting service: mlmmjadmin.
* Sync mailing list profiles to SQL/LDAP.
Traceback (most recent call last):
 File "tools/sync_profiles_to_db.py", line 251, in <module>
   qr = sync_owners(mail, owners)
 File "tools/sync_profiles_to_db.py", line 232, in sync_owners
   return __sync_addresses(mail=mail,
 File "tools/sync_profiles_to_db.py", line 210, in __sync_addresses
   mod_attr = [(ldap.MOD_REPLACE, "listOwner", str2bytes(addresses))]
 File "/opt/mlmmjadmin-3.1.2/tools/../libs/utils.py", line 39, in str2bytes
   s = __str2bytes(s)
 File "/opt/mlmmjadmin-3.1.2/tools/../libs/utils.py", line 22, in __str2bytes
   return bytes(s)
TypeError: cannot convert 'NoneType' object to bytes
* Upgrading completed.

After some digging around I found the problem:

201     elif backend == "ldap":
202         _domain = mail.split("@", 1)[-1]
203         ldn = "mail={},ou=Groups,domainName={},{}".format(mail, _domain, settings.iredmail_ldap_basedn)
204 
205         print(f"_domain -> %{_domain}")
206         print(f"ldn -> %{ldn}")
207 
208         if not addresses:
209             # Remove attribute.
210             addresses = None
211 
212         if address_type == "owner":
213             print("owner")
214             print(f"addresses -> %{addresses}")
215             mod_attr = [(ldap.MOD_REPLACE, "listOwner", str2bytes(addresses))]
216             print(f"mod_attr -> %{mod_attr}")
217         elif address_type == "moderator":
218             print("moderator")
219             print(f"addresses -> %{addresses}")
220             mod_attr = [(ldap.MOD_REPLACE, "listModerator", str2bytes(addresses))]
221             print(f"mod_attr -> %{mod_attr}")
222 
223         try:
224             conn.modify_s(ldn, mod_attr)
225         except ldap.OBJECT_CLASS_VIOLATION:
226             print("<<< ERROR >>> Seems your OpenLDAP server doesn't support "
227                   "`listOwner` and `listModerator` attributes which were "
228                   "introduced in iRedMail-1.4.0, please follow iRedMail "
229                   "upgrade tutorial to update LDAP schema file "
230                   "`iredmail.schema` first: "
231                   "https://docs.iredmail.org/iredmail.releases.html")
232             sys.exit()
233         except Exception as e:
234             msg = "Error while updating {} of mailing list {}: {}".format(address_type, mail, repr(e))
235             return (False, msg)
236 
237     return (True, )

Output from the modified code:

_domain -> %customername.tld
ldn -> %mail=listname@customername.tld,ou=Groups,domainName=customername.tld,o=domains,dc=mx,dc=companyname,dc=tld
owner
addresses -> %None
Traceback (most recent call last):
  File "./sync_profiles_to_db.py", line 260, in <module>
    qr = sync_owners(mail, owners)
  File "./sync_profiles_to_db.py", line 241, in sync_owners
    return __sync_addresses(mail=mail,
  File "./sync_profiles_to_db.py", line 215, in __sync_addresses
    mod_attr = [(ldap.MOD_REPLACE, "listOwner", str2bytes(addresses))]
  File "/opt/mlmmjadmin-3.1.2/tools/../libs/utils.py", line 39, in str2bytes
    s = __str2bytes(s)
  File "/opt/mlmmjadmin-3.1.2/tools/../libs/utils.py", line 22, in __str2bytes
    return bytes(s)
TypeError: cannot convert 'NoneType' object to bytes

I checked the UI and it is true, that the list currently does not have an owner.

----

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

2 (edited by dmeiswinkel 2021-09-09 15:55:18)

Re: sync_profiles_to_db throws TypeError if Mailinglist has no owner

The problem seems to be, that some of our lists are missing the LDAP "listOwner" attribute.

I tried to add it manually but get the following error message:

Warning! According to the schema attribute listOwner is not allowed!

We have several lists that seem to be missing said attribute. This LDAP filter should find the affected lists:

(&(objectClass=mailList)(!(listOwner=*)))

The attribute got added in the Update from 1.3.2 to 1.4.0: https://docs.iredmail.org/upgrade.iredm … chema-file

The strange thing is that we are using the correct LDAP schema file and I don't know why we can't add the listOwner attribute.

Found the reason:

I've been using the Manager account to add the value after switching to the vmailadmin user I've been able to add the attribute.

Manually adding still did not work until we realized that the listOwner has to be an existing iRedMail user.