[fix] Make sure the group permission update contains unique elements

This commit is contained in:
Alexandre Aubin 2020-03-15 22:33:51 +01:00 committed by Kay0u
parent addc4979ee
commit 96be75e177
No known key found for this signature in database
GPG key ID: 7FF262C033518333

View file

@ -453,6 +453,9 @@ def _update_ldap_group_permission(permission, allowed, sync_perm=True):
allowed = [allowed] if not isinstance(allowed, list) else allowed
# Guarantee uniqueness of values in allowed, which would otherwise make ldap.update angry.
allowed = set(allowed)
try:
ldap.update('cn=%s,ou=permission' % permission,
{'groupPermission': ['cn=' + g + ',ou=groups,dc=yunohost,dc=org' for g in allowed]})