Bug 51953 - office365-group listener traceback on missing univentionOffice365Data attribute
office365-group listener traceback on missing univentionOffice365Data attribute
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: Office 365
UCS 4.4
Other Linux
: P5 normal (vote)
: ---
Assigned To: Erik Damrose
Julia Bremer
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2020-09-07 16:58 CEST by Arvid Requate
Modified: 2021-01-11 12:51 CET (History)
6 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 5: Major Usability: Impairs usability in key scenarios
Who will be affected by this bug?: 1: Will affect a very few installed domains
How will those affected feel about the bug?: 3: A User would likely not purchase the product
User Pain: 0.086
Enterprise Customer affected?:
School Customer affected?: Yes
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2020090721000162
Bug group (optional):
Max CVSS v3 score:
best: Patch_Available+


Attachments
fix_traceback_on_empty_UniventionOffice365Data.patch (1.14 KB, patch)
2020-09-07 16:59 CEST, Arvid Requate
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arvid Requate univentionstaff 2020-09-07 16:58:03 CEST
In a customer project we saw this traceback in listener.log:
=========================================
06.09.20 14:02:23.355  DEBUG_INIT
Traceback (most recent call last):
  File "/usr/lib/univention-directory-listener/system/office365-group.py", line 151, in handler
    create_groups(ol, dn, new, old)
  File "/usr/lib/univention-directory-listener/system/office365-group.py", line 120, in create_groups
    new_group = ol.create_group_from_new(new)
  File "/usr/lib/pymodules/python2.7/univention/office365/listener.py", line 342, in create_group_from_new
    return self.create_group(name, desc, self.dn)
  File "/usr/lib/pymodules/python2.7/univention/office365/listener.py", line 336, in create_group
    self.add_ldap_members_to_azure_group(group_dn, new_group["objectId"])
  File "/usr/lib/pymodules/python2.7/univention/office365/listener.py", line 655, in add_ldap_members_to_azure_group
    self.set_adconnection_object_id(udm_group, member_object_id)
  File "/usr/lib/pymodules/python2.7/univention/office365/listener.py", line 375, in set_adconnection_object_id
    azure_data = self.decode_o365data(azure_data_encoded)
  File "/usr/lib/pymodules/python2.7/univention/office365/listener.py", line 827, in decode_o365data
    return json.loads(zlib.decompress(base64.b64decode(data)))
zlib.error: Error -5 while decompressing data: incomplete or truncated stream
Traceback (most recent call last):
  File "/usr/lib/univention-directory-listener/system/office365-group.py", line 151, in handler
    create_groups(ol, dn, new, old)
  File "/usr/lib/univention-directory-listener/system/office365-group.py", line 120, in create_groups
    new_group = ol.create_group_from_new(new)
  File "/usr/lib/pymodules/python2.7/univention/office365/listener.py", line 342, in create_group_from_new
    return self.create_group(name, desc, self.dn)
  File "/usr/lib/pymodules/python2.7/univention/office365/listener.py", line 336, in create_group
    self.add_ldap_members_to_azure_group(group_dn, new_group["objectId"])
  File "/usr/lib/pymodules/python2.7/univention/office365/listener.py", line 676, in add_ldap_members_to_azure_group
    _groups_up_the_tree(udm_target_group)
  File "/usr/lib/pymodules/python2.7/univention/office365/listener.py", line 672, in _groups_up_the_tree
    self.set_adconnection_object_id(udm_member, member_object_id)
  File "/usr/lib/pymodules/python2.7/univention/office365/listener.py", line 375, in set_adconnection_object_id
    azure_data = self.decode_o365data(azure_data_encoded)
  File "/usr/lib/pymodules/python2.7/univention/office365/listener.py", line 827, in decode_o365data
    return json.loads(zlib.decompress(base64.b64decode(data)))
zlib.error: Error -5 while decompressing data: incomplete or truncated stream
Traceback (most recent call last):
  File "/usr/lib/univention-directory-listener/system/office365-group.py", line 151, in handler
    create_groups(ol, dn, new, old)
=========================================

I think the exception handling could be improved.
Comment 1 Arvid Requate univentionstaff 2020-09-07 16:59:24 CEST
Created attachment 10472 [details]
fix_traceback_on_empty_UniventionOffice365Data.patch
Comment 3 Erik Damrose univentionstaff 2020-12-15 13:17:13 CET
9159315a5a Fix Exception handling in listener lib

univention-office365 2.0.2-91A~4.4.0.202012151315
Comment 4 Felix Botner univentionstaff 2020-12-17 14:29:41 CET
intentionally, i modified UniventionOffice365Data on my test user, so that the data structure is broken and the patch helps,

but now i get 

17.12.20 14:24:31.241  LISTENER    ( PROCESS ) : o365: office 365 user listener active with filter='(&(objectClass=posixAccount)(objectClass=univentionOffice365)(uid=*))'
17.12.20 14:24:31.241  LISTENER    ( PROCESS ) : o365: AD connection aliases: {'azuretestdomain': 'initialized', 'defaultADconnection': 'uninitialized', 'o365domain': 'initialized'}
17.12.20 14:24:31.248  LISTENER    ( PROCESS ) : o365: adconnection_alias_old=set([]) adconnection_alias_new=set(['azuretestdomain'])
Traceback (most recent call last):
  File "/usr/lib/univention-directory-listener/system/office365-user.py", line 395, in handler
    udm_user = udm_helper.get_udm_user(dn, new)
  File "/usr/lib/pymodules/python2.7/univention/office365/udm_helper.py", line 103, in get_udm_user
    return cls.get_udm_obj("users/user", userdn, attributes)
  File "/usr/lib/pymodules/python2.7/univention/office365/udm_helper.py", line 257, in get_udm_obj
    obj.open()
  File "/usr/lib/python2.7/dist-packages/univention/admin/handlers/users/user.py", line 1276, in open
    univention.admin.handlers.simpleLdap.open(self)
  File "/usr/lib/python2.7/dist-packages/univention/admin/handlers/__init__.py", line 1078, in open
    self.call_udm_property_hook('hook_open', self)
  File "/usr/lib/python2.7/dist-packages/univention/admin/handlers/__init__.py", line 1054, in call_udm_property_hook
    func(module)
  File "/usr/lib/pymodules/python2.7/univention/admin/hooks.d/office365_user_ADConnections_hook.py", line 69, in hook_open
    self.adconnection_data = Office365Listener.decode_o365data(adconnection_data_encoded)
  File "/usr/lib/pymodules/python2.7/univention/office365/listener.py", line 843, in decode_o365data
    return json.loads(zlib.decompress(base64.b64decode(data)))
zlib.error: Error -3 while decompressing data: incorrect data check
17.12.20 14:24:31.275  LISTENER    ( WARN    ) : handler: office365-user (failed)


So i think we have to do something similar in /usr/lib/pymodules/python2.7/univention/admin/hooks.d/office365_user_ADConnections_hook.py (Office365Listener.decode_o365data)
Comment 5 Erik Damrose univentionstaff 2021-01-05 16:48:22 CET
I fixed other users of decode_o365data()

b9240a1d Fix exception handling in o365 data decoding

univention-office365 2.0.2-95A~4.4.0.202101051629
Comment 6 Julia Bremer univentionstaff 2021-01-06 10:06:09 CET
No traceback on empty/ incorrect UniventionOffice365Data any more: OK
The exception is caught on every execution of decode_o365data: OK

Verified
Comment 7 Erik Damrose univentionstaff 2021-01-11 12:51:33 CET
Released with App Version Univention Microsoft 365 Connector v3.3