Bug 29964 - UCR C lib does not support different UCR layers
UCR C lib does not support different UCR layers
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UCR
UCS 2.4
Other Linux
: P5 normal (vote)
: UCS 3.2
Assigned To: Arvid Requate
Philipp Hahn
: interim-1
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-01-08 15:07 CET by Tim Petersen
Modified: 2013-11-19 06:41 CET (History)
1 user (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
Test case and rstip() implementation (3.87 KB, patch)
2013-08-05 09:40 CEST, Philipp Hahn
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Petersen univentionstaff 2013-01-08 15:07:42 CET
Initially watched with UCS 2.4 at Ticket #2013010421000598 - but seems to be also the case in UCS 3.0 and 3.1:

The listener uses the method "univention_config_get_string()" from config.c lib of univention-config-registry.
This method only looks in "/etc/univention/base.conf".

The listener should use the effective variable values (i.e. scope ldap if existing).
Comment 1 Stefan Gohmann univentionstaff 2013-01-08 15:24:32 CET
The listener uses the C lib of UCR. The C lib doesn't support the different layers.
Comment 2 Arvid Requate univentionstaff 2013-07-29 19:06:46 CEST
The C library has been adjusted to consider the force, schedule and ldap layers before consulting the normal layer. I only changed the "get" function(s). Since frontend.py does not consider the "custom" layer (environment variable "UNIVENTION_BASECONFIG") the C-library also doesn't, to keep results comparable.
Comment 3 Philipp Hahn univentionstaff 2013-08-05 09:39:48 CEST
> Modified: branches/ucs-3.2/ucs-3.2-0/base/univention-config-registry/lib/config.c (42903 => 42904)
...
> +const char *SCOPES[] = {
...
> +const char *BASES[] = {

Please prefix with "static" to limit the availability of those two declaration to the scope of this file. Otherwise they are exported and pollute the name space of all programs using this lib (not many). The names are way too generic for that.
otherwise prefix them with "univention_config_".

Otherwise this in an ABI change, which requires configure.ac and debian/libunivention-config0.symbols to be updated:
> --- debian/libunivention-config0.symbols
> (libunivention-config0_9.0.3-3_amd64) +++ dpkg-gensymbolsTRoxCZ      
> 2013-08-05 07:24:27.607999997 +0200 @@ -1,4 +1,6 @@
> 
>  libuniventionconfig.so.0 libunivention-config0 #MINVER#
> 
> + BASES@Base 9.0.3-3
> + SCOPES@Base 9.0.3-3
> 
>   univention_config_get_int@Base 5.0.0
>   univention_config_get_long@Base 5.0.0
>   univention_config_get_string@Base 5.0.0

LIB_CURRENT=0 → 1
LIB_REVISION=1 → 0
LIB_AGE=0 → 1
(The API was changed in a forward-compatible way:: programs linked with the old version still work (LIB_CURRENT-LIB_DELTA=const), but programs linked to the new version might not work with the old version (LIB_CURRENT++))


While updating test/clib.c I also noticed that the code was and is broken: The last entry in /etc/univention/base*.conf is NOT terminated by a new-line, so the code in lib/config.c:90
> 		ret = strndup(line + len, strlen(line) - len - 1 ); /* no newline */
strips the last character:
> should=--ldap-policy is=--ldap-polic
Notice the missing 'y'.

A hex-dump of /etc/univention/base-ldap.conf shows this:
# xxd /etc/univention/base-ldap.conf
0000000: 2320 756e 6976 656e 7469 6f6e 5f20 6261  # univention_ ba
0000010: 7365 2e63 6f6e 660a 0a74 6573 742f 636c  se.conf..test/cl
0000020: 6962 3a20 2d2d 6c64 6170 2d70 6f6c 6963  ib: --ldap-polic
0000030: 79                                       y
Also no '0a' = '\n' at the end.

The equivalent of Pythons string.rstrip() is needed instead of the unconditional -1.
Comment 4 Philipp Hahn univentionstaff 2013-08-05 09:40:37 CEST
Created attachment 5354 [details]
Test case and rstip() implementation
Comment 5 Arvid Requate univentionstaff 2013-08-05 11:43:21 CEST
Patch applied and rebuilt.
Comment 6 Philipp Hahn univentionstaff 2013-08-05 12:33:10 CEST
OK: univention_config_get_string() now honors the layers
OK: UCS-3.1-1 → UCS-3.2~
OK: svn42904,42905,42907,42984
OK: ./test/clib
OK: ucs-test 09_ucr/50layer-priority
OK: UCS 3.2 Autotest MultiEnv
OK: ChangeLog
Comment 7 Stefan Gohmann univentionstaff 2013-11-19 06:41:18 CET
UCS 3.2 has been released:
 http://docs.univention.de/release-notes-3.2-en.html
 http://docs.univention.de/release-notes-3.2-de.html

If this error occurs again, please use "Clone This Bug".