Bug 52608 - Migrate ucs-school-umc-exam to Python 3
Migrate ucs-school-umc-exam to Python 3
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: General
UCS@school 5.0
Other Linux
: P5 normal (vote)
: UCS@school 5.0 v1
Assigned To: Florian Best
Felix Botner
: interim-3
Depends on: 52617
Blocks: 52578
  Show dependency treegraph
 
Reported: 2021-01-12 15:13 CET by Florian Best
Modified: 2021-11-29 17:20 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):
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 2021-01-12 15:13:59 CET
The package ucs-school-umc-exam needs to be migrated to Python 3.

See: https://hutten.knut.univention.de/mediawiki/index.php/Python_3_Migration

As the package is using python-samba, which is not available for Python 2 anymore, the package/scripts needs to be migrated to UCS@school 5.0.
Comment 2 Florian Best univentionstaff 2021-06-14 16:40:13 CEST
Traceback (most recent call last):
  File "03_computerroom_endExam", line 47, in test_umc
    existing_rejects = get_s4_rejected()
  File "/usr/lib/python3/dist-packages/univention/testing/ucsschool/exam.py", line 48, in get_s4_rejected
    found = re.findall(r"DN:\s\w{2,4}=.*", out)
  File "/usr/lib/python3.7/re.py", line 223, in findall
    return _compile(pattern, flags).findall(string)
TypeError: cannot use a string pattern on a bytes-like object
Comment 3 Florian Best univentionstaff 2021-07-13 16:17:37 CEST
I will overtake this bug.
Comment 4 Florian Best univentionstaff 2021-07-13 22:42:48 CEST
There is an API change in python-samba. getntacls() and setntacls() need an extra argument "session_info".
Passing samba.auth.system_session() doesn't work. Currently I am getting:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/notifier/threads.py", line 80, in _run
    result = self._function()
  File "/usr/lib/python3/dist-packages/univention/management/console/modules/schoolexam/__init__.py", line 777, in _thread                                                                                                                    
    Instance.set_nt_acls_on_exam_folders(my.project.getRecipients())
  File "/usr/lib/python3/dist-packages/univention/management/console/modules/schoolexam/__init__.py", line 257, in set_nt_acls_on_exam_folders                                                                                                
    deny_owner_change_permissions(root)
  File "/usr/lib/python3/dist-packages/univention/management/console/modules/schoolexam/__init__.py", line 124, in deny_owner_change_permissions                                                                                              
    dacl = getntacl(lp, filename, system_session(), direct_db_access=False)
  File "/usr/lib/python3/dist-packages/samba/ntacls.py", line 135, in getntacl
    service=service)
RuntimeError: Session unix info not initialized
Comment 5 Florian Best univentionstaff 2021-07-13 22:44:14 CEST
The error handling in the module is broken since Bug #51166 so that the progress bar never ends on an exception.
This has been fixed here as well.
Comment 6 Florian Best univentionstaff 2021-07-13 23:05:47 CEST
(In reply to Florian Best from comment #4)
> There is an API change in python-samba. getntacls() and setntacls() need an
> extra argument "session_info".
> Passing samba.auth.system_session() doesn't work. Currently I am getting:

Passing samba.auth_util.system_session_unix() causes:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/notifier/threads.py", line 80, in _run
    result = self._function()
  File "/usr/lib/python3/dist-packages/univention/management/console/modules/schoolexam/__init__.py", line 777, in _thread
    Instance.set_nt_acls_on_exam_folders(my.project.getRecipients())
  File "/usr/lib/python3/dist-packages/univention/management/console/modules/schoolexam/__init__.py", line 257, in set_nt_acls_on_exam_folders
    deny_owner_change_permissions(root)
  File "/usr/lib/python3/dist-packages/univention/management/console/modules/schoolexam/__init__.py", line 124, in deny_owner_change_permissions
    dacl = getntacl(lp, filename, system_session_unix(), direct_db_access=False)
  File "/usr/lib/python3/dist-packages/samba/ntacls.py", line 135, in getntacl
    service=service)
