.
Some checks failed
Dropshell Test / Build_and_Test (push) Failing after 20s

This commit is contained in:
Your Name 2025-05-10 13:32:09 +12:00
parent 00571d8091
commit 068ef34709
3 changed files with 27 additions and 12 deletions

2
runner/hello.txt Normal file
View File

@ -0,0 +1,2 @@
lkjdfslka

View File

@ -7,7 +7,7 @@
# )
JSON=$(cat <<'EOF'
{"command":"nano","args":["-w","./hello.txt"],"ssh":{"host":"localhost","user":"j","key":"auto"},"options":{"interactive":true},"env":{"TERM":"xterm-256color"}}
{"command":"nano","args":["-w","./hello.txt"],"options":{"interactive":true}}
EOF
)

View File

@ -356,6 +356,10 @@ int Runner::execute_ssh(
ssh_options_set(session, SSH_OPTIONS_PORT, &port);
ssh_options_set(session, SSH_OPTIONS_USER, user.c_str());
// Set pseudo-terminal flag (equivalent to ssh -tt)
int flag = 1;
ssh_options_set(session, SSH_OPTIONS_STRICTHOSTKEYCHECK, &flag);
// Connect to server
int rc = ssh_connect(session);
if (rc != SSH_OK) {
@ -426,19 +430,28 @@ int Runner::execute_ssh(
if (interactive) {
// Request a pseudo-terminal for interactive commands with specific term type
const char* term_type = "xterm-256color";
// Force PTY allocation first with basic settings
rc = ssh_channel_request_pty(channel);
if (rc != SSH_OK) {
std::cerr << "Error requesting basic PTY: " << ssh_get_error(session) << std::endl;
ssh_channel_close(channel);
ssh_channel_free(channel);
ssh_disconnect(session);
ssh_free(session);
return -1;
}
// Then set the size and term type
rc = ssh_channel_request_pty_size(channel, term_type, 80, 24);
if (rc != SSH_OK) {
// Fallback to basic PTY request
std::cerr << "Warning: Could not set PTY with size, falling back to basic PTY" << std::endl;
rc = ssh_channel_request_pty(channel);
if (rc != SSH_OK) {
std::cerr << "Error requesting PTY: " << ssh_get_error(session) << std::endl;
ssh_channel_close(channel);
ssh_channel_free(channel);
ssh_disconnect(session);
ssh_free(session);
return -1;
}
std::cerr << "Warning: Could not set PTY size, but continuing anyway" << std::endl;
}
// Set up terminal mode to be more raw (important for full-screen apps)
if (env.find("TERM") == env.end()) {
// Add TERM environment if not present
cmd_stream << "export TERM=\"" << term_type << "\"; ";
}
}