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).
Note that we have a very old version of PyXDG. This might have been fixed in a newer version.
I tested the PyXDG included in Fedora, and it seems to handle these files just fine.
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):
We'll apply the workaround for now. An upgrade of PyXDG can be done when we're doing larger work on TLDC.
Workaround applied to trunk now. Customer has also verified that this works.
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.