Merge pull request #890 from YunoHost/unique-stuff-for-group-permission-update

[fix] Make sure the group permission update contains unique elements
This commit is contained in:
Kayou 2020-03-15 23:27:59 +01:00 committed by GitHub
commit 0711b5a22a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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 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: try:
ldap.update('cn=%s,ou=permission' % permission, ldap.update('cn=%s,ou=permission' % permission,
{'groupPermission': ['cn=' + g + ',ou=groups,dc=yunohost,dc=org' for g in allowed]}) {'groupPermission': ['cn=' + g + ',ou=groups,dc=yunohost,dc=org' for g in allowed]})