Skip to content

Commit da064c9

Browse files
committed
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> (cherry picked from commit 48d474f78c5f68471bf412a7dbf508ef52f77664)
1 parent c85dc05 commit da064c9

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/ttyopts.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ encode_termios_opts(struct termios *attr, unsigned char *buf, size_t buflen)
318318
* This function intentionally doesn't use the \c termios structure
319319
* to allow it to work on Windows as well.
320320
*
321+
* The "sane" default set is derived from the `stty sane`, but iutf8 support is
322+
* added on top of that.
323+
*
321324
* @param[out] buf Modes will be encoded into this buffer.
322325
*
323326
* @param[in] buflen The length of the buffer.
@@ -342,7 +345,7 @@ encode_default_opts(unsigned char *buf, size_t buflen)
342345
SSH_ENCODE_OPT(TTY_OP_VQUIT, 034)
343346
SSH_ENCODE_OPT(TTY_OP_VERASE, 0177)
344347
SSH_ENCODE_OPT(TTY_OP_VKILL, 025)
345-
SSH_ENCODE_OPT(TTY_OP_VEOF, 0)
348+
SSH_ENCODE_OPT(TTY_OP_VEOF, 004)
346349
SSH_ENCODE_OPT(TTY_OP_VEOL, 0)
347350
SSH_ENCODE_OPT(TTY_OP_VEOL2, 0)
348351
SSH_ENCODE_OPT(TTY_OP_VSTART, 021)
@@ -359,7 +362,7 @@ encode_default_opts(unsigned char *buf, size_t buflen)
359362
SSH_ENCODE_OPT(TTY_OP_ISTRIP, 0)
360363
SSH_ENCODE_OPT(TTY_OP_INLCR, 0)
361364
SSH_ENCODE_OPT(TTY_OP_IGNCR, 0)
362-
SSH_ENCODE_OPT(TTY_OP_ICRNL, 0)
365+
SSH_ENCODE_OPT(TTY_OP_ICRNL, 1)
363366
SSH_ENCODE_OPT(TTY_OP_IUCLC, 0)
364367
SSH_ENCODE_OPT(TTY_OP_IXON, 1)
365368
SSH_ENCODE_OPT(TTY_OP_IXANY, 0)
@@ -376,12 +379,12 @@ encode_default_opts(unsigned char *buf, size_t buflen)
376379
SSH_ENCODE_OPT(TTY_OP_NOFLSH, 0)
377380
SSH_ENCODE_OPT(TTY_OP_TOSTOP, 0)
378381
SSH_ENCODE_OPT(TTY_OP_IEXTEN, 1)
379-
SSH_ENCODE_OPT(TTY_OP_ECHOCTL, 0)
382+
SSH_ENCODE_OPT(TTY_OP_ECHOCTL, 1)
380383
SSH_ENCODE_OPT(TTY_OP_ECHOKE, 1)
381384
SSH_ENCODE_OPT(TTY_OP_PENDIN, 0)
382385
SSH_ENCODE_OPT(TTY_OP_OPOST, 1)
383386
SSH_ENCODE_OPT(TTY_OP_OLCUC, 0)
384-
SSH_ENCODE_OPT(TTY_OP_ONLCR, 0)
387+
SSH_ENCODE_OPT(TTY_OP_ONLCR, 1)
385388
SSH_ENCODE_OPT(TTY_OP_OCRNL, 0)
386389
SSH_ENCODE_OPT(TTY_OP_ONOCR, 0)
387390
SSH_ENCODE_OPT(TTY_OP_ONLRET, 0)

tests/client/torture_request_pty_modes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ static void torture_request_pty_modes_use_default_modes(void **state)
231231
rc = ssh_channel_request_exec(c, "/bin/echo -e '>TEST\\r\\n<'");
232232
assert_ssh_return_code(session, rc);
233233

234-
/* expect the input unmodified */
235-
string_found = check_channel_output(c, ">TEST\r\n<");
234+
/* expect the CRLF translated to newline */
235+
string_found = check_channel_output(c, ">TEST\r\r\n<");
236236
assert_int_equal(string_found, 1);
237237

238238
ssh_channel_close(c);

0 commit comments

Comments
 (0)