samba.NTSTATUSError: (3221225506, '{Access Denied} A process has requested access to an object but has not been granted those access rights.')
Comment 7 Florian Best univentionstaff 2021-07-14 16:12:46 CEST
The exam module and the exam-master module have been migrated to Python 3.

ucs-school-umc-exam (10.0.1)
76779b4fad1b | Bug #52608: [ucs-school-umc-exam] migrate to Python 3

*   Fix error handling when starting and stopping exams:
    * Revert git:cc1a2118dd55e315489160b13d4db4983723be58 Bug #51166.
      → It let the UMC module process crash and the progress bar hangs forever.
      A thread finish callback must never raise an exception.
    * The new behavior aborts the progress bar correctly, so that the error
      message is shown in the eror page of the exam mode.
    * Additionally a traceback dialog pops up.
    * Additionally the traceback is logged into
      /var/log/univention/management-console-web-server.log.
    
*   Adjust to API change in python-samba

(In reply to Florian Best from comment #6)
> (In reply to Florian Best from comment #4)
> > There is an API change in python-samba. getntacls() and setntacls() need an
> > extra argument "session_info".
> > Passing samba.auth.system_session() doesn't work. Currently I am getting:
> 
> Passing samba.auth_util.system_session_unix() causes:
> samba.NTSTATUSError: (3221225506, '{Access Denied} A process has requested
> access to an object but has not been granted those access rights.')
Calling the following prevents this:
+    s3conf = param.get_context()
+    s3conf.load(lp.configfile)
→ This is how get_local_domain_sid() from /usr/lib/python3/dist-packages/samba/netcmd/ntacl.py does it.
Comment 8 Florian Best univentionstaff 2021-07-16 12:05:30 CEST
The following test cases are currently failing:

 90_ucsschool.101_exam_prepare
 90_ucsschool.101_exam_mode_home_directories_permissions
 90_ucsschool.101_exam_mode_filename_problems.test_exam_mode_filename_problems
 90_ucsschool.101_exam_mode
Comment 9 Florian Best univentionstaff 2021-07-16 13:57:03 CEST
(In reply to Florian Best from comment #8)
> The following test cases are currently failing:
> 
>  90_ucsschool.101_exam_mode_filename_problems.
> test_exam_mode_filename_problems
→ interim problem in Py3 migration of the test case. fixed.

>  90_ucsschool.101_exam_prepare
>  90_ucsschool.101_exam_mode
looks like Bug #53579, already in 4.4 present.

>  90_ucsschool.101_exam_mode_home_directories_permissions
TODO: investigate the reason.
Comment 10 Florian Best univentionstaff 2021-07-17 14:27:54 CEST
(In reply to Florian Best from comment #9)
> (In reply to Florian Best from comment #8)
> > The following test cases are currently failing:
> > 
> >  90_ucsschool.101_exam_mode_filename_problems.
> > test_exam_mode_filename_problems
> → interim problem in Py3 migration of the test case. fixed.
> 
> >  90_ucsschool.101_exam_prepare
> >  90_ucsschool.101_exam_mode
> looks like Bug #53579, already in 4.4 present.
Fixed via Bug #53579

> >  90_ucsschool.101_exam_mode_home_directories_permissions
> TODO: investigate the reason.

This has to do with UCS 5.0 adjustments of univention-skel. I will open a new bug for this.
Comment 11 Felix Botner univentionstaff 2021-08-05 16:15:15 CEST
OK - is python3
OK - (simple) exam mode manual test
OK - exam_mode tests (except 101_exam_mode_home_directories_permissions.py, as mentioned in comment #10)
Comment 12 Florian Best univentionstaff 2021-08-09 14:54:01 CEST
(In reply to Felix Botner from comment #11)
> OK - exam_mode tests (except 101_exam_mode_home_directories_permissions.py,
> as mentioned in comment #10)Bug #53640
Comment 13 Jürn Brodersen univentionstaff 2021-11-29 17:20:01 CET
UCS@school 5.0 v1 has been released.

https://docs.software-univention.de/release-notes-ucsschool-5.0v1-de.html

If this error occurs again, please clone this bug.