From 086cc8602d7f9d7837eb2307819f3ed1fd5dc3bb Mon Sep 17 00:00:00 2001 From: BeefSteak Date: Mon, 17 Oct 2022 16:03:30 +0100 Subject: [PATCH] Revert "fix(CORE/dbupdate)): allow to pass MySQL password via env (#13404)" This reverts commit c855e8d227a73b8328fb3d0a7a9eb99347a60738. --- .devcontainer/devcontainer.json | 11 ++++++----- .github/workflows/core_build.yml | 4 +--- .github/workflows/core_matrix_build.yml | 4 +--- src/common/Utilities/StartProcess.cpp | 21 ++++++++++----------- src/common/Utilities/StartProcess.h | 5 ++--- src/server/database/Updater/DBUpdater.cpp | 10 ++++------ 6 files changed, 24 insertions(+), 31 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 15221f1aa5..ed955ab619 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,11 +3,12 @@ "name": "ac-dev-server", // Update the 'dockerComposeFile' list if you have more compose files or use different names. - // set an empty array to automatically solve - // the docker-compose files (including the .override.yml) - // https://github.com/microsoft/vscode-remote-release/issues/1080#issuecomment-824213014 - // it requires vscode 1.57+ - "dockerComposeFile": [], + // The .devcontainer/docker-compose.yml file contains any overrides you need/want to make. + "dockerComposeFile": [ + "../docker-compose.yml", + "../docker-compose.override.yml", // needed until this issue will be solved: https://github.com/microsoft/vscode-remote-release/issues/1080 + "docker-compose.yml" + ], // The 'service' property is the name of the service for the container that VS Code should // use. Update this value and .devcontainer/docker-compose.yml to the real service name. "service": "ac-dev-server", diff --git a/.github/workflows/core_build.yml b/.github/workflows/core_build.yml index 7c43a1bb7c..93cad079dd 100644 --- a/.github/workflows/core_build.yml +++ b/.github/workflows/core_build.yml @@ -42,9 +42,7 @@ jobs: run: bash bin/acore-db-pendings - name: Build run: source ./apps/ci/ci-compile.sh - - name: Dry run authserver - run: source ./apps/ci/ci-dry-run.sh authserver - - name: Dry run worldserver + - name: Dry run run: source ./apps/ci/ci-dry-run.sh worldserver - name: Check startup errors run: source ./apps/ci/ci-error-check.sh diff --git a/.github/workflows/core_matrix_build.yml b/.github/workflows/core_matrix_build.yml index a0f4d47f93..5852c6c17b 100644 --- a/.github/workflows/core_matrix_build.yml +++ b/.github/workflows/core_matrix_build.yml @@ -50,9 +50,7 @@ jobs: run: bash bin/acore-db-pendings - name: Build run: source ./apps/ci/ci-compile.sh - - name: Dry run authserver - run: source ./apps/ci/ci-dry-run.sh authserver - - name: Dry run worldserver + - name: Dry run run: source ./apps/ci/ci-dry-run.sh worldserver - name: Check startup errors run: source ./apps/ci/ci-error-check.sh diff --git a/src/common/Utilities/StartProcess.cpp b/src/common/Utilities/StartProcess.cpp index 1da7817f41..7fbe053a8d 100644 --- a/src/common/Utilities/StartProcess.cpp +++ b/src/common/Utilities/StartProcess.cpp @@ -70,7 +70,7 @@ namespace Acore static int CreateChildProcess(T waiter, std::string const& executable, std::vector const& argsVector, std::string const& logger, std::string const& input, - bool secure, boost::process::environment envVariables = boost::this_process::environment()) + bool secure) { ipstream outStream; ipstream errStream; @@ -97,7 +97,7 @@ namespace Acore return child{ exe = std::filesystem::absolute(executable).string(), args = argsVector, - env = environment(envVariables), + env = environment(boost::this_process::environment()), std_in = inputFile.get(), std_out = outStream, std_err = errStream @@ -109,7 +109,7 @@ namespace Acore return child{ exe = std::filesystem::absolute(executable).string(), args = argsVector, - env = environment(envVariables), + env = environment(boost::this_process::environment()), std_in = boost::process::close, std_out = outStream, std_err = errStream @@ -144,7 +144,7 @@ namespace Acore } int StartProcess(std::string const& executable, std::vector const& args, - std::string const& logger, std::string input_file, bool secure, boost::process::environment env) + std::string const& logger, std::string input_file, bool secure) { return CreateChildProcess([](child& c) -> int { @@ -157,7 +157,7 @@ namespace Acore { return EXIT_FAILURE; } - }, executable, args, logger, input_file, secure, env); + }, executable, args, logger, input_file, secure); } class AsyncProcessResultImplementation @@ -168,7 +168,6 @@ namespace Acore std::string const logger; std::string const input_file; bool const is_secure; - boost::process::environment envVariables; std::atomic was_terminated; @@ -178,10 +177,10 @@ namespace Acore public: explicit AsyncProcessResultImplementation(std::string executable_, std::vector args_, std::string logger_, std::string input_file_, - bool secure, boost::process::environment env) + bool secure) : executable(std::move(executable_)), args(std::move(args_)), logger(std::move(logger_)), input_file(input_file_), - is_secure(secure), envVariables(env), was_terminated(false) { } + is_secure(secure), was_terminated(false) { } AsyncProcessResultImplementation(AsyncProcessResultImplementation const&) = delete; AsyncProcessResultImplementation& operator= (AsyncProcessResultImplementation const&) = delete; @@ -210,7 +209,7 @@ namespace Acore my_child.reset(); return was_terminated ? EXIT_FAILURE : exitCode; - }, executable, args, logger, input_file, is_secure, envVariables); + }, executable, args, logger, input_file, is_secure); } void SetFuture(std::future result_) @@ -246,10 +245,10 @@ namespace Acore std::shared_ptr StartAsyncProcess(std::string executable, std::vector args, - std::string logger, std::string input_file, bool secure, boost::process::native_environment env) + std::string logger, std::string input_file, bool secure) { auto handle = std::make_shared( - std::move(executable), std::move(args), std::move(logger), std::move(input_file), secure, env); + std::move(executable), std::move(args), std::move(logger), std::move(input_file), secure); handle->SetFuture(std::async(std::launch::async, [handle] { return handle->StartProcess(); })); return handle; diff --git a/src/common/Utilities/StartProcess.h b/src/common/Utilities/StartProcess.h index f0d5d97818..6b564cb9e1 100644 --- a/src/common/Utilities/StartProcess.h +++ b/src/common/Utilities/StartProcess.h @@ -23,7 +23,6 @@ #include #include #include -#include namespace Acore { @@ -35,7 +34,7 @@ namespace Acore /// Note that most executables expect it's name as the first argument. AC_COMMON_API int StartProcess(std::string const& executable, std::vector const& args, std::string const& logger, std::string input_file = "", - bool secure = false, boost::process::environment env = boost::this_process::environment()); + bool secure = false); /// Platform and library independent representation /// of asynchronous process results @@ -59,7 +58,7 @@ namespace Acore /// Note that most executables expect it's name as the first argument. AC_COMMON_API std::shared_ptr StartAsyncProcess(std::string executable, std::vector args, std::string logger, std::string input_file = "", - bool secure = false, boost::process::environment env = boost::this_process::environment()); + bool secure = false); /// Searches for the given executable in the PATH variable /// and returns a non-empty string when it was found. diff --git a/src/server/database/Updater/DBUpdater.cpp b/src/server/database/Updater/DBUpdater.cpp index e1a1518f14..d4f45c2972 100644 --- a/src/server/database/Updater/DBUpdater.cpp +++ b/src/server/database/Updater/DBUpdater.cpp @@ -447,6 +447,9 @@ void DBUpdater::ApplyFile(DatabaseWorkerPool& pool, std::string const& hos args.emplace_back("-h" + host); args.emplace_back("-u" + user); + if (!password.empty()) + args.emplace_back("-p" + password); + // Check if we want to connect through ip or socket (Unix only) #ifdef _WIN32 @@ -496,14 +499,9 @@ void DBUpdater::ApplyFile(DatabaseWorkerPool& pool, std::string const& hos if (!database.empty()) args.emplace_back(database); - auto env = boost::process::environment(); - - if (!password.empty()) - env["MYSQL_PWD"]=password; - // Invokes a mysql process which doesn't leak credentials to logs int const ret = Acore::StartProcess(DBUpdaterUtil::GetCorrectedMySQLExecutable(), args, - "sql.updates", "", true, env); + "sql.updates", "", true); if (ret != EXIT_SUCCESS) {