Update source/src/utils/execute.cpp
This commit is contained in:
@@ -195,7 +195,7 @@ namespace dropshell
|
||||
return false;
|
||||
|
||||
std::stringstream ssh_cmd;
|
||||
ssh_cmd << "ssh -p " << ssh_info.get_port() << " "
|
||||
ssh_cmd << "ssh -p " << ssh_info.get_port() << " "
|
||||
<< (hasFlag(mode, cMode::Interactive) ? "-tt " : "")
|
||||
<< ssh_info.get_user() << "@" << ssh_info.get_host();
|
||||
|
||||
@@ -204,14 +204,29 @@ namespace dropshell
|
||||
if (!hasFlag(mode, cMode::NoBB64))
|
||||
remote_bb64_path = remotepath(ssh_info.get_server_ID(), ssh_info.get_user()).agent() + "/bb64";
|
||||
|
||||
// Capture output to check for AGENT_MISMATCH (but not in Interactive mode)
|
||||
std::string captured_output;
|
||||
std::string* output_ptr = output;
|
||||
if (!hasFlag(mode, cMode::Interactive) && output == nullptr)
|
||||
output_ptr = &captured_output;
|
||||
|
||||
bool rval = execute_local_command(
|
||||
"", // local directory to run in
|
||||
ssh_cmd.str() + " " + remote_command.construct_cmd(remote_bb64_path), // local command to run
|
||||
{}, // environment variables
|
||||
output, // output string
|
||||
output_ptr, // output string
|
||||
mode // mode
|
||||
);
|
||||
|
||||
// Check for agent mismatch error
|
||||
if (!rval && output_ptr != nullptr && output_ptr->find("AGENT_MISMATCH:") != std::string::npos)
|
||||
{
|
||||
error << "Agent version mismatch detected!" << std::endl;
|
||||
error << "The remote agent on " << ssh_info.get_host() << " is out of date." << std::endl;
|
||||
info << "Run 'ds install " << ssh_info.get_server_ID() << "' to update the agent." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!rval && !hasFlag(mode, cMode::Silent))
|
||||
{
|
||||
error << "Failed to execute ssh command" << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user