Update source/src/utils/execute.cpp
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 26s
Build-Test-Publish / build (linux/arm64) (push) Successful in 1m0s

This commit is contained in:
j
2026-01-03 17:22:49 +13:00
parent b9ef58d979
commit cc4c59132b

View File

@@ -195,7 +195,7 @@ namespace dropshell
return false; return false;
std::stringstream ssh_cmd; 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 " : "") << (hasFlag(mode, cMode::Interactive) ? "-tt " : "")
<< ssh_info.get_user() << "@" << ssh_info.get_host(); << ssh_info.get_user() << "@" << ssh_info.get_host();
@@ -204,14 +204,29 @@ namespace dropshell
if (!hasFlag(mode, cMode::NoBB64)) if (!hasFlag(mode, cMode::NoBB64))
remote_bb64_path = remotepath(ssh_info.get_server_ID(), ssh_info.get_user()).agent() + "/bb64"; 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( bool rval = execute_local_command(
"", // local directory to run in "", // local directory to run in
ssh_cmd.str() + " " + remote_command.construct_cmd(remote_bb64_path), // local command to run ssh_cmd.str() + " " + remote_command.construct_cmd(remote_bb64_path), // local command to run
{}, // environment variables {}, // environment variables
output, // output string output_ptr, // output string
mode // mode 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)) if (!rval && !hasFlag(mode, cMode::Silent))
{ {
error << "Failed to execute ssh command" << std::endl; error << "Failed to execute ssh command" << std::endl;