[networkcfg] NetworkManager files are UTF-8 encoded
The filenames don't matter, but the contents of the file are also UTF-8, and depending on the default encoding of the Python interpreter, this can fail on non-ASCII characters in the file. Set the encoding explicitly while reading and writing the NetworkManager configuration files. FIXES #1848
This commit is contained in:
parent
db86c24638
commit
132ebd2c2d
@ -73,12 +73,12 @@ def replace_username(nm_config_filename, live_user, target_user):
|
||||
if not os.path.exists(nm_config_filename):
|
||||
return
|
||||
|
||||
with open(nm_config_filename, "r") as network_conf:
|
||||
with open(nm_config_filename, "r", encoding="UTF-8") as network_conf:
|
||||
text = network_conf.readlines()
|
||||
|
||||
live_permissions = 'permissions=user:{}:;'.format(live_user)
|
||||
target_permissions = 'permissions=user:{}:;\n'.format(target_user)
|
||||
with open(nm_config_filename, "w") as network_conf:
|
||||
with open(nm_config_filename, "w", encoding="UTF-8") as network_conf:
|
||||
for line in text:
|
||||
if live_permissions in line:
|
||||
line = target_permissions
|
||||
|
Loading…
Reference in New Issue
Block a user