Bug 7381 - TLDC crash with menu file with empty <include>
Summary: TLDC crash with menu file with empty <include>
Status: CLOSED FIXED
Alias: None
Product: ThinLinc
Classification: Unclassified
Component: TLDC (Desktop Customizer) (show other bugs)
Version: trunk
Hardware: PC Unknown
: P2 Normal
Target Milestone: 4.11.0
Assignee: Pierre Ossman
URL:
Keywords: nikle_tester, relnotes
Depends on:
Blocks:
 
Reported: 2019-09-27 10:30 CEST by Pierre Ossman
Modified: 2020-09-23 15:44 CEST (History)
1 user (show)

See Also:
Acceptance Criteria:


Attachments
Provoking .menu file (179 bytes, application/octet-stream)
2019-09-27 10:30 CEST, Pierre Ossman
Details

Description Pierre Ossman cendio 2019-09-27 10:30:46 CEST
Created attachment 914 [details]
Provoking .menu file

We got a report that TLDC would only give a 500 response when trying to use it in tlwebadm, and the following crash was seen in the logs:

> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1] code 500, message Internal error on page '/desktop/'
> 2019-09-23 10:38:57 INFO tlwebadm[24456]: [::1] 'GET /desktop/ HTTP/1.1' 500 -
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1] ----------------------------------------
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1] Traceback (most recent call last):
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]   File "/opt/thinlinc/sbin/tlwebadm", line 225, in post_or_get
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]     I1i1iii , OOO0o = getattr ( oOOOOo0 , action ) ( IiI11iII1 , iII , I1i1iii )
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]   File "/opt/thinlinc/modules/thinlinc/tlwebadm/main.py", line 109, in do_GET
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]     self . _GET_METHODS . get ( page_name , self . error_404 ) ( query ) )
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]   File "/opt/thinlinc/modules/thinlinc/tlwebadm/desktop.py", line 74, in home
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]     selfdefined = False ) )
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]   File "/opt/thinlinc/modules/thinlinc/tl_desktop/apps.py", line 77, in get_applications
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]     oo0O000OoO ( menuparse ( iiIIiIiIi ) , OOo )
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]   File "/opt/thinlinc/modules/thinlinc/xdg/Menu.py", line 524, in parse
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]     __parse(doc, filename, tmp["Root"])
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]   File "/opt/thinlinc/modules/thinlinc/xdg/Menu.py", line 545, in __parse
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]     __parseMenu(child, filename, parent)
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]   File "/opt/thinlinc/modules/thinlinc/xdg/Menu.py", line 699, in __parseMenu
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]     __parse(child, filename, m)
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]   File "/opt/thinlinc/modules/thinlinc/xdg/Menu.py", line 545, in __parse
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]     __parseMenu(child, filename, parent)
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]   File "/opt/thinlinc/modules/thinlinc/xdg/Menu.py", line 699, in __parseMenu
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]     __parse(child, filename, m)
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]   File "/opt/thinlinc/modules/thinlinc/xdg/Menu.py", line 579, in __parse
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]     parent.Rules.append(Rule(child.tagName, child))
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]   File "/opt/thinlinc/modules/thinlinc/xdg/Menu.py", line 291, in __init__
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]     self.compile()
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]   File "/opt/thinlinc/modules/thinlinc/xdg/Menu.py", line 310, in compile
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]     """ % self.Rule) in self.__dict__
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]   File "<string>", line 6
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]     elif :
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1]          ^
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1] SyntaxError: invalid syntax
> 2019-09-23 10:38:57 ERROR tlwebadm[24456]: [::1] ----------------------------------------

The file triggering this has been attached. Simply put it in one of the "-merged" directories in /etc/xdg/menus and TLDC will start crashing.

The issue seems to be that pyxdg does not handle empty <include> blocks (and likely not empty <exclude> blocks either).
Comment 2 Pierre Ossman cendio 2019-09-27 10:46:10 CEST
Note that we have a very old version of PyXDG. This might have been fixed in a newer version.
Comment 3 Pierre Ossman cendio 2019-09-27 12:36:04 CEST
I tested the PyXDG included in Fedora, and it seems to handle these files just fine.
Comment 4 Pierre Ossman cendio 2019-09-27 12:37:41 CEST
Temporary workaround:

> diff --git a/tlmisc/tl-desktop/modules/thinlinc/xdg/Menu.py b/tlmisc/tl-desktop/modules/thinlinc/xdg/Menu.py
> index 3af88b70e..65633465b 100644
> --- a/tlmisc/tl-desktop/modules/thinlinc/xdg/Menu.py
> +++ b/tlmisc/tl-desktop/modules/thinlinc/xdg/Menu.py
> @@ -288,6 +288,9 @@ class Rule:
>          # Begin parsing
>          if node:
>              self.parseNode(node)
> +            # See Cendio bug 7381
> +            if self.Rule == "":
> +                self.Rule = "False"
>              self.compile()
>  
>      def __str__(self):
Comment 5 Pierre Ossman cendio 2019-10-01 12:42:32 CEST
We'll apply the workaround for now. An upgrade of PyXDG can be done when we're doing larger work on TLDC.
Comment 7 Pierre Ossman cendio 2019-10-01 15:41:33 CEST
Workaround applied to trunk now. Customer has also verified that this works.
Comment 8 Samuel Mannehed cendio 2019-10-03 12:38:43 CEST
Looks good. Verified the crash using ThinLinc 4.10.1, and verified that it is indeed fixed in build 6255.

Used an Ubuntu 18.04 as a server, and it might be worth noting that my /etc/xdg/menus didn't have any "-merged" directories.

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