From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 8C4B4138359 for ; Sat, 14 Nov 2020 16:37:33 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C0513E0391; Sat, 14 Nov 2020 16:37:32 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 9A869E0391 for ; Sat, 14 Nov 2020 16:37:32 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 654D33410F1 for ; Sat, 14 Nov 2020 16:37:31 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A89A744C for ; Sat, 14 Nov 2020 16:37:29 +0000 (UTC) From: "Matt Turner" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Turner" Message-ID: <1605371697.b556ff31b8d4caaef6c0e7612a70f5f0c397b02c.mattst88@gentoo> Subject: [gentoo-commits] proj/catalyst:master commit in: catalyst/, catalyst/base/ X-VCS-Repository: proj/catalyst X-VCS-Files: catalyst/base/stagebase.py catalyst/main.py X-VCS-Directories: catalyst/ catalyst/base/ X-VCS-Committer: mattst88 X-VCS-Committer-Name: Matt Turner X-VCS-Revision: b556ff31b8d4caaef6c0e7612a70f5f0c397b02c X-VCS-Branch: master Date: Sat, 14 Nov 2020 16:37:29 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: e4e52634-4949-4078-a6b7-5049dd742569 X-Archives-Hash: 6c1a577c7fbe97988243b0730786279c Message-ID: <20201114163729.FbkxyRHZ_I0_EN-mW5tbKrG9N5rviQDpNV-kaH9F0yY@z> commit: b556ff31b8d4caaef6c0e7612a70f5f0c397b02c Author: Felix Bier rohde-schwarz com> AuthorDate: Tue Nov 10 00:59:01 2020 +0000 Commit: Matt Turner gentoo org> CommitDate: Sat Nov 14 16:34:57 2020 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=b556ff31 Ensure deep copying of config defaults This commit adds deep copying operations when initializing config objects from a default config. This prevents the config from being a shallow copy of the default, ensuring that modifications to the config do not modify the default. In particular, this fixes a check in write_make_conf, where the PORTDIR variable is supposed to be only written to the generated make.conf when a non-default repo_basedir is set in /etc/catalyst/catalyst.conf. This check is never satisfied, because confvalues is a shallow copy of confdefaults, therefore both will always hold the same value for repo_basedir. For self.mounts / MOUNT_DEFAULTS this problem can also be observed, the modifications done to self.mounts are also visible in MOUNT_DEFAULTS. I am not aware of any bugs due to this shallow copy, but I would prefer adding a deep copy to prevent future bugs, in case a comparision against the default mounts is ever needed. Signed-off-by: Felix Bier rohde-schwarz.com> Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 3 ++- catalyst/main.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index a75dbdf9..21cf96a0 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -1,4 +1,5 @@ +import copy import os import platform import shutil @@ -187,7 +188,7 @@ class StageBase(TargetBase, ClearBase, GenBase): file_locate(self.settings, ["portage_confdir"], expand=0) # Setup our mount points. - self.mount = MOUNT_DEFAULTS.copy() + self.mount = copy.deepcopy(MOUNT_DEFAULTS) self.mount['portdir']['source'] = self.snapshot self.mount['portdir']['target'] = self.settings['repo_basedir'] + '/' + self.settings['repo_name'] diff --git a/catalyst/main.py b/catalyst/main.py index 5536471a..48daf004 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -1,4 +1,5 @@ import argparse +import copy import datetime import hashlib import os @@ -19,7 +20,7 @@ from catalyst.defaults import (confdefaults, option_messages, from catalyst.support import CatalystError from catalyst.version import get_version -conf_values = confdefaults +conf_values = copy.deepcopy(confdefaults) def version():