Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give windows a good hint about where to find the program to run #2

Conversation

jsoref
Copy link

@jsoref jsoref commented Apr 8, 2019

Test command:
ssh -J localhost localhost -vvv

The current openssh-portable code results in the following API calls (trying to find a "program"):

2:41:28.1645579 PM	ssh.exe	2836	CreateFile	C:\Windows\System32\OpenSSH\ssh -W '[localhost]:22' localhost	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
2:41:28.1647720 PM	ssh.exe	2836	CreateFile	C:\Windows\System32\OpenSSH\ssh -W '[localhost]:22' localhost.exe	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

Your current proposal results in the following API calls (trying to find a "program"):

4:34:11.0114226 PM	ssh.exe	3280	CreateFile	C:\Users\IEUser\openssh\bin\x64\Debug\ssh -vvv -W.exe	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

4:34:11.0116687 PM	ssh.exe	3280	CreateFile	C:\Users\IEUser\openssh\bin\x64\Debug\ssh -vvv -W.exe	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

4:34:11.0118551 PM	ssh.exe	3280	CreateFile	C:\Windows\System32\ssh -vvv -W.exe	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

4:34:11.0120783 PM	ssh.exe	3280	CreateFile	C:\Windows\System\ssh -vvv -W.exe	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

4:34:11.0122631 PM	ssh.exe	3280	CreateFile	C:\Windows\ssh -vvv -W.exe	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

4:34:11.0123699 PM	ssh.exe	3280	CreateFile	C:\Program Files\git\cmd\ssh -vvv -W.exe	PATH NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

4:34:11.0125956 PM	ssh.exe	3280	CreateFile	C:\Windows\System32\ssh -vvv -W.exe	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

4:34:11.0127745 PM	ssh.exe	3280	CreateFile	C:\Windows\ssh -vvv -W.exe	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

4:34:11.0129540 PM	ssh.exe	3280	CreateFile	C:\Windows\System32\wbem\ssh -vvv -W.exe	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

4:34:11.0131813 PM	ssh.exe	3280	CreateFile	C:\Windows\System32\WindowsPowerShell\v1.0\ssh -vvv -W.exe	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

4:34:11.0133618 PM	ssh.exe	3280	CreateFile	C:\Windows\System32\OpenSSH\ssh -vvv -W.exe	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

4:34:11.0136626 PM	ssh.exe	3280	CreateFile	C:\ProgramData\chocolatey\bin\ssh -vvv -W.exe	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

4:34:11.0138542 PM	ssh.exe	3280	CreateFile	C:\Program Files\Puppet Labs\Puppet\bin\ssh -vvv -W.exe	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

4:34:11.0140380 PM	ssh.exe	3280	CreateFile	C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\ssh -vvv -W.exe	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

4:34:11.0142676 PM	ssh.exe	3280	CreateFile	C:\Users\IEUser\AppData\Local\Microsoft\WindowsApps\ssh -vvv -W.exe	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

4:34:11.0143515 PM	ssh.exe	3280	Thread Create		SUCCESS	Thread ID: 3088

4:34:11.0169724 PM	ssh.exe	3280	Thread Exit		SUCCESS	Thread ID: 3088, User Time: 0.0000000, Kernel Time: 0.0000000

4:34:11.0172968 PM	ssh.exe	3280	CreateFile	C:\Users\IEUser\openssh\bin\x64\Debug\ssh.exe	SUCCESS	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened

It eventually finds C:\Users\IEUser\openssh\bin\x64\Debug\ssh.exe

Note: the path change from C:\Windows\System32\OpenSSH\ssh to C:\Users\IEUser\openssh\bin\x64\Debug\ssh isn't important, the ssh binary lives in a new place.

This is still pretty stupid.

We can do better, here's the entire log with this change:

