diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2023-11-15 22:51:50 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2023-11-15 22:51:50 +0000 |
commit | a74b27860b3dae769fff39f8f8ee791a8aea67eb (patch) | |
tree | 93a0d6ca9f10cd0d28dd228563d29e74e60003fc /usr.bin | |
parent | f7f9b0d95c86052cdbc623221e1295ac77367b81 (diff) |
when deciding whether to enable keystroke timing obfuscation,
only consider enabling it when a channel with a tty is open.
Avoids turning on the obfucation when X11 forwarding only is in use,
which slows it right down. Reported by Roger Marsh
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/channels.c | 19 | ||||
-rw-r--r-- | usr.bin/ssh/channels.h | 3 | ||||
-rw-r--r-- | usr.bin/ssh/clientloop.c | 4 |
3 files changed, 22 insertions, 4 deletions
diff --git a/usr.bin/ssh/channels.c b/usr.bin/ssh/channels.c index 1b310e3c629..7c611bc375c 100644 --- a/usr.bin/ssh/channels.c +++ b/usr.bin/ssh/channels.c @@ -1,4 +1,4 @@ -/* $OpenBSD: channels.c,v 1.433 2023/09/04 00:01:46 djm Exp $ */ +/* $OpenBSD: channels.c,v 1.434 2023/11/15 22:51:49 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -886,6 +886,23 @@ channel_still_open(struct ssh *ssh) return 0; } +/* Returns true if a channel with a TTY is open. */ +int +channel_tty_open(struct ssh *ssh) +{ + u_int i; + Channel *c; + + for (i = 0; i < ssh->chanctxt->channels_alloc; i++) { + c = ssh->chanctxt->channels[i]; + if (c == NULL || c->type != SSH_CHANNEL_OPEN) + continue; + if (c->client_tty) + return 1; + } + return 0; +} + /* Returns the id of an open channel suitable for keepaliving */ int channel_find_open(struct ssh *ssh) diff --git a/usr.bin/ssh/channels.h b/usr.bin/ssh/channels.h index 7cfba92a8f0..b8c888358fb 100644 --- a/usr.bin/ssh/channels.h +++ b/usr.bin/ssh/channels.h @@ -1,4 +1,4 @@ -/* $OpenBSD: channels.h,v 1.152 2023/09/04 00:01:46 djm Exp $ */ +/* $OpenBSD: channels.h,v 1.153 2023/11/15 22:51:49 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> @@ -337,6 +337,7 @@ int channel_output_poll(struct ssh *); int channel_not_very_much_buffered_data(struct ssh *); void channel_close_all(struct ssh *); int channel_still_open(struct ssh *); +int channel_tty_open(struct ssh *); const char *channel_format_extended_usage(const Channel *); char *channel_open_message(struct ssh *); int channel_find_open(struct ssh *); diff --git a/usr.bin/ssh/clientloop.c b/usr.bin/ssh/clientloop.c index deebbbac0d3..ffa0facaf76 100644 --- a/usr.bin/ssh/clientloop.c +++ b/usr.bin/ssh/clientloop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clientloop.c,v 1.400 2023/10/12 02:12:53 djm Exp $ */ +/* $OpenBSD: clientloop.c,v 1.401 2023/11/15 22:51:49 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -580,7 +580,7 @@ obfuscate_keystroke_timing(struct ssh *ssh, struct timespec *timeout, if (options.obscure_keystroke_timing_interval <= 0) return 1; /* disabled in config */ - if (!channel_still_open(ssh) || quit_pending) { + if (!channel_tty_open(ssh) || quit_pending) { /* Stop if no channels left of we're waiting for one to close */ stop_reason = "no active channels"; } else if (ssh_packet_is_rekeying(ssh)) { |