Bug 29420 - Entwicklung eines Listener-Moduls
Entwicklung eines Listener-Moduls
Status: CLOSED FIXED
Product: UCS extended documentation
Classification: Unclassified
Component: Developer documentation
unspecified
Other Linux
: P5 normal (vote)
: UCS 4.0-1-errata
Assigned To: Philipp Hahn
Arvid Requate
: interim-5
: 7662 22101 (view as bug list)
Depends on:
Blocks: 29398 31511
  Show dependency treegraph
 
Reported: 2012-11-27 17:15 CET by Moritz Muehlenhoff
Modified: 2015-02-19 15:02 CET (History)
3 users (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments
qa_29420.patch (35.90 KB, patch)
2014-04-07 21:51 CEST, Arvid Requate
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Moritz Muehlenhoff univentionstaff 2012-11-27 17:15:10 CET
Die 3.1-0 Version der Developer-Dokumentation sollte auf Basis des 
Artikels http://wiki.univention.de/index.php?title=Entwicklung_von_Univention_Directory_Listener-Modulen erstellt werden.

Anschließend kann er entfernt werden oder ein Verweis auf die Entwickler-Doku eingefügt werden.

Das Beispielmodul sollte am besten ins öffentliche SVN kopiert werden, damit es leicht ausgecheckt werden kann.
Comment 1 Moritz Muehlenhoff univentionstaff 2012-11-27 17:17:37 CET
*** Bug 7662 has been marked as a duplicate of this bug. ***
Comment 2 Moritz Muehlenhoff univentionstaff 2012-11-28 11:45:51 CET
*** Bug 22101 has been marked as a duplicate of this bug. ***
Comment 3 Moritz Muehlenhoff univentionstaff 2013-08-30 15:59:50 CEST
That bug can be closed?
http://docs.univention.de/developer-reference-3.1.html#chap:listener

Or is there anything missing?
Comment 4 Philipp Hahn univentionstaff 2013-08-30 17:20:39 CEST
(In reply to Moritz Muehlenhoff from comment #3)
> That bug can be closed?
No
> http://docs.univention.de/developer-reference-3.1.html#chap:listener
> 
> Or is there anything missing?
Yes
Comment 5 Philipp Hahn univentionstaff 2014-01-30 16:11:31 CET
r47537+r47538
QA neede:
1. comare internals with <https://hutten.knut.univention.de/mediawiki/index.php/Arvid_memo/Listener>
2. Remove Wiki page after QA and publish.
Comment 6 Nico Gulden univentionstaff 2014-02-04 09:27:06 CET
An app vendor is currently working on a listener module and the updated documentation would be really helpful for them. I'd like to point him to the documenation as soon as possible and as soon as it is available.
Comment 7 Stefan Gohmann univentionstaff 2014-02-04 10:27:21 CET
(In reply to Nico Gulden from comment #6)
> An app vendor is currently working on a listener module and the updated
> documentation would be really helpful for them. I'd like to point him to the
> documenation as soon as possible and as soon as it is available.

Can they read German? If so please use:
http://wiki.univention.de/index.php?title=Entwicklung_von_Univention_Directory_Listener-Modulen
Comment 8 Nico Gulden univentionstaff 2014-02-04 15:55:23 CET
(In reply to Stefan Gohmann from comment #7)
> (In reply to Nico Gulden from comment #6)
> > An app vendor is currently working on a listener module and the updated
> > documentation would be really helpful for them. I'd like to point him to the
> > documenation as soon as possible and as soon as it is available.
> 
> Can they read German? If so please use:
> http://wiki.univention.de/index.
> php?title=Entwicklung_von_Univention_Directory_Listener-Modulen

Yes, they can. I forwarded it. QA is not urgent anymore for me. Thanks.
Comment 9 Arvid Requate univentionstaff 2014-04-07 21:51:05 CEST
Created attachment 5859 [details]
qa_29420.patch

Please find some small change proposals attached.
Comment 10 Philipp Hahn univentionstaff 2014-04-08 10:21:33 CEST
(In reply to Arvid Requate from comment #9)
> Created attachment 5859 [details]
> qa_29420.patch
> 
> Please find some small change proposals attached.

Applied with some small changes:
 array -> list
 Listener -> listener (some more cases)
 automatically internally configured -> configured internally
 should be -> is
 cache to cache -> cache to store

Split long sentence:
> It's best practice to use the <function>handler()</function> only to process the stream of changes, set UCR variables or generate new configuration files.
> Restarting associated services should be delayed to the <function>postrun()</function> function.

Additional changes:
1. Remove the ':' between ldap/server/addition and the closing ')'.
2. Tag all variables and functions as either "required" or "optional". (actually "filter" is optional, but will be evaluated is False always. And the listener will crash, is handler() is not defined.)
3. Move the "debian/printusers.postrm" line between the two source code examples to better separate them for readability.

Regarding Listener&pickle:
> AREQ: And what's the recommendation?
Currently you can't write pickle files from a listener module and read them from a non-listener program (I tried to do that once for a customer module, only to discover that later which forced me to re-write the whole module).
Writing pickle data and reading pickle from the same listener module should work.

Regarding writing files to /tmp/ as root:
> AREQ: Why? What's the point here? Relevant?
The module does something problematic here to keep the example simple.
Most listener modules used in UCS seem to simply do the seteuid() thing to by-pass the permission checking, since they easily could live with files owned by "listener" instead of "root". I actually tried to implement such a listener, but there are several pit-falls, as for example, the module is initialized with euid=root; so if you already create a file/directory there, the module will not be able to access it later on from its handler(), as there euid=listener. So you have to explicitly change the owner of the initial file/directory by hand, using some combination of os.chown(path, pwd.getpwnam("listener").pw_uid), -1)
Since there's also no code to prevent symlink attacks , I at least want't to tell the reader that "this is bad style to write as root into a public location".
I've removed the paragraph and changed the path to /root/UserList.txt

Regarding LDAP returning nothing:
> AREQ: Uh, really? A d operation should be processed as well? Maybe rephrase "the process"?
You are right and I was wrong, now reads:
> It retrieve the latest state of the object identified through the <abbrev>DN</abbrev>.
> If access is blocked, for example, by <firstterm>selective replication</firstterm>, the change is handled as a delete operation instead.

r49143: <http://jenkins.knut.univention.de:8080/view/Doku/job/UCS-3.2%20Handbook%20Developer/ws/webroot/developer-reference-3.2.html#chap:listener>
Comment 12 Philipp Hahn univentionstaff 2014-04-08 13:31:04 CEST
r49159: Replace wrong reference to ldap/server/addition and document notifier choosing mechanism.
<http://jenkins.knut.univention.de:8080/job/UCS-3.2%20Handbook%20Developer/104/artifact/webroot/developer-reference-3.2.html#listener:details:internal>
Comment 13 Arvid Requate univentionstaff 2014-04-08 14:22:58 CEST
Ok, looks good, high information quality.
Comment 14 Philipp Hahn univentionstaff 2014-04-09 16:03:15 CEST
r49217: Fixed several issues in the printuser.py example, which was originally copied from the Wiki article.
Comment 15 Philipp Hahn univentionstaff 2014-05-05 16:13:15 CEST
As previously discussed: a listener MUST NOT use command only, but should still prefer checking "new" and "old" for "None" or "{...}".
r49798 | Bug #29420 DevDoc: Listener example
Comment 16 Arvid Requate univentionstaff 2015-01-26 18:10:05 CET
Ok.