Issue #157: Use the current TTY's settings by default.

When opening a PTY on the server, try to use the current TTY's settings
(i.e. based on STDIN). If that fails or STDIN isn't a TTY, use default
modes that avoid any character translation.

Don't rely on stdin to be a TTY (breaks CI). Instead, open a PTY and
temporarily use that as "fake" stdin.

Signed-off-by: Daniel Evers (daniel.evers@utimaco.com)
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Daniel Evers
2023-10-28 16:16:11 +02:00
committed by Jakub Jelen
parent b5daac6772
commit cd6e84a6c3
6 changed files with 589 additions and 17 deletions

View File

@@ -1991,9 +1991,18 @@ error:
int ssh_channel_request_pty_size(ssh_channel channel, const char *terminal,
int col, int row)
{
/* default modes/options: none */
const unsigned char modes[1] = {0};
return ssh_channel_request_pty_size_modes(channel, terminal, col, row, modes, sizeof(modes));
/* use modes from the current TTY */
unsigned char modes_buf[SSH_TTY_MODES_MAX_BUFSIZE];
int rc = encode_current_tty_opts(modes_buf, sizeof(modes_buf));
if (rc < 0) {
return rc;
}
return ssh_channel_request_pty_size_modes(channel,
terminal,
col,
row,
modes_buf,
(size_t)rc);
}
/**