From fe73bb57a50d96a08457bf654419c4ca05115fd2 Mon Sep 17 00:00:00 2001 From: Olivier Leger Date: Thu, 28 Apr 2022 09:30:35 -0400 Subject: [PATCH 1/2] Treat PostgreSQL password validation apart --- helpers/config.py | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/helpers/config.py b/helpers/config.py index 90ce9e1..b5d4d7b 100644 --- a/helpers/config.py +++ b/helpers/config.py @@ -616,28 +616,36 @@ def validate_passwords(self): }, } errors = [] + psql_replication = passwords.pop('PostgreSQL replication') for label, config_ in passwords.items(): if not re.match(config_['pattern'], config_['password']): errors.append(label) CLI.colored_print( f'{label} password contains unsupported characters.', - CLI.COLOR_WARNING + CLI.COLOR_ERROR ) if errors: - CLI.colored_print( - 'You should run `python run.py --setup` to update.', - CLI.COLOR_ERROR - ) - # PostgreSQL replication password is set in PostgreSQL on the first - # launch and nothing is run afterwards in subsequent starts to update - # it if it has changed. - if 'PostgreSQL replication' in errors: CLI.colored_print( - 'PostgreSQL replication password must be changed manually\n' - 'in `kobo-install/.run.conf` and PostgreSQL itself.', + 'You should run `python run.py --setup` to update.', CLI.COLOR_WARNING ) + # PostgreSQL replication password must be handled separately because + # it is set in PostgreSQL on the first launch and nothing is done + # afterwards in subsequent starts to update it if it has changed. + if not re.match( + psql_replication['pattern'], psql_replication['password'] + ): + CLI.colored_print( + 'PostgreSQL replication password contains unsupported characters.', + CLI.COLOR_ERROR + ) + CLI.colored_print( + 'It must be changed manually in `kobo-install/.run.conf` ' + '(and PostgreSQL itself if you use replication).', + CLI.COLOR_WARNING + ) + def write_config(self): """ Writes config to file `Config.CONFIG_FILE`. From b321a40874ac59ff9118602e6354ed1f169ffdc5 Mon Sep 17 00:00:00 2001 From: Olivier Leger Date: Tue, 10 May 2022 13:47:46 -0400 Subject: [PATCH 2/2] Remove over-ident --- helpers/config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/helpers/config.py b/helpers/config.py index b5d4d7b..941a436 100644 --- a/helpers/config.py +++ b/helpers/config.py @@ -625,10 +625,10 @@ def validate_passwords(self): CLI.COLOR_ERROR ) if errors: - CLI.colored_print( - 'You should run `python run.py --setup` to update.', - CLI.COLOR_WARNING - ) + CLI.colored_print( + 'You should run `python run.py --setup` to update.', + CLI.COLOR_WARNING + ) # PostgreSQL replication password must be handled separately because # it is set in PostgreSQL on the first launch and nothing is done