Bad character encoding with NetworkManager backend
Bug #2071652 reported by
Glandos
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Netplan |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Ubuntu 23.10
netplan 0.107-5ubuntu0.3
network-manager 1.44.2-1ubuntu1.2
My WiFi network has a Latin1 character in it. It's managed by hostapd (by myself), so the character is UTF-8.
Previously, this was managed by NetworkManager just fine.
Now in netplan, the following happens:
- the password is saved with latin1 encoding, resulting in \xe9 in YAML files
- this encoding is not understood by NetworkManager, resulting in double encoding withing password field
- I have to re-enter the password each time the laptop goes out of sleep.
Changed in netplan: | |
status: | In Progress → Fix Committed |
To post a comment you must log in.
Hello, thank you for your bug report.
I managed to reproduce the issue and I'm testing a fix for that.
For our own reference, I'll add more details below:
The libyaml's emitter is converting valid utf-8 characters to latin1. In this case it's happening here https:/ /github. com/yaml/ libyaml/ blob/0. 2.5/src/ emitter. c#L2051.
Example:
The keyfile below:
--- 81e0-4f59- 99c4-6d55348d8c 46 name=wlan0
[connection]
id=Wi-Fi connection 1
uuid=f486322b-
type=wifi
interface-
[wifi] 161;195; 161;195; 161;195; 169;195; 169;195; 173;195; 173;195; 179;195; 179;195; 186;195; 186;195; 129;195; 137;195; 141;195; 147;195; 154;
mode=infrastructure
ssid=195;
[wifi-security] óóÚÚÁÉÍÓÚ
key-mgmt=wpa-psk
psk=Záááéééíííó
[ipv4]
method=auto
[ipv6] mode=stable- privacy
addr-gen-
method=auto
[proxy]
---
Will emit the YAML below:
--- f486322b- 81e0-4f59- 99c4-6d55348d8c 46: address- generation: "stable-privacy" points:
"195;161; 195;161; 195;161; 195;169; 195;169; 195;173; 195;173; 195;179; 195;179; 195;186; 195;186; 195;129; 195;137; 195;141; 195;147; 195;154; ":
key- management: "psk"
password: "Z\xE1\ xE1\xE1\ xE9\xE9\ xE9\xED\ xED\xED\ xF3\xF3\ xF3\xDA\ xDA\xC1\ xC9\xCD\ xD3\xDA"
networkmanag er: 81e0-4f59- 99c4-6d55348d8c 46"
passthroug h:
ipv6.ip6- privacy: "-1"
proxy._ : "" nager: 81e0-4f59- 99c4-6d55348d8c 46"
network:
version: 2
wifis:
NM-
renderer: NetworkManager
match:
name: "wlan0"
dhcp4: true
dhcp6: true
ipv6-
access-
auth:
uuid: "f486322b-
name: "Wi-Fi connection 1"
networkma
uuid: "f486322b-
name: "Wi-Fi connection 1"
---
The string in the "psk" field is valid latin1 encoded text:
>>> b"Z\xE1\ xE1\xE1\ xE9\xE9\ xE9\xED\ xED\xED\ xF3\xF3\ xF3\xDA\ xDA\xC1\ xC9\xCD\ xD3\xDA" .decode( 'latin1' ) ÚÁÉÍÓÚ'
'ZáááéééíííóóóÚ
Checking the libyaml function closely, one of the things it checks is if emitter->unicode is set.
This variable is documented as: /** Allow unescaped non-ASCII characters? */
The libyaml API has a function to set it: yaml_emitter_ set_unicode( emitter_ ptr, 1);
After using it in libnetplan, the YAML below is generated:
--- f486322b- 81e0-4f59- 99c4-6d55348d8c 46: address- generation: "stable-privacy" points:
"195;161; 195;161; 195;161; 195;169; 195;169; 195;173; 195;173; 195;179; 195;179; 195;186; 195;186; 195;129; 195;137; 195;141; 195;147; 195;154; ":
key- management: "psk"
password: "ZáááéééíííóóóÚ ÚÁÉÍÓÚ"
networkmanag er: 81e0-4f59- 99c4-6d55348d8c 46"
passthroug h:
ipv6.ip6- privacy: "-1"
proxy._ : "" nager: 81e0-4f59- 99
network:
version: 2
wifis:
NM-
renderer: NetworkManager
match:
name: "wlan0"
dhcp4: true
dhcp6: true
ipv6-
access-
auth:
uuid: "f486322b-
name: "Wi-Fi connection 1"
networkma
uuid: "f486322b-
---
I still need to prepare a patch and investigate if something will break with this change.