From 80ef6e6755748c8c289baf3b5b49894653cabfb8 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Wed, 15 May 2024 17:47:21 +0100 Subject: [PATCH 1/2] Correct logic for DEFAULT config population Fixes https://github.com/matrix-org/sydent/issues/585 --- sydent/config/__init__.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sydent/config/__init__.py b/sydent/config/__init__.py index f3c78680..a7fd7cbd 100644 --- a/sydent/config/__init__.py +++ b/sydent/config/__init__.py @@ -219,14 +219,15 @@ def parse_config_file(self, config_file: str) -> None: :param config_file: the file to be parsed """ - # If the config file doesn't exist, prepopulate the config object - # with the defaults, in the right section. + # If the config file already exists, place all config options in + # the DEFAULT section, to avoid overriding any of the user's + # configured values in the sections other than DEFAULT. # - # Otherwise, we have to put the defaults in the DEFAULT section, - # to ensure that they don't override anyone's settings which are - # in their config file in the default section (which is likely, - # because sydent used to be braindead). - use_defaults = not os.path.exists(config_file) + # We don't always do this as earlier Sydent versions required + # users to put their settings in the DEFAULT section. + # + # We want to avoid overwriting those. + use_defaults = os.path.exists(config_file) cfg = ConfigParser() for sect, entries in CONFIG_DEFAULTS.items(): From d6d64055895c4d6a1c1b5004f2de623e254ec0a5 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Wed, 15 May 2024 17:48:34 +0100 Subject: [PATCH 2/2] changelog --- changelog.d/590.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/590.bugfix diff --git a/changelog.d/590.bugfix b/changelog.d/590.bugfix new file mode 100644 index 00000000..f5aff74f --- /dev/null +++ b/changelog.d/590.bugfix @@ -0,0 +1 @@ +Prevent Sydent from overwriting user settings in the DEFAULT section upon startup. \ No newline at end of file