Bug 57398 - Unable to modify the country via self-service if user lacks object class "univentionPerson"
Summary: Unable to modify the country via self-service if user lacks object class "uni...
Status: REOPENED
Alias: None
Product: UCS
Classification: Unclassified
Component: Self Service
Version: UCS 5.0
Hardware: Other Linux
: P5 normal
Target Milestone: ---
Assignee: UMC maintainers
QA Contact: UMC maintainers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-21 11:31 CEST by Finn David
Modified: 2025-04-02 12:22 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 3: Simply Wrong: The implementation doesn't match the docu
Who will be affected by this bug?: 3: Will affect average number of installed domains
How will those affected feel about the bug?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.103
Enterprise Customer affected?: Yes
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2024061921000192
Bug group (optional): bitesize, Workaround is available
Customer ID:
Max CVSS v3 score:


Attachments
Traceback (3.48 KB, text/x-log)
2024-06-21 11:31 CEST, Finn David
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Finn David univentionstaff 2024-06-21 11:31:08 CEST
Created attachment 11221 [details]
Traceback

# UCS: 5.0-8 errata1060
# /usr/share/univention-directory-manager-tools/udm-remap-country-from-st-to-c was executed via the UMC during a system diagnosis


# Problem
When a user tries to change the country via the self-service a traceback appears in /var/log/univention/management-console-module-passwordreset.log (see attachment).

# Investigation
The country was unset and the user tried to modify/add it via the self-service. When the country is set to a value beforehand by an administrator (udm users/user modify --dn ... --set country=DE), then the user is able to change the value via the self-service.
Comment 1 Florian Best univentionstaff 2025-03-21 14:37:55 CET
Workaround should be:
ucr set self-service/ldap_attributes="c,$(ucr get self-service/ldap_attributes)"
Comment 2 Florian Best univentionstaff 2025-04-02 12:13:35 CEST
For searchability:

MODULE      ( ERROR   ) : set_user_attributes(): modifying the user failed: Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/univention/admin/uldap.py", line 792, in modify
    return self.lo.modify(dn, changes, serverctrls=serverctrls, response=response, rename_callback=rename_callback)
  File "/usr/lib/python3/dist-packages/univention/uldap.py", line 220, in _decorated
    return func(self, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/univention/uldap.py", line 816, in modify
    self.modify_ext_s(dn, ml, serverctrls=serverctrls, response=response)
  File "/usr/lib/python3/dist-packages/univention/uldap.py", line 220, in _decorated
    return func(self, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/univention/uldap.py", line 875, in modify_ext_s
    _rtype, _rdata, _rmsgid, resp_ctrls = self.lo.modify_ext_s(dn, ml, serverctrls=serverctrls)
  File "/usr/lib/python3/dist-packages/ldap/ldapobject.py", line 1253, in modify_ext_s
    return self._apply_method_s(SimpleLDAPObject.modify_ext_s,*args,**kwargs)
  File "/usr/lib/python3/dist-packages/ldap/ldapobject.py", line 1197, in _apply_method_s
    return func(self,*args,**kwargs)
  File "/usr/lib/python3/dist-packages/ldap/ldapobject.py", line 602, in modify_ext_s
    resp_type, resp_data, resp_msgid, resp_ctrls = self.result3(msgid,all=1,timeout=self.timeout)
  File "/usr/lib/python3/dist-packages/ldap/ldapobject.py", line 749, in result3
    resp_ctrl_classes=resp_ctrl_classes
  File "/usr/lib/python3/dist-packages/ldap/ldapobject.py", line 756, in result4
    ldap_result = self._ldap_call(self._l.result4,msgid,all,timeout,add_ctrls,add_intermediates,add_extop)
  File "/usr/lib/python3/dist-packages/ldap/ldapobject.py", line 329, in _ldap_call
    reraise(exc_type, exc_value, exc_traceback)
  File "/usr/lib/python3/dist-packages/ldap/compat.py", line 44, in reraise
    raise exc_value
  File "/usr/lib/python3/dist-packages/ldap/ldapobject.py", line 313, in _ldap_call
    result = func(*args,**kwargs)
ldap.INSUFFICIENT_ACCESS: {'desc': 'Insufficient access'}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/univention/management/console/modules/passwordreset/__init__.py", line 581, in set_user_attributes
    user.modify()
  File "/usr/lib/python3/dist-packages/univention/admin/handlers/users/user.py", line 1288, in modify
    return super(object, self).modify(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/univention/admin/handlers/__init__.py", line 692, in modify
    dn = self._modify(modify_childs, ignore_license=ignore_license, response=response, serverctrls=serverctrls)
  File "/usr/lib/python3/dist-packages/univention/admin/handlers/__init__.py", line 1412, in _modify
    self.dn = self.lo.modify(self.dn, ml, ignore_license=ignore_license, serverctrls=serverctrls, response=response, rename_callback=wouldRename.on_rename)
  File "/usr/lib/python3/dist-packages/univention/admin/uldap.py", line 798, in modify
    raise univention.admin.uexceptions.permissionDenied()
univention.admin.uexceptions.permissionDenied: Zugriff verweigert.
Comment 3 Florian Best univentionstaff 2025-04-02 12:22:23 CEST
This is not about allowing to change the attribute "c" by self.

The problem are users, which don't have the objectClass "univentionPerson".
When setting a value for "c" UDM adds the objectClass "univentionPerson" to the modlist (as LDAP add operation):
> users/user.py:            ml.append(('objectClass', b'', b'univentionPerson')

And our LDAP ACLs allow to do this:
> management/univention-ldap/conffiles/etc/ldap/slapd.conf.d/63univention-ldap-server_acl-master-password:print('access to filter="objectClass=person" attrs=objectClass value=univentionPerson')
> management/univention-ldap/conffiles/etc/ldap/slapd.conf.d/63univention-ldap-server_acl-master-password-print('   by self %s' % usr)

But UDM transforms that ldap ADD operation to an LDAP replace operation:
> 1325     def _ldap_object_classes_add(self, al: list[tuple[str, Any]]) -> list[tuple[str, Any]]:
…
1354             al.append(('objectClass', [x.encode('UTF-8') for x in ocs]))

Which is then denied by the LDAP server - even if it only contains the allowed object class and the currently set object classes.

So we have to rewrite this, that it still performs only an LDAP add operation.

Workaround: change all users and set any "c", or "birthdate" via CLI, which then sets the objectClass to the users.