summaryrefslogtreecommitdiff
path: root/clientloop.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2023-01-06 02:39:59 +0000
committerDamien Miller <djm@mindrot.org>2023-01-06 16:21:39 +1100
commitc60438158ad4b2f83d8504257aba1be7d0b0bb4b (patch)
tree4448c18b7d781578d8d5fc8c7335c5b7e1c1078e /clientloop.c
parentd478cdc7ad6edd4b1bcd1e86fb2f23194ff33d5a (diff)
downloadopenssh-git-c60438158ad4b2f83d8504257aba1be7d0b0bb4b.tar.gz
upstream: Add channel_force_close()
This will forcibly close an open channel by simulating read/write errors, draining the IO buffers and calling the detach function. Previously the detach function was only ever called during channel garbage collection, but there was no way to signal the user of a channel (e.g. session.c) that its channel was being closed deliberately (vs. by the usual state-machine logic). So this adds an extra "force" argument to the channel cleanup callback to indicate this condition. ok markus dtucker OpenBSD-Commit-ID: 23052707a42bdc62fda2508636e624afd466324b
Diffstat (limited to 'clientloop.c')
-rw-r--r--clientloop.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/clientloop.c b/clientloop.c
index d087b05b..fef9efc6 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clientloop.c,v 1.386 2023/01/06 02:38:23 djm Exp $ */
+/* $OpenBSD: clientloop.c,v 1.387 2023/01/06 02:39:59 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1033,15 +1033,7 @@ process_escapes(struct ssh *ssh, Channel *c,
efc->escape_char)) != 0)
fatal_fr(r, "sshbuf_putf");
if (c && c->ctl_chan != -1) {
- chan_read_failed(ssh, c);
- chan_write_failed(ssh, c);
- if (c->detach_user) {
- c->detach_user(ssh,
- c->self, NULL);
- }
- c->type = SSH_CHANNEL_ABANDONED;
- sshbuf_reset(c->input);
- chan_ibuf_empty(ssh, c);
+ channel_force_close(ssh, c, 1);
return 0;
} else
quit_pending = 1;
@@ -1267,7 +1259,7 @@ client_simple_escape_filter(struct ssh *ssh, Channel *c, char *buf, int len)
}
static void
-client_channel_closed(struct ssh *ssh, int id, void *arg)
+client_channel_closed(struct ssh *ssh, int id, int force, void *arg)
{
channel_cancel_cleanup(ssh, id);
session_closed = 1;