1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-19 21:30:10 +01:00

Fix parsing of smartcardoptions config

With the previous code, a trailing newline would result in an empty
space being part of the list. When this is passed to keytool, it fails
with "Illegal option: ".

Instead of doing overly complicated regex based string substitution
followed by parametrized splitting, we can simply use `.split()`
without any parameters, and Python will automatically strip any
whitespace.
This commit is contained in:
Danilo Bargen 2022-04-19 17:42:26 +02:00 committed by Hans-Christoph Steiner
parent 05e6c293c0
commit a4d0698628

View File

@ -385,7 +385,8 @@ def read_config(opts=None):
# smartcardoptions must be a list since its command line args for Popen # smartcardoptions must be a list since its command line args for Popen
smartcardoptions = config.get('smartcardoptions') smartcardoptions = config.get('smartcardoptions')
if isinstance(smartcardoptions, str): if isinstance(smartcardoptions, str):
config['smartcardoptions'] = re.sub(r'\s+', r' ', config['smartcardoptions']).split(' ') options = re.sub(r'\s+', r' ', config['smartcardoptions']).split(' ')
config['smartcardoptions'] = [i.strip() for i in options if i]
elif not smartcardoptions and 'keystore' in config and config['keystore'] == 'NONE': elif not smartcardoptions and 'keystore' in config and config['keystore'] == 'NONE':
# keystore='NONE' means use smartcard, these are required defaults # keystore='NONE' means use smartcard, these are required defaults
config['smartcardoptions'] = ['-storetype', 'PKCS11', '-providerName', config['smartcardoptions'] = ['-storetype', 'PKCS11', '-providerName',