Bug 56603 - Adjust S4-Connector and AD-Connector to python3-ldap API change in PostReadControl
Summary: Adjust S4-Connector and AD-Connector to python3-ldap API change in PostReadCo...
Status: CLOSED FIXED
Alias: None
Product: UCS
Classification: Unclassified
Component: S4 Connector
Version: UCS 5.1
Hardware: Other Linux
: P5 normal
Target Milestone: UCS 5.0-5-errata
Assignee: Florian Best
QA Contact: Felix Botner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-15 11:05 CEST by Florian Best
Modified: 2024-12-17 11:43 CET (History)
1 user (show)

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 2023-09-15 11:05:31 CEST
python3-ldap > 4.0 (https://github.com/python-ldap/python-ldap/issues/399) changed the PostReadConrol to return bytes instead of str (as it doesn't know the encoding for attributes).

We need to adjust S4-Connector and AD-Connector for this API change:

diff --git services/univention-s4-connector/modules/univention/s4connector/__init__.py services/univention-s4-connector/modules/univention/s4connector/__init__.py                                                                            
index 1236edf63b..f349d7ce05 100644
--- services/univention-s4-connector/modules/univention/s4connector/__init__.py
+++ services/univention-s4-connector/modules/univention/s4connector/__init__.py
@@ -1193,8 +1193,8 @@ class ucs(object):
         if res:
             for c in response.get('ctrls', []):
                 if c.controlType == PostReadControl.controlType:
-                    entryUUID = c.entry['entryUUID'][0]
-                    entryCSN = c.entry['entryCSN'][0]
+                    entryUUID = c.entry['entryUUID'][0].decode('ASCII')
+                    entryCSN = c.entry['entryCSN'][0].decode('ASCII')
                     self._remember_entryCSN_commited_by_connector(entryUUID, entryCSN)
             res = True
         return res
@@ -1216,8 +1216,8 @@ class ucs(object):
         if res:
             for c in response.get('ctrls', []):
                 if c.controlType == PostReadControl.controlType:  # If the modify actually did something
-                    entryUUID = c.entry['entryUUID'][0]
-                    entryCSN = c.entry['entryCSN'][0]
+                    entryUUID = c.entry['entryUUID'][0].decode('ASCII')
+                    entryCSN = c.entry['entryCSN'][0].decode('ASCII')
                     self._remember_entryCSN_commited_by_connector(entryUUID, entryCSN)
             res = True
         return res
diff --git services/univention-s4-connector/modules/univention/s4connector/s4/ntsecurity_descriptor.py services/univention-s4-connector/modules/univention/s4connector/s4/ntsecurity_descriptor.py                                            
index 97fe6a710c..2a5cffdc0e 100644
--- services/univention-s4-connector/modules/univention/s4connector/s4/ntsecurity_descriptor.py
+++ services/univention-s4-connector/modules/univention/s4connector/s4/ntsecurity_descriptor.py
@@ -132,6 +132,6 @@ def ntsd_to_ucs(s4connector, key, s4_object):
         s4connector.lo.lo.modify(ucs_dn, ml, serverctrls=serverctrls, response=response)
         for c in response.get('ctrls', []):   # If the modify actually did something
             if c.controlType == PostReadControl.controlType:
-                entryUUID = c.entry['entryUUID'][0]
-                entryCSN = c.entry['entryCSN'][0]
+                entryUUID = c.entry['entryUUID'][0].decode('ASCII')
+                entryCSN = c.entry['entryCSN'][0].decode('ASCII')
                 s4connector._remember_entryCSN_commited_by_connector(entryUUID, entryCSN)
Comment 2 Florian Best univentionstaff 2023-10-05 13:45:41 CEST
univention-s4-connector.yaml
fc82de78e09d | fix(s4c): Adjust post-read-control to decode values

univention-s4-connector (14.0.15-4)
fc82de78e09d | fix(s4c): Adjust post-read-control to decode values

univention-ad-connector.yaml
b2bcf1eb8a2e | fix(adc): Adjust to fixed post-read-control in python-ldap 4.0

univention-ad-connector (14.0.16-3)
b2bcf1eb8a2e | fix(adc): Adjust to fixed post-read-control in python-ldap 4.0
Comment 3 Florian Best univentionstaff 2023-10-05 13:47:19 CEST
Example traceback caused by this:

    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/univention/s4connector/__init__.py", line 1486, in sync_to_ucs
        post_ucs_modify_function(self, property_type, object)
      File "/usr/lib/python3/dist-packages/univention/s4connector/s4/ntsecurity_descriptor.py", line 137, in ntsd_to_ucs
        s4connector._remember_entryCSN_commited_by_connector(entryUUID, entryCSN)
      File "/usr/lib/python3/dist-packages/univention/s4connector/__init__.py", line 621, in _remember_entryCSN_commited_by_connector
        entryCSN_set = set(value.split(','))
                           ^^^^^^^^^^^^^^^^
    TypeError: a bytes-like object is required, not 'str'
Comment 4 Felix Botner univentionstaff 2023-10-10 09:19:44 CEST
OK