Bug 50053 - fix simpleLdap.__setitem__() side effects
Summary: fix simpleLdap.__setitem__() side effects
Status: RESOLVED WONTFIX
Alias: None
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
Version: UCS 4.4
Hardware: Other Linux
: P5 normal
Target Milestone: ---
Assignee: UMC maintainers
QA Contact: UMC maintainers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-25 18:51 CEST by Florian Best
Modified: 2024-06-27 12:10 CEST (History)
0 users

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Customer ID:
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2019-08-25 18:51:49 CEST
univention.admin.simeLdap.__setitem__() has some unwanted behavior:

1.
For properties which cannot be modified, it raises univention.admin.uexceptions.valueMayNotChange but even if the value is equal to the currently set value.
When fixing this, please note, that the comparision for equality needs to be done after syntax.parse() which may normalize the format!

>>> o['unlockTime'] = o['unlockTime']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 396, in __setitem__
    raise univention.admin.uexceptions.valueMayNotChange(_('key=%(key)s old=%(old)s new=%(new)s') % {'key': key, 'old': self[key], 'new': value})
univention.admin.uexceptions.valueMayNotChange: key=unlockTime old=None new=None

2. When setting a property to an equal value, it just doesn't replace it. This is evil for lists:

>>> obj['foo']
['bar']
>>> l = ['bar']
>>> obj['foo'] = l
>>> l.append('blub')
>>> obj['foo']
['bar']

3. If the property is required, setting a value to 0 or another false-ish value causes a univention.admin.uexceptions.valueRequired exception.

>>> o['username'] = 0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 399, in __setitem__
    raise univention.admin.uexceptions.valueRequired, _('The property %s is required') % self.descriptions[key].short_description
univention.admin.uexceptions.valueRequired: The property User name is required

4. When checking for equality of a multivalue property it compares None == [] (because self.info.get(key) is None and not []).
Setting lists works:
>>> obj['some_multivalue_property'] = []
Setting None doesn't:
>>> o['groups'] = None
>>> o.info['groups']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'groups'

This influences also the handling of self.__no_default.

(5. Unsetting a value by setting it to None is not supported by all syntax classes, and therefore sometimes raises TypeError or univention.admin.uexceptions.valueInvalidSyntax).

>>> o['roomNumber'] = None
Traceback (most recent call last):                                           
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 414, in __setitem__
    raise univention.admin.uexceptions.valueInvalidSyntax(key)               
univention.admin.uexceptions.valueInvalidSyntax: roomNumber
Comment 1 Jan-Luca Kiok univentionstaff 2024-06-27 12:10:21 CEST
This issue has been filed against UCS 4.4.

UCS 4.4 is out of general maintenance and components may have vastly changed in later releases. Thus, this issue is now being closed.

If this issue still occurs in newer versions, please use "Clone this bug" or reopen this issue. In this case please provide detailed information on how this issue is affecting you.