diff options
author | djm@openbsd.org <djm@openbsd.org> | 2020-04-03 04:03:51 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2020-04-03 15:35:28 +1100 |
commit | 7b4d8999f2e1a0cb7b065e3efa83e6edccfc7d82 (patch) | |
tree | da59a7f6db8be2811227e09f0c40f7850c48fa25 | |
parent | eece243666d44ceb710d004624c5c7bdc05454bc (diff) |
upstream: the tunnel-forwarding vs ExitOnForwardFailure fix that I
committed earlier had an off-by-one. Fix this and add some debugging that
would have made it apparent sooner.
OpenBSD-Commit-ID: 082f8f72b1423bd81bbdad750925b906e5ac6910
-rw-r--r-- | ssh.c | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh.c,v 1.523 2020/04/03 02:40:32 djm Exp $ */ | 1 | /* $OpenBSD: ssh.c,v 1.524 2020/04/03 04:03:51 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -1676,10 +1676,15 @@ fork_postauth(void) | |||
1676 | static void | 1676 | static void |
1677 | forwarding_success(void) | 1677 | forwarding_success(void) |
1678 | { | 1678 | { |
1679 | if (forward_confirms_pending > 0 && --forward_confirms_pending == 0) { | 1679 | if (forward_confirms_pending == -1) |
1680 | debug("All forwarding requests processed"); | 1680 | return; |
1681 | if (--forward_confirms_pending == 0) { | ||
1682 | debug("%s: all expected forwarding replies received"); | ||
1681 | if (fork_after_authentication_flag) | 1683 | if (fork_after_authentication_flag) |
1682 | fork_postauth(); | 1684 | fork_postauth(); |
1685 | } else { | ||
1686 | debug2("%s: %d expected forwarding replies remaining", | ||
1687 | __func__, forward_confirms_pending); | ||
1683 | } | 1688 | } |
1684 | } | 1689 | } |
1685 | 1690 | ||
@@ -1800,6 +1805,8 @@ ssh_init_forwarding(struct ssh *ssh, char **ifname) | |||
1800 | int success = 0; | 1805 | int success = 0; |
1801 | int i; | 1806 | int i; |
1802 | 1807 | ||
1808 | if (options.exit_on_forward_failure) | ||
1809 | forward_confirms_pending = 0; /* track pending requests */ | ||
1803 | /* Initiate local TCP/IP port forwardings. */ | 1810 | /* Initiate local TCP/IP port forwardings. */ |
1804 | for (i = 0; i < options.num_local_forwards; i++) { | 1811 | for (i = 0; i < options.num_local_forwards; i++) { |
1805 | debug("Local connections to %.200s:%d forwarded to remote " | 1812 | debug("Local connections to %.200s:%d forwarded to remote " |
@@ -1859,6 +1866,10 @@ ssh_init_forwarding(struct ssh *ssh, char **ifname) | |||
1859 | else | 1866 | else |
1860 | error("Could not request tunnel forwarding."); | 1867 | error("Could not request tunnel forwarding."); |
1861 | } | 1868 | } |
1869 | if (forward_confirms_pending > 0) { | ||
1870 | debug("%s: expecting replies for %d forwards", __func__, | ||
1871 | forward_confirms_pending); | ||
1872 | } | ||
1862 | } | 1873 | } |
1863 | 1874 | ||
1864 | static void | 1875 | static void |