1
0
mirror of synced 2025-04-19 11:02:15 +03:00

Correct logic for DEFAULT config section population (#590)

This commit is contained in:
Andrew Morgan 2024-05-17 10:26:43 +01:00 committed by GitHub
parent fdde810deb
commit a37d60bd8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 7 deletions

1
changelog.d/590.bugfix Normal file
View File

@ -0,0 +1 @@
Prevent Sydent from overwriting user settings in the DEFAULT section upon startup.

View File

@ -219,14 +219,15 @@ class SydentConfig:
: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():