Revert feat(core): Start Process and DBUpdater (#13465)

Revert "feat(CORE): for Start Process and  DBUpdater

This a selective reverts for commits:
c855e8d227 and  636df19514. To re-enable the windows build to function again while applying updates.

Update DBUpdater.cpp
This commit is contained in:
M'Dic
2022-10-20 01:43:34 -04:00
committed by GitHub
parent 1fe126766f
commit e836f08cc4
3 changed files with 13 additions and 17 deletions
+10 -11
View File
@@ -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, boost::process::environment envVariables = boost::this_process::environment()) bool secure)
{ {
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(envVariables), env = environment(boost::this_process::environment()),
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(envVariables), env = environment(boost::this_process::environment()),
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, boost::process::environment env) std::string const& logger, std::string input_file, bool secure)
{ {
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, env); }, executable, args, logger, input_file, secure);
} }
class AsyncProcessResultImplementation class AsyncProcessResultImplementation
@@ -168,7 +168,6 @@ 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;
@@ -178,10 +177,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, boost::process::environment env) bool secure)
: 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), envVariables(env), was_terminated(false) { } is_secure(secure), was_terminated(false) { }
AsyncProcessResultImplementation(AsyncProcessResultImplementation const&) = delete; AsyncProcessResultImplementation(AsyncProcessResultImplementation const&) = delete;
AsyncProcessResultImplementation& operator= (AsyncProcessResultImplementation const&) = delete; AsyncProcessResultImplementation& operator= (AsyncProcessResultImplementation const&) = delete;
@@ -210,7 +209,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, envVariables); }, executable, args, logger, input_file, is_secure);
} }
void SetFuture(std::future<int> result_) void SetFuture(std::future<int> result_)
@@ -246,10 +245,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, boost::process::native_environment env) std::string logger, std::string input_file, bool secure)
{ {
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, 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(); })); handle->SetFuture(std::async(std::launch::async, [handle] { return handle->StartProcess(); }));
return handle; return handle;
+2 -3
View File
@@ -23,7 +23,6 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
#include <boost/process/environment.hpp>
namespace Acore namespace Acore
{ {
@@ -35,7 +34,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, boost::process::environment env = boost::this_process::environment()); bool secure = false);
/// Platform and library independent representation /// Platform and library independent representation
/// of asynchronous process results /// of asynchronous process results
@@ -59,7 +58,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, boost::process::environment env = boost::this_process::environment()); bool secure = false);
/// 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.
+1 -3
View File
@@ -501,11 +501,9 @@ 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();
// 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, env); "sql.updates", "", true);
if (ret != EXIT_SUCCESS) if (ret != EXIT_SUCCESS)
{ {