Bug 3618 - tl-config gives traceback on bad files
Summary: tl-config gives traceback on bad files
Status: CLOSED FIXED
Alias: None
Product: ThinLinc
Classification: Unclassified
Component: Other (show other bugs)
Version: pre-1.0
Hardware: PC Unknown
: P2 Normal
Target Milestone: 4.17.0
Assignee: Samuel Mannehed
URL:
Keywords: adaha_tester, prosaic
Depends on:
Blocks:
 
Reported: 2010-10-06 14:40 CEST by Pierre Ossman
Modified: 2024-05-17 16:00 CEST (History)
3 users (show)

See Also:
Acceptance Criteria:
MUST: * tl-config must not write a traceback when there are syntax errors in the configuration. SHOULD: * tl-config should still try to continue despite the syntax error. COULD: * Other ThinLinc tools and services should not traceback on syntax errors in the configuration.


Attachments

Description Pierre Ossman cendio 2010-10-06 14:40:13 CEST
This is not very user friendly:

[root@dhcp-254-171 ~]# /opt/thinlinc/bin/tl-config /appservergroups/rdp/default/domain
Traceback (most recent call last):
  File "/usr/bin/hivetool", line 165, in ?
    main()
  File "/usr/bin/hivetool", line 128, in main
    hive = hiveconf.open_hive(roothive)
  File "/usr/lib/hiveconf/hiveconf.py", line 638, in open_hive
    return hfp.parse()
  File "/usr/lib/hiveconf/hiveconf.py", line 699, in parse
    self.mount_directive(args, curfolder, url, linenum, sectionname)
  File "/usr/lib/hiveconf/hiveconf.py", line 798, in mount_directive
    self.parse(mount_url, curfolder)
  File "/usr/lib/hiveconf/hiveconf.py", line 718, in parse
    raise SyntaxError(url, linenum)
hiveconf.SyntaxError: Bad line 13 in file:///opt/thinlinc/etc/conf.d/appservergroups.hconf
Comment 1 Emil Lock cendio 2023-07-10 10:24:02 CEST
Since the cause of the problem is located in hiveconf I found that this also happens for the following:

  - tlwebaccess
  - thinlinc-login
  - vsmagent
  - vsmserver
  - tl-ssh-all
  - tlwebadm
  - tl-setup
  - tl-desktop-builder
  - tl-rsync-all
  - tl-wait-smartcard
  - tl-session-param
  - tl-ldap-certalias
  - tl-limit-printers
Comment 3 Pierre Ossman cendio 2023-07-12 14:41:50 CEST
Note that we already have bug 2126 as the general case of this issue.
Comment 6 Samuel Mannehed cendio 2024-05-08 09:58:10 CEST
The change proposed in comment 4 and comment 5 would enable hiveconf to continue parsing the configuration despite syntax errors.

However, with the above change, if the admin made a mistake when editing the configuration, the error might go undiscovered. The ThinLinc services would start, and the error would be printed to the journal. An error would be printed to the terminal if the admin used, for example, tl-config, but we don't know if he/she will.

We have decided that we will not make any large changes as part of this bug. Let's leave bigger discussions and redesigns to bug 2126. Removing "blocks".
Comment 11 Samuel Mannehed cendio 2024-05-08 11:46:58 CEST
> MUST:
> * tl-config must not write a traceback when there are syntax errors in the configuration.
Fixed as of r40902.
 
> SHOULD:
> * tl-config should still try to continue despite the syntax error.
While this would be nice for tl-config, achieving this would require a larger change that would also affect our services. We're not comfortable changing that doing right now, it needs further research. See comment 6, and also bug 2126.

> COULD:
> * Other ThinLinc tools and services should not traceback on syntax errors in the configuration.
This was not included as part of this bug to save some time.
Comment 13 Samuel Mannehed cendio 2024-05-13 11:47:49 CEST
Opened a PR containing this fix upstream:

https://github.com/astrand/hiveconf/pull/2
Comment 14 Adam Halim cendio 2024-05-14 16:06:10 CEST
Tested the following using 4.16.0 and build 3585 on RHEL 9:
========

Added the following line to vsm.hconf and ran tl-config:
> syntax_error?
4.16.0:
> tl-config
> Traceback (most recent call last):
>   File "/opt/thinlinc/bin/../bin/hivetool", line 322, in <module>
>     main()
>   File "/opt/thinlinc/bin/../bin/hivetool", line 270, in main
>     hive = hiveconf.open_hive(roothive)
>   File "/opt/thinlinc/modules/thinlinc/hiveconf.py", line 597, in open_hive
>     return hfp.parse()
>   File "/opt/thinlinc/modules/thinlinc/hiveconf.py", line 622, in parse
>     self._parse_file(file, rootfolder, url)
>   File "/opt/thinlinc/modules/thinlinc/hiveconf.py", line 676, in _parse_file
>     self.mount_directive(args, curfolder, url, linenum, sectionname)
>   File "/opt/thinlinc/modules/thinlinc/hiveconf.py", line 773, in mount_directive
>     self.parse(mount_url, curfolder)
>   File "/opt/thinlinc/modules/thinlinc/hiveconf.py", line 622, in parse
>     self._parse_file(file, rootfolder, url)
>   File "/opt/thinlinc/modules/thinlinc/hiveconf.py", line 695, in _parse_file
>     raise SyntaxError(url, linenum)
> thinlinc.hiveconf.SyntaxError: Bad line 7 in file:///opt/thinlinc/etc/conf.d/vsm.hconf
Build 3585:
> tl-config
> Bad line 7 in file:///opt/thinlinc/etc/conf.d/vsm.hconf: 'syntax_error?'
The output is much more helpful with this fix.

Looked through the commits and they looked good!

> MUST:
> ✅ tl-config must not write a traceback when there are syntax errors in the
>    configuration.
tl-config no longer produces a traceback when reading a conf file.
> SHOULD:
> ❌ tl-config should still try to continue despite the syntax error.
> COULD:
> ❌ Other ThinLinc tools and services should not traceback on syntax errors in the
>    configuration.
While these two AC's were not fulfilled, as motivated by comment #11, the bug has been fixed and the MUST criteria is fulfilled. Closing.

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