]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: when deciding whether to enable keystroke timing
authordjm@openbsd.org <djm@openbsd.org>
Wed, 15 Nov 2023 22:51:49 +0000 (22:51 +0000)
committerDamien Miller <djm@mindrot.org>
Wed, 15 Nov 2023 22:53:42 +0000 (09:53 +1100)
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

OpenBSD-Commit-ID: c292f738db410f729190f92de100c39ec931a4f1

channels.c
channels.h
clientloop.c

index 598ff322a17548a6a08c9a65a2b7cb13356e65b1..38135e5ad2b8d9f62ea752e25c4c4d0ac5b26900 100644 (file)
@@ -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
@@ -898,6 +898,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)
index 58019a84e71cd13b93a6cb9643d2985e03c44c33..3054b04dfbf87ffa859aaed27446e2d0ada30072 100644 (file)
@@ -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>
@@ -340,6 +340,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 *);
index 8e323a6008eb6d9f6b920c8591ffd38cd088d84f..c5a9240928d1522919b234a2fae7b224bcc1559e 100644 (file)
@@ -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
@@ -589,7 +589,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)) {