Bug 52960 - [o365] Changing UCR default settings for usertoken script causes traceback due to missing conversion to int
[o365] Changing UCR default settings for usertoken script causes traceback du...
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: Office 365
UCS 4.4
Other Linux
: P5 normal (vote)
: ---
Assigned To: Erik Damrose
Felix Botner
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2021-03-19 13:40 CET by Erik Damrose
Modified: 2021-09-13 17:23 CEST (History)
0 users

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?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.057
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2021022221000304
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Damrose univentionstaff 2021-03-19 13:40:46 CET
The script o365_usertokens is used within a cronjob to periodically reset usertokens in azure. The period between two resets can be configured via UCR, the default is 60 + up to 15 days.

Manually configured settings set by admins in UCR does cause the script to fail, as the UCR value is not correctly converted to int, causing the following traceback:

Traceback (most recent call last):
  File "/usr/share/univention-office365/scripts/o365_usertokens", line 127, in <module>
    next_mod_date = today + timedelta(days=base_reset_period + randrange(reset_period_modifier + 1))
TypeError: cannot concatenate 'str' and 'int' objects

Fix: Parse values read from UCR as int.
Comment 1 Erik Damrose univentionstaff 2021-03-19 13:54:11 CET
453bbeab univention-office365 2.0.2-111A~4.4.0.202103191347

Reproduce: 
create udm user, o365 enabled
ucr set office365/tokens/base_reset_period=12
/usr/share/univention-office365/scripts/o365_usertokens --invalidate-tokens -m (this is what the cronjob does)
Comment 2 Felix Botner univentionstaff 2021-03-19 14:24:05 CET
OK - reproduce

-> ucr set office365/tokens/base_reset_period=12
-> /usr/share/univention-office365/scripts/o365_usertokens --invalidate-tokens --modify
proxy settings: {}
service_plan_names=['SHAREPOINTWAC', 'SHAREPOINTWAC_DEVELOPER', 'OFFICESUBSCRIPTION', 'OFFICEMOBILE_SUBSCRIPTION', 'SHAREPOINTWAC_EDU']
status: 200 (OK) (POST https://graph.windows.net/d66c72f6-8dee-47ed-ac2b-7fdbe8b8a5d4/users/0af4e4cf-581c-4404-8ddd-db8e5c132ee5/invalidateAllRefreshTokens?api-version=1.6)
Traceback (most recent call last):
  File "/usr/share/univention-office365/scripts/o365_usertokens", line 127, in <module>
    next_mod_date = today + timedelta(days=base_reset_period + randrange(reset_period_modifier + 1))
TypeError: cannot concatenate 'str' and 'int' objects

OK - fixed with 2.0.2-112

-> ucr set office365/tokens/base_reset_period=12
-> /usr/share/univention-office365/scripts/o365_usertokens --invalidate-tokens --modify
proxy settings: {}
service_plan_names=['SHAREPOINTWAC', 'SHAREPOINTWAC_DEVELOPER', 'OFFICESUBSCRIPTION', 'OFFICEMOBILE_SUBSCRIPTION', 'SHAREPOINTWAC_EDU']
status: 200 (OK) (POST https://graph.windows.net/d66c72f6-8dee-47ed-ac2b-7fdbe8b8a5d4/users/0af4e4cf-581c-4404-8ddd-db8e5c132ee5/invalidateAllRefreshTokens?api-version=1.6)
Modified user: fbx1, next reset will be 2021-04-03
Error: user fbx2 is not correctly synced to Azure (missing univentionOffice365Data attribute)
Modified user: fbx3, next reset will be 2021-04-07
Comment 3 Erik Damrose univentionstaff 2021-09-13 17:23:11 CEST
Published in App 'office365' version 4.0