Created attachment 2864 [details] use /proc/self/exe or environment variable to launch port forwarding for ProxyJump When testing the relatively new JumpHost (-J) functionality, ssh constructed several command lines to facilitate the port forwarding; the command line however always starts with "ssh", picking the wrong binary from $PATH (and not from my development directory). This patch adds the option to use an environment variable (SSH_CUSTOM_CMD) to specify the command line to start with; on platforms that support it (Linux), it can also use /proc/self/exe to identify the ssh binary currently run and use it to create the port forwarding, avoiding confusions and possible problems when using different versions of ssh. github reference: https://github.com/wertarbyte/openssh-portable/compare/master...proxyjump_custom_cmd
Since /proc/self is not portable I don't think we should be cluttering up the code with it, and if you're going to set an environment variable to tell it where to find ssh, why not $PATH?
I missed the initial discussion about -J, but why not using av[0]?
(In reply to Bert Wesarg from comment #2) > I missed the initial discussion about -J, but why not using av[0]? That's a better idea. It doesn't cover all cases, but it might cover enough. The cases I can think of are: 1) full path: currently will exhibit the described behaviour, using argv[0] would fix it. 2) relative path: ditto, assuming ssh(1) doesn't chdir, which I don't think it does. 3) no path, $PATH set and exported. should work. 4) no path, $PATH set but not exported. could potentially pick up a different ssh.
ssh now tries to use argv[0] and falls back to $PATH if it doesn't look like an executable
closing resolved bugs as of 8.6p1 release