1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-12-24 19:37:48 +03:00

ttyopts: Adjust the default TTY modes to be sane

The "sane" default is now based on the man stty "sane" alias with addition of
utf8.

Fixes: #270

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Jakub Jelen
2024-08-22 15:15:14 +02:00
parent e298600303
commit 48d474f78c
2 changed files with 9 additions and 6 deletions

View File

@@ -318,6 +318,9 @@ encode_termios_opts(struct termios *attr, unsigned char *buf, size_t buflen)
* This function intentionally doesn't use the \c termios structure
* to allow it to work on Windows as well.
*
* The "sane" default set is derived from the `stty sane`, but iutf8 support is
* added on top of that.
*
* @param[out] buf Modes will be encoded into this buffer.
*
* @param[in] buflen The length of the buffer.
@@ -342,7 +345,7 @@ encode_default_opts(unsigned char *buf, size_t buflen)
SSH_ENCODE_OPT(TTY_OP_VQUIT, 034)
SSH_ENCODE_OPT(TTY_OP_VERASE, 0177)
SSH_ENCODE_OPT(TTY_OP_VKILL, 025)
SSH_ENCODE_OPT(TTY_OP_VEOF, 0)
SSH_ENCODE_OPT(TTY_OP_VEOF, 004)
SSH_ENCODE_OPT(TTY_OP_VEOL, 0)
SSH_ENCODE_OPT(TTY_OP_VEOL2, 0)
SSH_ENCODE_OPT(TTY_OP_VSTART, 021)
@@ -359,7 +362,7 @@ encode_default_opts(unsigned char *buf, size_t buflen)
SSH_ENCODE_OPT(TTY_OP_ISTRIP, 0)
SSH_ENCODE_OPT(TTY_OP_INLCR, 0)
SSH_ENCODE_OPT(TTY_OP_IGNCR, 0)
SSH_ENCODE_OPT(TTY_OP_ICRNL, 0)
SSH_ENCODE_OPT(TTY_OP_ICRNL, 1)
SSH_ENCODE_OPT(TTY_OP_IUCLC, 0)
SSH_ENCODE_OPT(TTY_OP_IXON, 1)
SSH_ENCODE_OPT(TTY_OP_IXANY, 0)
@@ -376,12 +379,12 @@ encode_default_opts(unsigned char *buf, size_t buflen)
SSH_ENCODE_OPT(TTY_OP_NOFLSH, 0)
SSH_ENCODE_OPT(TTY_OP_TOSTOP, 0)
SSH_ENCODE_OPT(TTY_OP_IEXTEN, 1)
SSH_ENCODE_OPT(TTY_OP_ECHOCTL, 0)
SSH_ENCODE_OPT(TTY_OP_ECHOCTL, 1)
SSH_ENCODE_OPT(TTY_OP_ECHOKE, 1)
SSH_ENCODE_OPT(TTY_OP_PENDIN, 0)
SSH_ENCODE_OPT(TTY_OP_OPOST, 1)
SSH_ENCODE_OPT(TTY_OP_OLCUC, 0)
SSH_ENCODE_OPT(TTY_OP_ONLCR, 0)
SSH_ENCODE_OPT(TTY_OP_ONLCR, 1)
SSH_ENCODE_OPT(TTY_OP_OCRNL, 0)
SSH_ENCODE_OPT(TTY_OP_ONOCR, 0)
SSH_ENCODE_OPT(TTY_OP_ONLRET, 0)

View File

@@ -231,8 +231,8 @@ static void torture_request_pty_modes_use_default_modes(void **state)
rc = ssh_channel_request_exec(c, "/bin/echo -e '>TEST\\r\\n<'");
assert_ssh_return_code(session, rc);
/* expect the input unmodified */
string_found = check_channel_output(c, ">TEST\r\n<");
/* expect the CRLF translated to newline */
string_found = check_channel_output(c, ">TEST\r\r\n<");
assert_int_equal(string_found, 1);
ssh_channel_close(c);