public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Matt Turner" <mattst88@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/catalyst:master commit in: catalyst/, catalyst/base/
Date: Sat, 14 Nov 2020 16:37:29 +0000 (UTC)	[thread overview]
Message-ID: <1605371697.b556ff31b8d4caaef6c0e7612a70f5f0c397b02c.mattst88@gentoo> (raw)
Message-ID: <20201114163729.FbkxyRHZ_I0_EN-mW5tbKrG9N5rviQDpNV-kaH9F0yY@z> (raw)

commit:     b556ff31b8d4caaef6c0e7612a70f5f0c397b02c
Author:     Felix Bier <Felix.Bier <AT> rohde-schwarz <DOT> com>
AuthorDate: Tue Nov 10 00:59:01 2020 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> 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 <felix.bier <AT> rohde-schwarz.com>
Signed-off-by: Matt Turner <mattst88 <AT> 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():


             reply	other threads:[~2020-11-14 16:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-19 19:56 Matt Turner [this message]
2020-11-14 16:37 ` [gentoo-commits] proj/catalyst:master commit in: catalyst/, catalyst/base/ Matt Turner
  -- strict thread matches above, loose matches on Subject: below --
2021-06-10  0:48 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
2021-01-18 19:53 [gentoo-commits] proj/catalyst:pending/mattst88 " Matt Turner
2020-12-19 19:56 ` [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
2020-05-27  6:22 Matt Turner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1605371697.b556ff31b8d4caaef6c0e7612a70f5f0c397b02c.mattst88@gentoo \
    --to=mattst88@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox