mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 01:08:35 +00:00
fix(CORE/dbupdate)): allow to pass MySQL password via env (#13404)
* fix(CORE/dbupdate)): allow to pass MySQL password via env + fixed devContainer override file issue + added authserver dry-run in our CI
This commit is contained in:
@@ -3,12 +3,11 @@
|
|||||||
"name": "ac-dev-server",
|
"name": "ac-dev-server",
|
||||||
|
|
||||||
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
|
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
|
||||||
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
|
// set an empty array to automatically solve
|
||||||
"dockerComposeFile": [
|
// the docker-compose files (including the .override.yml)
|
||||||
"../docker-compose.yml",
|
// https://github.com/microsoft/vscode-remote-release/issues/1080#issuecomment-824213014
|
||||||
"../docker-compose.override.yml", // needed until this issue will be solved: https://github.com/microsoft/vscode-remote-release/issues/1080
|
// it requires vscode 1.57+
|
||||||
"docker-compose.yml"
|
"dockerComposeFile": [],
|
||||||
],
|
|
||||||
// The 'service' property is the name of the service for the container that VS Code should
|
// 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.
|
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
|
||||||
"service": "ac-dev-server",
|
"service": "ac-dev-server",
|
||||||
|
|||||||
4
.github/workflows/core_build.yml
vendored
4
.github/workflows/core_build.yml
vendored
@@ -42,7 +42,9 @@ jobs:
|
|||||||
run: bash bin/acore-db-pendings
|
run: bash bin/acore-db-pendings
|
||||||
- name: Build
|
- name: Build
|
||||||
run: source ./apps/ci/ci-compile.sh
|
run: source ./apps/ci/ci-compile.sh
|
||||||
- name: Dry run
|
- name: Dry run authserver
|
||||||
|
run: source ./apps/ci/ci-dry-run.sh authserver
|
||||||
|
- name: Dry run worldserver
|
||||||
run: source ./apps/ci/ci-dry-run.sh worldserver
|
run: source ./apps/ci/ci-dry-run.sh worldserver
|
||||||
- name: Check startup errors
|
- name: Check startup errors
|
||||||
run: source ./apps/ci/ci-error-check.sh
|
run: source ./apps/ci/ci-error-check.sh
|
||||||
|
|||||||
4
.github/workflows/core_matrix_build.yml
vendored
4
.github/workflows/core_matrix_build.yml
vendored
@@ -50,7 +50,9 @@ jobs:
|
|||||||
run: bash bin/acore-db-pendings
|
run: bash bin/acore-db-pendings
|
||||||
- name: Build
|
- name: Build
|
||||||
run: source ./apps/ci/ci-compile.sh
|
run: source ./apps/ci/ci-compile.sh
|
||||||
- name: Dry run
|
- name: Dry run authserver
|
||||||
|
run: source ./apps/ci/ci-dry-run.sh authserver
|
||||||
|
- name: Dry run worldserver
|
||||||
run: source ./apps/ci/ci-dry-run.sh worldserver
|
run: source ./apps/ci/ci-dry-run.sh worldserver
|
||||||
- name: Check startup errors
|
- name: Check startup errors
|
||||||
run: source ./apps/ci/ci-error-check.sh
|
run: source ./apps/ci/ci-error-check.sh
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace Acore
|
|||||||
static int CreateChildProcess(T waiter, std::string const& executable,
|
static int CreateChildProcess(T waiter, std::string const& executable,
|
||||||
std::vector<std::string> const& argsVector,
|
std::vector<std::string> const& argsVector,
|
||||||
std::string const& logger, std::string const& input,
|
std::string const& logger, std::string const& input,
|
||||||
bool secure)
|
bool secure, boost::process::environment envVariables = boost::this_process::environment())
|
||||||
{
|
{
|
||||||
ipstream outStream;
|
ipstream outStream;
|
||||||
ipstream errStream;
|
ipstream errStream;
|
||||||
@@ -97,7 +97,7 @@ namespace Acore
|
|||||||
return child{
|
return child{
|
||||||
exe = std::filesystem::absolute(executable).string(),
|
exe = std::filesystem::absolute(executable).string(),
|
||||||
args = argsVector,
|
args = argsVector,
|
||||||
env = environment(boost::this_process::environment()),
|
env = environment(envVariables),
|
||||||
std_in = inputFile.get(),
|
std_in = inputFile.get(),
|
||||||
std_out = outStream,
|
std_out = outStream,
|
||||||
std_err = errStream
|
std_err = errStream
|
||||||
@@ -109,7 +109,7 @@ namespace Acore
|
|||||||
return child{
|
return child{
|
||||||
exe = std::filesystem::absolute(executable).string(),
|
exe = std::filesystem::absolute(executable).string(),
|
||||||
args = argsVector,
|
args = argsVector,
|
||||||
env = environment(boost::this_process::environment()),
|
env = environment(envVariables),
|
||||||
std_in = boost::process::close,
|
std_in = boost::process::close,
|
||||||
std_out = outStream,
|
std_out = outStream,
|
||||||
std_err = errStream
|
std_err = errStream
|
||||||
@@ -144,7 +144,7 @@ namespace Acore
|
|||||||
}
|
}
|
||||||
|
|
||||||
int StartProcess(std::string const& executable, std::vector<std::string> const& args,
|
int StartProcess(std::string const& executable, std::vector<std::string> const& args,
|
||||||
std::string const& logger, std::string input_file, bool secure)
|
std::string const& logger, std::string input_file, bool secure, boost::process::environment env)
|
||||||
{
|
{
|
||||||
return CreateChildProcess([](child& c) -> int
|
return CreateChildProcess([](child& c) -> int
|
||||||
{
|
{
|
||||||
@@ -157,7 +157,7 @@ namespace Acore
|
|||||||
{
|
{
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}, executable, args, logger, input_file, secure);
|
}, executable, args, logger, input_file, secure, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
class AsyncProcessResultImplementation
|
class AsyncProcessResultImplementation
|
||||||
@@ -168,6 +168,7 @@ namespace Acore
|
|||||||
std::string const logger;
|
std::string const logger;
|
||||||
std::string const input_file;
|
std::string const input_file;
|
||||||
bool const is_secure;
|
bool const is_secure;
|
||||||
|
boost::process::environment envVariables;
|
||||||
|
|
||||||
std::atomic<bool> was_terminated;
|
std::atomic<bool> was_terminated;
|
||||||
|
|
||||||
@@ -177,10 +178,10 @@ namespace Acore
|
|||||||
public:
|
public:
|
||||||
explicit AsyncProcessResultImplementation(std::string executable_, std::vector<std::string> args_,
|
explicit AsyncProcessResultImplementation(std::string executable_, std::vector<std::string> args_,
|
||||||
std::string logger_, std::string input_file_,
|
std::string logger_, std::string input_file_,
|
||||||
bool secure)
|
bool secure, boost::process::environment env)
|
||||||
: executable(std::move(executable_)), args(std::move(args_)),
|
: executable(std::move(executable_)), args(std::move(args_)),
|
||||||
logger(std::move(logger_)), input_file(input_file_),
|
logger(std::move(logger_)), input_file(input_file_),
|
||||||
is_secure(secure), was_terminated(false) { }
|
is_secure(secure), envVariables(env), was_terminated(false) { }
|
||||||
|
|
||||||
AsyncProcessResultImplementation(AsyncProcessResultImplementation const&) = delete;
|
AsyncProcessResultImplementation(AsyncProcessResultImplementation const&) = delete;
|
||||||
AsyncProcessResultImplementation& operator= (AsyncProcessResultImplementation const&) = delete;
|
AsyncProcessResultImplementation& operator= (AsyncProcessResultImplementation const&) = delete;
|
||||||
@@ -209,7 +210,7 @@ namespace Acore
|
|||||||
my_child.reset();
|
my_child.reset();
|
||||||
return was_terminated ? EXIT_FAILURE : exitCode;
|
return was_terminated ? EXIT_FAILURE : exitCode;
|
||||||
|
|
||||||
}, executable, args, logger, input_file, is_secure);
|
}, executable, args, logger, input_file, is_secure, envVariables);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetFuture(std::future<int> result_)
|
void SetFuture(std::future<int> result_)
|
||||||
@@ -245,10 +246,10 @@ namespace Acore
|
|||||||
|
|
||||||
std::shared_ptr<AsyncProcessResult>
|
std::shared_ptr<AsyncProcessResult>
|
||||||
StartAsyncProcess(std::string executable, std::vector<std::string> args,
|
StartAsyncProcess(std::string executable, std::vector<std::string> args,
|
||||||
std::string logger, std::string input_file, bool secure)
|
std::string logger, std::string input_file, bool secure, boost::process::native_environment env)
|
||||||
{
|
{
|
||||||
auto handle = std::make_shared<AsyncProcessResultImplementation>(
|
auto handle = std::make_shared<AsyncProcessResultImplementation>(
|
||||||
std::move(executable), std::move(args), std::move(logger), std::move(input_file), secure);
|
std::move(executable), std::move(args), std::move(logger), std::move(input_file), secure, env);
|
||||||
|
|
||||||
handle->SetFuture(std::async(std::launch::async, [handle] { return handle->StartProcess(); }));
|
handle->SetFuture(std::async(std::launch::async, [handle] { return handle->StartProcess(); }));
|
||||||
return handle;
|
return handle;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <boost/process/environment.hpp>
|
||||||
|
|
||||||
namespace Acore
|
namespace Acore
|
||||||
{
|
{
|
||||||
@@ -34,7 +35,7 @@ namespace Acore
|
|||||||
/// Note that most executables expect it's name as the first argument.
|
/// Note that most executables expect it's name as the first argument.
|
||||||
AC_COMMON_API int StartProcess(std::string const& executable, std::vector<std::string> const& args,
|
AC_COMMON_API int StartProcess(std::string const& executable, std::vector<std::string> const& args,
|
||||||
std::string const& logger, std::string input_file = "",
|
std::string const& logger, std::string input_file = "",
|
||||||
bool secure = false);
|
bool secure = false, boost::process::environment env = boost::this_process::environment());
|
||||||
|
|
||||||
/// Platform and library independent representation
|
/// Platform and library independent representation
|
||||||
/// of asynchronous process results
|
/// of asynchronous process results
|
||||||
@@ -58,7 +59,7 @@ namespace Acore
|
|||||||
/// Note that most executables expect it's name as the first argument.
|
/// Note that most executables expect it's name as the first argument.
|
||||||
AC_COMMON_API std::shared_ptr<AsyncProcessResult> StartAsyncProcess(std::string executable, std::vector<std::string> args,
|
AC_COMMON_API std::shared_ptr<AsyncProcessResult> StartAsyncProcess(std::string executable, std::vector<std::string> args,
|
||||||
std::string logger, std::string input_file = "",
|
std::string logger, std::string input_file = "",
|
||||||
bool secure = false);
|
bool secure = false, boost::process::environment env = boost::this_process::environment());
|
||||||
|
|
||||||
/// Searches for the given executable in the PATH variable
|
/// Searches for the given executable in the PATH variable
|
||||||
/// and returns a non-empty string when it was found.
|
/// and returns a non-empty string when it was found.
|
||||||
|
|||||||
@@ -447,9 +447,6 @@ void DBUpdater<T>::ApplyFile(DatabaseWorkerPool<T>& pool, std::string const& hos
|
|||||||
args.emplace_back("-h" + host);
|
args.emplace_back("-h" + host);
|
||||||
args.emplace_back("-u" + user);
|
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)
|
// Check if we want to connect through ip or socket (Unix only)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
@@ -499,9 +496,14 @@ void DBUpdater<T>::ApplyFile(DatabaseWorkerPool<T>& pool, std::string const& hos
|
|||||||
if (!database.empty())
|
if (!database.empty())
|
||||||
args.emplace_back(database);
|
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
|
// Invokes a mysql process which doesn't leak credentials to logs
|
||||||
int const ret = Acore::StartProcess(DBUpdaterUtil::GetCorrectedMySQLExecutable(), args,
|
int const ret = Acore::StartProcess(DBUpdaterUtil::GetCorrectedMySQLExecutable(), args,
|
||||||
"sql.updates", "", true);
|
"sql.updates", "", true, env);
|
||||||
|
|
||||||
if (ret != EXIT_SUCCESS)
|
if (ret != EXIT_SUCCESS)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user