Bug 7703 - xstartup cannot be run in Python 3
Summary: xstartup cannot be run in Python 3
Status: CLOSED FIXED
Alias: None
Product: ThinLinc
Classification: Unclassified
Component: Misc (show other bugs)
Version: trunk
Hardware: PC Unknown
: P2 Normal
Target Milestone: 4.13.0
Assignee: Niko Lehto
URL:
Keywords: frifl_tester, prosaic, wilsj_tester
Depends on:
Blocks: 4586
  Show dependency treegraph
 
Reported: 2021-05-07 12:23 CEST by Niko Lehto
Modified: 2021-05-26 13:34 CEST (History)
3 users (show)

See Also:
Acceptance Criteria:


Attachments

Description Niko Lehto cendio 2021-05-07 12:23:08 CEST
Our xstartup contains a few Python scripts, these should be converted to be compatible with Python 3 so we don't depend on Python 2 anymore.
The Python files I found are:
- tl-xstartup-desc
- tl-run-xstartup-feedback
Comment 5 Niko Lehto cendio 2021-05-12 13:07:07 CEST
Tested with 4.12.1 client against Fedora 33 server-bundle containing these changes. Works good.
Comment 6 Samuel Mannehed cendio 2021-05-14 14:37:17 CEST
Crashes on RHEL7:

> [cendio@lab-203 ~]$ touch test
> [cendio@lab-203 ~]$ /opt/thinlinc/libexec/tl-run-xstartup-feedback test 
>   File "/opt/thinlinc/libexec/tl-run-xstartup-feedback", line 115
>     print ( "%s: warning: Unable to initialize GTK+" % sys . argv [ 0 ] , file = sys . stderr )
>                                                                                ^
> SyntaxError: invalid syntax
Comment 8 Pierre Ossman cendio 2021-05-17 10:11:52 CEST
Should work properly under Python 3 now.
Comment 9 William Sjöblom cendio 2021-05-19 16:24:03 CEST
The converted `tl-xstartup-desc` assumes that all files in /opt/thinlinc/etc/xstartup.d are textual scripts and not arbitrary binaries. 

Thus, if we symlink a binary into xstartup.d:
> ln -s /bin/pwd /opt/thinlinc/etc/xstartup.d/00-pwd`
We get the following stack trace in /var/opt/thinlinc/sessions/<user>/last/xinit.log:
> Traceback (most recent call last):
>   File "/opt/thinlinc/libexec/tl-xstartup-desc", line 58, in <module>
>     ooo0oOoooOOO0 ( )
>   File "/opt/thinlinc/libexec/tl-xstartup-desc", line 19, in ooo0oOoooOOO0
>     if oOO0OoOoo000 . read ( 1 ) != '#' :
>   File "/usr/lib64/python3.4/codecs.py", line 319, in decode
>     (result, consumed) = self._buffer_decode(data, self.errors, final)
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 40: invalid start byte
> Running /opt/thinlinc/etc/xstartup.d/00-pwd
> /home/<user>
As you can see `pwd` still runs, but we get an ugly stack trace in the logs.
Comment 11 Samuel Mannehed cendio 2021-05-20 16:22:28 CEST
The traceback has now been fixed.
Comment 13 Frida Flodin cendio 2021-05-26 13:34:10 CEST
Tested on RHEL 8 with build 2101.

 ✓ Feedback in GUI.
 ✓ Descriptions are correctly displayed in log and GUI.
 ✓ Running without GTK+ prints the warnings (e.i. comment 6 is fixed).
 ✓ Symlinking a binary into xstartup.d as described in comment 9.

Note You need to log in before you can comment on or make changes to this bug.