From e48c5d11fc59bb60739a67764bb24924c66dce31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Wed, 10 Feb 2021 14:58:40 +0200 Subject: [PATCH] MXS-3345: Create persistdir earlier The directory was created when the configuration was being processed and it wasn't checked unless it was configured to a non-default value. With the addition of the path validation, the directory must be created earlier. --- server/core/config.cc | 2 -- server/core/gateway.cc | 10 ++++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/server/core/config.cc b/server/core/config.cc index fa52c8271..b2416aac7 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -1436,9 +1436,7 @@ static bool config_load_and_process(const char* filename, bool (* process_config rval = config_load_dir(dir, &dcontext, &config_context); } - /** Create the persisted configuration directory if it doesn't exist */ const char* persist_cnf = get_config_persistdir(); - mxs_mkdir_all(persist_cnf, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); if (config_get_global_options()->load_persisted_configs && is_directory(persist_cnf) && contains_cnf_files(persist_cnf)) diff --git a/server/core/gateway.cc b/server/core/gateway.cc index 87b14ed9a..00bb8b535 100644 --- a/server/core/gateway.cc +++ b/server/core/gateway.cc @@ -1810,10 +1810,7 @@ int main(int argc, char** argv) break; case '?': - if (check_paths()) - { - usage(); - } + usage(); rc = EXIT_SUCCESS; goto return_main; @@ -2047,6 +2044,11 @@ int main(int argc, char** argv) goto return_main; } + // Try to create the persisted configuration directory. This needs to be done before the path validation + // done by check_paths() to prevent it from failing. The directory wont' exist if it's the first time + // MaxScale is starting up with this configuration. + mxs_mkdir_all(get_config_persistdir(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + if (!check_paths()) { rc = MAXSCALE_BADCONFIG;