summaryrefslogtreecommitdiff
path: root/ssh.c
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2020-07-31 04:19:37 +0000
committerDamien Miller <djm@mindrot.org>2020-08-03 14:27:18 +1000
commitced327b9fb78c94d143879ef4b2a02cbc5d38690 (patch)
tree765b157455e1494433aec9d0b8a24207772b6af9 /ssh.c
parentae7527010c44b3376b85d036a498f136597b2099 (diff)
upstream: Also compare username when checking for JumpHost loops.
bz#3057, ok djm@ OpenBSD-Commit-ID: 9bbc1d138adb34c54f3c03a15a91f75dbf418782
Diffstat (limited to 'ssh.c')
-rw-r--r--ssh.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/ssh.c b/ssh.c
index 93e5c4831..9c6a6278b 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.533 2020/07/17 03:43:42 dtucker Exp $ */ 1/* $OpenBSD: ssh.c,v 1.534 2020/07/31 04:19:37 dtucker 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
@@ -1256,19 +1256,25 @@ main(int ac, char **av)
1256 /* Fill configuration defaults. */ 1256 /* Fill configuration defaults. */
1257 fill_default_options(&options); 1257 fill_default_options(&options);
1258 1258
1259 if (options.user == NULL)
1260 options.user = xstrdup(pw->pw_name);
1261
1259 /* 1262 /*
1260 * If ProxyJump option specified, then construct a ProxyCommand now. 1263 * If ProxyJump option specified, then construct a ProxyCommand now.
1261 */ 1264 */
1262 if (options.jump_host != NULL) { 1265 if (options.jump_host != NULL) {
1263 char port_s[8]; 1266 char port_s[8];
1264 const char *sshbin = argv0; 1267 const char *jumpuser = options.jump_user, *sshbin = argv0;
1265 int port = options.port, jumpport = options.jump_port; 1268 int port = options.port, jumpport = options.jump_port;
1266 1269
1267 if (port <= 0) 1270 if (port <= 0)
1268 port = default_ssh_port(); 1271 port = default_ssh_port();
1269 if (jumpport <= 0) 1272 if (jumpport <= 0)
1270 jumpport = default_ssh_port(); 1273 jumpport = default_ssh_port();
1271 if (strcmp(options.jump_host, host) == 0 && port == jumpport) 1274 if (jumpuser == NULL)
1275 jumpuser = options.user;
1276 if (strcmp(options.jump_host, host) == 0 && port == jumpport &&
1277 strcmp(options.user, jumpuser) == 0)
1272 fatal("jumphost loop via %s", options.jump_host); 1278 fatal("jumphost loop via %s", options.jump_host);
1273 1279
1274 /* 1280 /*
@@ -1371,9 +1377,6 @@ main(int ac, char **av)
1371 tty_flag = 0; 1377 tty_flag = 0;
1372 } 1378 }
1373 1379
1374 if (options.user == NULL)
1375 options.user = xstrdup(pw->pw_name);
1376
1377 /* Set up strings used to percent_expand() arguments */ 1380 /* Set up strings used to percent_expand() arguments */
1378 if (gethostname(thishost, sizeof(thishost)) == -1) 1381 if (gethostname(thishost, sizeof(thishost)) == -1)
1379 fatal("gethostname: %s", strerror(errno)); 1382 fatal("gethostname: %s", strerror(errno));