Bug 48357 - listener modules created with new listener API always displayed with status=0
listener modules created with new listener API always displayed with status=0
Status: NEW
Product: UCS
Classification: Unclassified
Component: Listener (univention-directory-listener)
UCS 4.3
Other Linux
: P5 normal (vote)
: ---
Assigned To: UCS maintainers
UCS maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2018-12-16 08:52 CET by Daniel Tröder
Modified: 2019-08-19 16:08 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 3: Simply Wrong: The implementation doesn't match the docu
Who will be affected by this bug?: 3: Will affect average number of installed domains
How will those affected feel about the bug?: 1: Nuisance – not a big deal but noticeable
User Pain: 0.051
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Ticket number:
Bug group (optional):
Max CVSS v3 score:
troeder: Patch_Available+


Attachments
simple listener module (984 bytes, text/x-python)
2018-12-16 08:52 CET, Daniel Tröder
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2018-12-16 08:52:00 CET
Created attachment 9779 [details]
simple listener module

When a listener module created with the new listener API is installed and the u-d-l is restarted the status shown with "univention-directory-listener-ctrl status" is always "0".

The listener did however successfully initialize the module, as can be seen in the logfile.

The status file in /var/lib/univention-directory-listener/handlers/$NAME does contain a "3", but "univention-directory-listener-ctrl status" still shows a "0".

Attached is a simple listener module to reproduce this.
Comment 1 Philipp Hahn univentionstaff 2018-12-16 12:17:05 CET
<http://docs.software-univention.de/developer-reference-4.3.html#listener:handler> specified that "name" must be declared as the top-level symbol in the *Python* module.
This is parsed by the *shell* script "management/univention-directory-listener/src/listener-ctrl", which uses the regular expression
  ^name\s*=\s*['\"]([^'\"]+)['\"]\s*(#.*)?$

Using anything else breaks the status output.
Comment 2 Daniel Tröder univentionstaff 2018-12-18 11:29:34 CET
I created a script that prints the configuration of both new and old API listener modules.

Because the old way is must faster (no Python import required), it is only used as a fall back.

[dtroeder/48357_listener_name 3b8a94241c] Bug #48357: get name of listener modules using new API
Comment 3 Daniel Tröder univentionstaff 2019-08-19 16:08:42 CEST
Alternative:

$ apt install pcre2-utils

$ pcre2grep -M -o3 "ListenerModuleHandler\).*(\n|.)*class Configuration.*(\n|.)*name\s*=\s*[\"'](.+)[\"']" <LISTENERMODULE>

Tested with 
* univention-radius.py
* /usr/share/doc/univention-directory-listener/examples/listener_module_template.py