Bug 23753 - UCR Werte entsprechend der locale kodieren
UCR Werte entsprechend der locale kodieren
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UCR
UCS 3.0
Other Linux
: P5 enhancement (vote)
: UCS 3.0 - RC
Assigned To: Janek Walkenhorst
Felix Botner
:
Depends on: 18006
Blocks:
  Show dependency treegraph
 
Reported: 2011-09-21 18:19 CEST by Janek Walkenhorst
Modified: 2011-12-13 15:50 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

Note You need to log in before you can comment on or make changes to this bug.
Description Janek Walkenhorst univentionstaff 2011-09-21 18:19:44 CEST
UCR könnte übergebene Werte nach den Regeln der Locale (LC_CTYPE) dekodieren und dann UTF-8 kodiert in die base.conf schreiben.
Analog beim Ausgeben.

(Siehe Bug #18006)
Comment 1 Janek Walkenhorst univentionstaff 2011-10-11 10:31:02 CEST
UCR versucht jetzt die Eingaben als UTF-8 zu dekodieren, und wenn dies fehlschlägt wird versucht anhand der locale zu dekodieren.

univention-config-registry (7.0.23-1)
Comment 2 Janek Walkenhorst univentionstaff 2011-10-11 10:40:45 CEST
Changelog angepasst
Comment 3 Stefan Gohmann univentionstaff 2011-10-21 12:01:06 CEST
Philipp ist folgendes aufgefallen, das kann beim Update auftreten, wenn locale-gen noch nicht lief:

root@master121:~# ucr set foo=bar
Setting foo
root@master121:~# LC_ALL=fr_FR ucr set foo=bar
Traceback (most recent call last):
  File "/usr/sbin/ucr", line 65, in <module>
    ub.main(convertToUtf8(sys.argv[1:]))
  File "/usr/sbin/ucr", line 48, in convertToUtf8
    locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib/python2.6/locale.py", line 513, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting
root@master121:~#

Ich habe jetzt einen einfachen Workaround eingebaut und setze LC_ALL auf C. @Janek bitte prüfen und anpassen.
Comment 4 Janek Walkenhorst univentionstaff 2011-10-25 18:16:39 CEST
Die Funktion locale.getpreferredencoding() macht keine Probleme.

univention-config-registry (7.0.27-1) unstable; urgency=low

  * fix traceback with wrong locale setting (Bug #23753)
Comment 5 Felix Botner univentionstaff 2011-11-07 17:45:53 CET
FAILED -  Vielleicht kann man für ucr/encoding/strict noch ein UCR Beschreibung hinzufügen

OK - nicht konvertierbare nicht UTF-8 Zeichen werden nicht gesetzt

# reines UTF-8 System, das Zeichen hinter a= ist latin1
ucr set a=ä
Setting a
Error: UCR is running in strict mode and thus cannot accept the given input:
value is not UTF-8 encoded


OK - nicht vorhandene locale führt nicht zum Fehler

-> ucr get locale/default
locale/default: de_DE:ISO-8859-1
# locale.getpreferredencoding() wird in /usr/sbin/ucr ausgegeben
ucr set a=a
ISO-8859-1
Setting a
-> LC_ALL=de_DE.UTF-8 ucr set a=a
UTF-8
Setting a
-> LC_ALL=de_DE.UTF-8sdsdsadsa ucr set a=a
ANSI_X3.4-1968
Setting a

OK - Werte mit der Systemkodierung (!= UTF-8) werden in UTF-8 umgewandelt

# iso latin1
-> ucr set a=öööö
Setting a
-> ucr get a
öööö
root@master:~# file /etc/univention/base.conf
/etc/univention/base.conf: UTF-8 Unicode text, with very long lines

OK - wenn ucr/encoding/strict nicht gesetzt ist, kann ein nicht UTF-8 Zeichen
in der base.conf gesetzt werden

LC_ALL=asadsdf ucr set a=ö
Create a
->  file /etc/univention/base.conf
/etc/univention/base.conf: ISO-8859 text, with very long lines

OK - Update -> ucr/encoding/strict nicht gesetzt
     Installation -> ucr/encoding/strict auf true
Comment 6 Janek Walkenhorst univentionstaff 2011-11-08 13:47:05 CET
(In reply to comment #5)
> FAILED -  Vielleicht kann man für ucr/encoding/strict noch ein UCR Beschreibung
> hinzufügen
Es gibt keine Beschreibung, weil diese Variable nicht einfach so geändert werden soll.
Comment 7 Felix Botner univentionstaff 2011-11-08 15:27:55 CET
(In reply to comment #6)
> (In reply to comment #5)
> > FAILED -  Vielleicht kann man für ucr/encoding/strict noch ein UCR Beschreibung
> > hinzufügen
> Es gibt keine Beschreibung, weil diese Variable nicht einfach so geändert
> werden soll.

OK, dann zu.
Comment 8 Sönke Schwardt-Krummrich univentionstaff 2011-12-13 15:50:14 CET
UCS 3.0-0 wurde veröffentlicht. Sollte der hier beschriebene Bug mit einer
neueren Version von UCS erneut auftreten, so sollte dieser Bug dupliziert
werden: "Clone This Bug"