Seite 1 von 1

Encoding

Verfasst: 13 Apr 2018, 12:49
von thomas.besser
Hi,

eigentlich wollte ich ein Problem beim Patchen einer INI-Datei melden, die im Format "UCS-2LE" (https://download.uib.de/opsi4.0/doc/htm ... t-encoding) vorliegt. Allerdings scheint das Problem viel tiefgreifender zu liegen.

Folgendes äußerst simple Skript funktioniert bei mir nicht bzw. gibt im Log keinen Eintrag "Test" aus:

Code: Alles auswählen

[Actions]
encoding=ucs2le
comment "Test"
Ergibt (gekürzter und anonymisierter Auszug):

Code: Alles auswählen

[1] [Apr 13 12:17:38:882] [test_encoding] ============ Version 4.12.0.15 script "p:\test_encoding\setup.opsiscript"
[1] [Apr 13 12:17:38:883] [test_encoding]              used script encoding: ucs2le
[1] [Apr 13 12:17:38:883] [test_encoding]              used system encoding: cp1252
[1] [Apr 13 12:17:38:883] [test_encoding]              start: 2018-04-13  12:17:38 
[1] [Apr 13 12:17:38:883] [test_encoding]              installing product: test_encoding_1.0-1
[1] [Apr 13 12:17:38:883] [test_encoding]              on client named    "test.example.com"
[1] [Apr 13 12:17:38:883] [test_encoding]              loggedin user    ""
[1] [Apr 13 12:17:38:884] [test_encoding]              opsi-script running as    "SYSTEM"
[1] [Apr 13 12:17:38:884] [test_encoding]              opsi-script running with admin privileges
[1] [Apr 13 12:17:38:884] [test_encoding]              opsi-script running in standard script mode
[1] [Apr 13 12:17:38:884] [test_encoding] executing: "C:\Program Files (x86)\opsi.org\opsi-client-agent\opsi-winst\winst32.exe"
[1] [Apr 13 12:17:38:884] [test_encoding] system infos:
[1] [Apr 13 12:17:38:897] [test_encoding] 00-00-00-00-00-00  -  PC hardware address
[1] [Apr 13 12:17:38:897] [test_encoding] test.example.com  -  IP name 
[1] [Apr 13 12:17:38:897] [test_encoding] 192.168.0.1  -  IP address
[1] [Apr 13 12:17:38:897] [test_encoding] DEU  -  System default locale 
[7] [Apr 13 12:17:38:897] [test_encoding] Registry started readonly
[7] [Apr 13 12:17:38:897] [test_encoding] Registry started without redirection (64 Bit)
[6] [Apr 13 12:17:38:897] [test_encoding] Registry key [HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion]  opened
[6] [Apr 13 12:17:38:897] [test_encoding] Key closed
[1] [Apr 13 12:17:38:902] [test_encoding] MS Windows 10.0 64 Bit, Release: 1607, Edition: Windows Enterprise 2015 LTSB
[1] [Apr 13 12:17:38:902] [test_encoding] opsi service version : 4
[1] [Apr 13 12:17:38:902] [test_encoding] 
[7] [Apr 13 12:17:38:908] [test_encoding] Registry started readonly
[7] [Apr 13 12:17:38:908] [test_encoding] Registry started without redirection (64 Bit)
[6] [Apr 13 12:17:38:909] [test_encoding] Registry key [HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion]  opened
[6] [Apr 13 12:17:38:910] [test_encoding] Key closed
[1] [Apr 13 12:17:39:067] [test_encoding] ___________________
[1] [Apr 13 12:17:39:067] [test_encoding] script finished: success
[1] [Apr 13 12:17:39:067] [test_encoding] 0 errors
[1] [Apr 13 12:17:39:067] [test_encoding] 0 warnings
[1] [Apr 13 12:17:39:067] [test_encoding] 
[1] [Apr 13 12:17:39:068] [test_encoding] installed product: test_encoding Version: 1.0-1
Kommentiere ich die Zeile "encoding=ucs2le" aus, ist alles wie erwartet:

Code: Alles auswählen

[1] [Apr 13 12:15:48:795] [test_encoding] ============ Version 4.12.0.15 script "p:\test_encoding\setup.opsiscript"
[1] [Apr 13 12:15:48:795] [test_encoding]              used script encoding: cp1252
[1] [Apr 13 12:15:48:796] [test_encoding]              used system encoding: cp1252
[1] [Apr 13 12:15:48:796] [test_encoding]              start: 2018-04-13  12:15:48 
[1] [Apr 13 12:15:48:796] [test_encoding]              installing product: test_encoding_1.0-1
[1] [Apr 13 12:15:48:796] [test_encoding]              on client named    "test.example.com"
[1] [Apr 13 12:15:48:796] [test_encoding]              loggedin user    ""
[1] [Apr 13 12:15:48:797] [test_encoding]              opsi-script running as    "SYSTEM"
[1] [Apr 13 12:15:48:797] [test_encoding]              opsi-script running with admin privileges
[1] [Apr 13 12:15:48:797] [test_encoding]              opsi-script running in standard script mode
[1] [Apr 13 12:15:48:797] [test_encoding] executing: "C:\Program Files (x86)\opsi.org\opsi-client-agent\opsi-winst\winst32.exe"
[1] [Apr 13 12:15:48:797] [test_encoding] system infos:
[1] [Apr 13 12:15:48:807] [test_encoding] 00-00-00-00-00-00  -  PC hardware address
[1] [Apr 13 12:15:48:807] [test_encoding] test.example.com  -  IP name 
[1] [Apr 13 12:15:48:807] [test_encoding] 192.168.0.1  -  IP address
[1] [Apr 13 12:15:48:807] [test_encoding] DEU  -  System default locale 
[7] [Apr 13 12:15:48:807] [test_encoding] Registry started readonly
[7] [Apr 13 12:15:48:807] [test_encoding] Registry started without redirection (64 Bit)
[6] [Apr 13 12:15:48:807] [test_encoding] Registry key [HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion]  opened
[6] [Apr 13 12:15:48:807] [test_encoding] Key closed
[1] [Apr 13 12:15:48:807] [test_encoding] MS Windows 10.0 64 Bit, Release: 1607, Edition: Windows Enterprise 2015 LTSB
[1] [Apr 13 12:15:48:807] [test_encoding] opsi service version : 4
[1] [Apr 13 12:15:48:807] [test_encoding] 
[7] [Apr 13 12:15:48:812] [test_encoding] Registry started readonly
[7] [Apr 13 12:15:48:812] [test_encoding] Registry started without redirection (64 Bit)
[6] [Apr 13 12:15:48:812] [test_encoding] Registry key [HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion]  opened
[6] [Apr 13 12:15:48:812] [test_encoding] Key closed
[5] [Apr 13 12:15:48:977] [test_encoding] comment: Test
[1] [Apr 13 12:15:48:977] [test_encoding] ___________________
[1] [Apr 13 12:15:48:977] [test_encoding] script finished: success
[1] [Apr 13 12:15:48:977] [test_encoding] 0 errors
[1] [Apr 13 12:15:48:977] [test_encoding] 0 warnings
[1] [Apr 13 12:15:48:977] [test_encoding] 
[1] [Apr 13 12:15:48:977] [test_encoding] installed product: test_encoding Version: 1.0-1
OPSI-Server 4.0 Testing-Zweig:

Code: Alles auswählen

dpkg -l "opsi*" | grep ii
ii  opsi-atftpd             0.7.dfsg-7   amd64        advanced TFTP server - opsi version with pcre, fifo and max-blksize patches
ii  opsi-configed           4.0.7.6.34-2 all          OPSI config editor
ii  opsi-depotserver        4.0.7.3-3    all          opsi depotserver configuration package
ii  opsi-linux-bootimage    20171012-1   amd64        opsi bootimage for netboot tasks.
ii  opsi-utils              4.0.7.18-7   all          utilites for working with opsi.
ii  opsiconfd               4.0.7.14-2   all          opsi configuration service
ii  opsipxeconfd            4.0.7.9-2    all          opsi pxe configuration daemon
Bug oder Denkfehler bei mir?

Gruß
Thomas

Re: Encoding

Verfasst: 16 Apr 2018, 10:52
von d.oertel
Hallo,

die Zeile
encoding=<encoding>
gibt das encoding des scriptes an. (wenn diese nicht enthalten ist wird das system encoding vermutet).
Dies dient dazu Um Umlaute im Script richtig zu verwenden.
Wird das Script:

Code: Alles auswählen

[Actions]
encoding=utf8
comment "Test üöäß"
Mit dem Encoding utf8 abgespeichert so gibt das log

Code: Alles auswählen

============ Version 4.12.0.17 script "C:\temp\try.opsiscript"
             used script encoding: utf8
             used system encoding: cp1252
             start: 2018-04-16  10:41:21 
             on client named    "PCBON4"
             loggedin user    "oertel"
(....)
Registry started readonly
Registry started without redirection (64 Bit)
Registry key [HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion]  opened
Key closed
comment: Test üöäß
___________________
script finished: success
0 errors
0 warnings
Hier gibt es aber in der Tat einen Bug mit der Verwendung von 16 + 32 Bit Unicode Varianten.

Das eigentlich adressierte Problem - das Handling von Inidateien im Unicodeformat ließe sich hierdurch aber sowieso nicht lösen.
Hier brauchen wir die Möglichkeit beim Aufruf der entsperechenden Funktionen / Sektionen zum Lesen und schreiben einer INI Datei das Encoding der Datei anzugeben.
Das liegt seit längerem auf meiner todo Liste, da es sich im ersten Versuch als nicht ganz trivial heraus gestellt hat.

Ich hoffe für brides demnächst einen Fix anbieten zu können.

gruß
d.oertel

Re: Encoding

Verfasst: 15 Apr 2021, 16:06
von thomas.besser
Hallo Detlef,

ich denke viewtopic.php?f=10&t=12241&p=53133&hili ... ing#p53133 könnte das jetzt möglich machen!?

Ich werde es die Tage testen und Feedback geben.

Danke und Gruß
Thomas