From d6e4cdb45ab0c1cdf344b479664038e858fb397c Mon Sep 17 00:00:00 2001 From: mwiegand Date: Sat, 13 Nov 2021 15:57:29 +0100 Subject: [PATCH] case sensitive config parser --- bundles/nextcloud/metadata.py | 10 +++++----- libs/ini.py | 26 ++++++++++++++++---------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/bundles/nextcloud/metadata.py b/bundles/nextcloud/metadata.py index 19258ab..b677d0a 100644 --- a/bundles/nextcloud/metadata.py +++ b/bundles/nextcloud/metadata.py @@ -44,11 +44,11 @@ defaults = { 'php': { 'post_max_size': '32G', 'www.conf': { - 'env[hostname]': '$HOSTNAME', - 'env[path]': '/usr/local/bin:/usr/bin:/bin', - 'env[tmp]': '/tmp', - 'env[tmpdir]': '/tmp', - 'env[temp]': '/tmp', + 'env[HOSTNAME]': '$HOSTNAME', + 'env[PATH]': '/usr/local/bin:/usr/bin:/bin', + 'env[TMP]': '/tmp', + 'env[TMPDIR]': '/tmp', + 'env[TEMP]': '/tmp', }, }, 'postgresql': { diff --git a/libs/ini.py b/libs/ini.py index 902f305..e94b3e2 100644 --- a/libs/ini.py +++ b/libs/ini.py @@ -1,8 +1,18 @@ from configparser import ConfigParser import json +class Writable(): + data = '' + def write(self, line): + self.data += line + +class CaseSensitiveConfigParser(ConfigParser): + # dont make keys lowercase + def optionxform(self, value): + return value + def parse(text): - config = ConfigParser() + config = CaseSensitiveConfigParser() config.read_string(text) return { @@ -10,17 +20,13 @@ def parse(text): for section in config.sections() } -class Writable(): - data = '' - - def write(self, line): - self.data += line - def dumps(dict): - config = ConfigParser() sorted_dict = json.loads(json.dumps(dict, sort_keys=True)) - config.read_dict(sorted_dict) + + parser = CaseSensitiveConfigParser() + parser.read_dict(sorted_dict) + writable = Writable() - config.write(writable) + parser.write(writable) return writable.data