diff options
author | djm@openbsd.org <djm@openbsd.org> | 2018-06-01 03:11:49 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2018-06-01 13:14:54 +1000 |
commit | d8748b91d1d6c108c0c260ed41fa55f37b9ef34b (patch) | |
tree | 2bcedc2023514a24ef441b2dac0628f32bb7b419 /ssh.c | |
parent | fbb4b5fd4f8e0bb89732670a01954e18b69e15ba (diff) |
upstream: prefer argv0 to "ssh" when re-executing ssh for ProxyJump
directive; bz2831, feedback and ok dtucker@
OpenBSD-Commit-ID: 3cec709a131499fbb0c1ea8a0a9e0b0915ce769e
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh.c,v 1.477 2018/04/14 21:50:41 djm Exp $ */ | 1 | /* $OpenBSD: ssh.c,v 1.478 2018/06/01 03:11:49 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 |
@@ -1171,6 +1171,14 @@ main(int ac, char **av) | |||
1171 | */ | 1171 | */ |
1172 | if (options.jump_host != NULL) { | 1172 | if (options.jump_host != NULL) { |
1173 | char port_s[8]; | 1173 | char port_s[8]; |
1174 | const char *sshbin = argv0; | ||
1175 | |||
1176 | /* | ||
1177 | * Try to use SSH indicated by argv[0], but fall back to | ||
1178 | * "ssh" if it appears unavailable. | ||
1179 | */ | ||
1180 | if (strchr(argv0, '/') != NULL && access(argv0, X_OK) != 0) | ||
1181 | sshbin = "ssh"; | ||
1174 | 1182 | ||
1175 | /* Consistency check */ | 1183 | /* Consistency check */ |
1176 | if (options.proxy_command != NULL) | 1184 | if (options.proxy_command != NULL) |
@@ -1179,7 +1187,8 @@ main(int ac, char **av) | |||
1179 | options.proxy_use_fdpass = 0; | 1187 | options.proxy_use_fdpass = 0; |
1180 | snprintf(port_s, sizeof(port_s), "%d", options.jump_port); | 1188 | snprintf(port_s, sizeof(port_s), "%d", options.jump_port); |
1181 | xasprintf(&options.proxy_command, | 1189 | xasprintf(&options.proxy_command, |
1182 | "ssh%s%s%s%s%s%s%s%s%s%.*s -W '[%%h]:%%p' %s", | 1190 | "%s%s%s%s%s%s%s%s%s%s%.*s -W '[%%h]:%%p' %s", |
1191 | sshbin, | ||
1183 | /* Optional "-l user" argument if jump_user set */ | 1192 | /* Optional "-l user" argument if jump_user set */ |
1184 | options.jump_user == NULL ? "" : " -l ", | 1193 | options.jump_user == NULL ? "" : " -l ", |
1185 | options.jump_user == NULL ? "" : options.jump_user, | 1194 | options.jump_user == NULL ? "" : options.jump_user, |