You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ProxyCommand incorrectly requires an absolute path #1185
ProxyCommand requires an executable with an absolute path or a path relative to the ssh.exe installation directory. This is because it uses posix_spawn instead of posix_spawnp (although the latter is not currently implemented).
This seems wrong. OpenSSH on POSIX passes the ProxyCommand to the shell, and the shell looks up the executable in the path.
This breaks the inbox Windows hvc tool for connecting to Hyper-V VMs.
From what I can tell, the upstream code doesn't actually use posix_spawnp(), it uses execv() after a fork(). Regardless, it looks like Win32 fork prepends the OpenSSH directory to the executable string in spawn_child_internal() if the string is not an absolute path which subsequently causes CreateProcess() to not go through the normal PATH environment variable search routine. I imagine this might have been to ensure that an unqualified executable in sshd_config could be launched without worrying about what the working directory might have been sshd was launched. Maybe a better thing to do would be to set the working directory to the OpenSSH at launch via SetCurrentDirectory() and let the CreateProcess() executable resolution code do it's thing or maybe prepend the OpenSSH directory into the beginning of the path which should have the same effect? Thoughts?
Right, upstream uses execv, but it launches the process through the shell (arg0 = $SHELL, arg1 = -c, arg2 = the proxy command) , which will handle looking up the binary in the path internally, among other things.
Perhaps the right fix is to do the same and run the command line through %COMSPEC% /c.
Behavior of current posix_spawn is to support launching ssh from sftp and scp.
I like the idea of supporting a posix_spawnp variant that would respect PATH instead. Will have it supported in next drop.
Activity
NoMoreFood commentedon Jul 19, 2018
From what I can tell, the upstream code doesn't actually use posix_spawnp(), it uses execv() after a fork(). Regardless, it looks like Win32 fork prepends the OpenSSH directory to the executable string in spawn_child_internal() if the string is not an absolute path which subsequently causes CreateProcess() to not go through the normal PATH environment variable search routine. I imagine this might have been to ensure that an unqualified executable in sshd_config could be launched without worrying about what the working directory might have been sshd was launched. Maybe a better thing to do would be to set the working directory to the OpenSSH at launch via SetCurrentDirectory() and let the CreateProcess() executable resolution code do it's thing or maybe prepend the OpenSSH directory into the beginning of the path which should have the same effect? Thoughts?
jstarks commentedon Jul 19, 2018
Right, upstream uses
execv, but it launches the process through the shell (arg0 =$SHELL, arg1 =-c, arg2 = the proxy command) , which will handle looking up the binary in the path internally, among other things.Perhaps the right fix is to do the same and run the command line through
%COMSPEC% /c.manojampalam commentedon Jul 20, 2018
Behavior of current posix_spawn is to support launching ssh from sftp and scp.
I like the idea of supporting a posix_spawnp variant that would respect PATH instead. Will have it supported in next drop.
Added support of posix_spawnp.
Add support of posix_spawnp (#344)
bingbing8 commentedon Jan 11, 2019
posix_spawnp is implemented to respect PATH. Relative path should work for ProxyCommand now.
fix(CAWS): Use absolute file path to powershell executable to fix con…
Add support of posix_spawnp (PowerShell#344)