dropbear: cherry-pick upstream patches
[openwrt/staging/robimarko.git] / package / network / services / dropbear / patches / 017-Don-t-try-to-shutdown-a-pty.patch
1 From e28ba1b9975eab48799aa3ed77d3cd91627d7b27 Mon Sep 17 00:00:00 2001
2 From: Matt Johnston <matt@ucc.asn.au>
3 Date: Sat, 9 Dec 2023 23:10:41 +0800
4 Subject: Don't try to shutdown() a pty
5
6 shutdown() of a pty doesn't work (ENOTSOCK), so we should close
7 it instead.
8
9 This will ensure that PTY controlling terminals are closed when a
10 session exits, including when multiple sessions run over a single SSH
11 connection. In the normal case of a single session, the PTY controlling
12 terminal would be closed when the Dropbear server process exits anyway.
13
14 This possibly fixes #264 on github
15
16 It is possible that there could be subtle changes to PTY flushing
17 behaviour, though nothing caught by tests at present.
18 ---
19 svr-chansession.c | 2 +-
20 1 file changed, 1 insertion(+), 1 deletion(-)
21
22 --- a/svr-chansession.c
23 +++ b/svr-chansession.c
24 @@ -910,7 +910,7 @@ static int ptycommand(struct Channel *ch
25 channel->readfd = chansess->master;
26 /* don't need to set stderr here */
27 ses.maxfd = MAX(ses.maxfd, chansess->master);
28 - channel->bidir_fd = 1;
29 + channel->bidir_fd = 0;
30
31 setnonblocking(chansess->master);
32