4:44:23.7184239 PM	ssh.exe	3784	CloseFile	C:\Windows\System32\wshbth.dll	SUCCESS	
4:44:23.7194645 PM	ssh.exe	3784	Thread Create		SUCCESS	Thread ID: 180
4:44:23.7272320 PM	ssh.exe	3784	Thread Exit		SUCCESS	Thread ID: 180, User Time: 0.0000000, Kernel Time: 0.0000000
4:44:23.7314823 PM	ssh.exe	3784	Thread Create		SUCCESS	Thread ID: 5744
4:44:23.7329023 PM	ssh.exe	3784	Thread Exit		SUCCESS	Thread ID: 5744, User Time: 0.0000000, Kernel Time: 0.0000000
4:44:23.7330393 PM	ssh.exe	3784	Thread Create		SUCCESS	Thread ID: 4540
4:44:23.7337068 PM	ssh.exe	3784	Thread Exit		SUCCESS	Thread ID: 4540, User Time: 0.0000000, Kernel Time: 0.0000000
4:44:23.7340065 PM	ssh.exe	3784	CreateFile	C:\Users\IEUser\openssh\bin\x64\Debug\ssh.exe	SUCCESS	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
4:44:23.7340345 PM	ssh.exe	3784	QueryBasicInformationFile	C:\Users\IEUser\openssh\bin\x64\Debug\ssh.exe	SUCCESS	CreationTime: 4/8/2019 3:41:26 PM, LastAccessTime: 4/8/2019 4:44:23 PM, LastWriteTime: 4/8/2019 4:42:44 PM, ChangeTime: 4/8/2019 4:42:44 PM, FileAttributes: A
4:44:23.7340455 PM	ssh.exe	3784	CloseFile	C:\Users\IEUser\openssh\bin\x64\Debug\ssh.exe	SUCCESS	
4:44:23.7342841 PM	ssh.exe	3784	CreateFile	C:\Users\IEUser\openssh\bin\x64\Debug\ssh.exe	SUCCESS	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
4:44:23.7343032 PM	ssh.exe	3784	QueryBasicInformationFile	C:\Users\IEUser\openssh\bin\x64\Debug\ssh.exe	SUCCESS	CreationTime: 4/8/2019 3:41:26 PM, LastAccessTime: 4/8/2019 4:44:23 PM, LastWriteTime: 4/8/2019 4:42:44 PM, ChangeTime: 4/8/2019 4:42:44 PM, FileAttributes: A
4:44:23.7343116 PM	ssh.exe	3784	CloseFile	C:\Users\IEUser\openssh\bin\x64\Debug\ssh.exe	SUCCESS	
4:44:23.7347504 PM	ssh.exe	3784	CreateFile	C:\Users\IEUser\openssh\bin\x64\Debug\ssh.exe	SUCCESS	Desired Access: Read Data/List Directory, Execute/Traverse, Read Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Delete, AllocationSize: n/a, OpenResult: Opened
4:44:23.7347903 PM	ssh.exe	3784	CreateFileMapping	C:\Users\IEUser\openssh\bin\x64\Debug\ssh.exe	FILE LOCKED WITH ONLY READERS	SyncType: SyncTypeCreateSection, PageProtection: PAGE_EXECUTE|PAGE_NOCACHE
4:44:23.7348106 PM	ssh.exe	3784	CreateFileMapping	C:\Users\IEUser\openssh\bin\x64\Debug\ssh.exe	SUCCESS	SyncType: SyncTypeOther
4:44:23.7348730 PM	ssh.exe	3784	QuerySecurityFile	C:\Users\IEUser\openssh\bin\x64\Debug\ssh.exe	SUCCESS	Information: Label
4:44:23.7349081 PM	ssh.exe	3784	QueryNameInformationFile	C:\Users\IEUser\openssh\bin\x64\Debug\ssh.exe	SUCCESS	Name: \Users\IEUser\openssh\bin\x64\Debug\ssh.exe
4:44:23.7443246 PM	ssh.exe	3784	Process Create	C:\Users\IEUser\openssh\bin\x64\Debug\ssh.exe	SUCCESS	PID: 4480, Command line: "ssh ""  -vvv -W "[localhost]:22" localhost"
4:44:23.7443311 PM	ssh.exe	4480	Process Start		SUCCESS	Parent PID: 3784, Command line: "ssh ""  -vvv -W "[localhost]:22" localhost", Current directory: C:\Users\IEUser\openssh\bin\x64\Debug\, Environment: 
	=::=::\
	=C:=C:\Users\IEUser\openssh\bin\x64\Debug
	=ExitCode=00000000
	ALLUSERSPROFILE=C:\ProgramData
	APPDATA=C:\Users\IEUser\AppData\Roaming
	c28fc6f98a2c44abbbd89d6a3037d0d9_POSIX_FD_STATE=AAAAAAICA80=
	ChocolateyInstall=C:\ProgramData\chocolatey
	ChocolateyLastPathUpdate=131974685787905910
	CommonProgramFiles=C:\Program Files\Common Files
	CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
	CommonProgramW6432=C:\Program Files\Common Files
	COMPUTERNAME=MSEDGEWIN10
	ComSpec=C:\Windows\system32\cmd.exe
	DriverData=C:\Windows\System32\Drivers\DriverData
	HOMEDRIVE=C:
	HOMEPATH=\Users\IEUser
	LOCALAPPDATA=C:\Users\IEUser\AppData\Local
	LOGONSERVER=\\MSEDGEWIN10
	NUMBER_OF_PROCESSORS=1
	OneDrive=C:\Users\IEUser\OneDrive
	OS=Windows_NT
	Path=C:\Program Files\git\cmd;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;C:\Program Files\Puppet Labs\Puppet\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Users\IEUser\AppData\Local\Microsoft\WindowsApps;
	PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
	PROCESSOR_ARCHITECTURE=AMD64
	PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 70 Stepping 1, GenuineIntel
	PROCESSOR_LEVEL=6
	PROCESSOR_REVISION=4601
	ProgramData=C:\ProgramData
	ProgramFiles=C:\Program Files
	ProgramFiles(x86)=C:\Program Files (x86)
	ProgramW6432=C:\Program Files
	PROMPT=$P$G
	PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
	PUBLIC=C:\Users\Public
	SESSIONNAME=Console
	SSH_AUTH_SOCK=\\.\pipe\openssh-ssh-agent
	SystemDrive=C:
	SystemRoot=C:\Windows
	TEMP=C:\Users\IEUser\AppData\Local\Temp
	TERM=xterm-256color
	TMP=C:\Users\IEUser\AppData\Local\Temp
	USERDOMAIN=MSEDGEWIN10
	USERDOMAIN_ROAMINGPROFILE=MSEDGEWIN10
	USERNAME=IEUser
	USERPROFILE=C:\Users\IEUser
	VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
	windir=C:\Windows
4:44:23.7443361 PM	ssh.exe	4480	Thread Create		SUCCESS	Thread ID: 5296
4:44:23.7447263 PM	ssh.exe	3784	QuerySecurityFile	C:\Users\IEUser\openssh\bin\x64\Debug\ssh.exe	SUCCESS	Information: Owner, Group, DACL, SACL, Label, Attribute, Process Trust Label, 0x100

@jsoref jsoref force-pushed the createprocess-command-line-parsing-to-find-exe branch from bdc4c60 to c434358 Compare April 9, 2019 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants