From 8913317a44e0a81a9a208ae71b52268005ec7a9a Mon Sep 17 00:00:00 2001 From: demmm Date: Mon, 16 Aug 2021 14:06:13 +0200 Subject: [PATCH] [networkcfg] add setting the correct target user in copied file see https://github.com/calamares/calamares/issues/1753 --- src/modules/networkcfg/main.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/modules/networkcfg/main.py b/src/modules/networkcfg/main.py index 40d153031..cc6c394fe 100644 --- a/src/modules/networkcfg/main.py +++ b/src/modules/networkcfg/main.py @@ -7,6 +7,7 @@ # SPDX-FileCopyrightText: 2014 Teo Mrnjavac # SPDX-FileCopyrightText: 2017 Alf Gaida # SPDX-FileCopyrightText: 2019 Adriaan de Groot +# SPDX-FileCopyrightText: 2021 Anke boersma # SPDX-License-Identifier: GPL-3.0-or-later # # Calamares is Free Software: see the License-Identifier above. @@ -14,6 +15,7 @@ import os import shutil +import getpass import libcalamares @@ -33,6 +35,8 @@ def run(): Setup network configuration """ root_mount_point = libcalamares.globalstorage.value("rootMountPoint") + user = libcalamares.globalstorage.value("username") + live_user = getpass.getuser() if root_mount_point is None: libcalamares.utils.warning("rootMountPoint is empty, {!s}".format(root_mount_point)) @@ -60,6 +64,16 @@ def run(): try: shutil.copy(source_network, target_network, follow_symlinks=False) + if live_user in open(target_network).read(): + text = [] + with open(target_network, "r") as network_conf: + text = network_conf.readlines() + with open(target_network, "w") as network_conf: + for line in text: + if 'permissions=user:{}:;'.format(live_user) in line: + line = 'permissions=user:{}:;\n'.format(user) + network_conf.write(line) + network_conf.close() except FileNotFoundError: libcalamares.utils.debug( "Can't copy network configuration files in "