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

stat: can't stat ssh.exe: No such file or directory #458

Open
ale5000-git opened this issue Sep 22, 2024 · 3 comments
Open

stat: can't stat ssh.exe: No such file or directory #458

ale5000-git opened this issue Sep 22, 2024 · 3 comments

Comments

@ale5000-git
Copy link

ale5000-git commented Sep 22, 2024

This is what I get with 32-bit BusyBox:

$ stat 'C:/Windows/System32/OpenSSH/ssh.exe'
stat: can't stat 'C:/Windows/System32/OpenSSH/ssh.exe': No such file or directory

Can it be fixed please?

PS: The file exist.

@rmyorston
Copy link
Owner

Congratulations! You've just met the File System Redirector.

When a 32-bit binary running on 64-bit Windows accesses certain directories which usually contain 64-bit stuff it's magically redirected to an equivalent directory containing 32-bit stuff. In particular, references to C:/Windows/System32 are redirected to C:/Windows/SysWoW64.

Your 32-bit command stat 'C:/Windows/System32/OpenSSH/ssh.exe' is redirected to look for C:/Windows/SysWoW64/OpenSSH/ssh.exe. But there's no such thing, so you get an error.

If you read all the way through the documentation linked above you'll find that you could have said C:/Windows/Sysnative/OpenSSH/ssh.exe and it would have worked. But only with a 32-bit binary. With a 64-bit binary that command would fail, so it's hardly a panacea.

And, of course, there are exceptions: subdirectories that aren't subject to redirection. We'd have been disappointed if Microsoft hadn't thrown in some special cases.

There are APIs to work around the problem but I'd prefer not to go down that route. I don't think the additional complexity is worth it.

@ale5000-git
Copy link
Author

C:/Windows/System32/OpenSSH is automatically inside $PATH as well as C:/Windows/System32 while C:/Windows/Sysnative isn't, so this redirection break the default executable search (command -v ssh).

Isn't possible to automatically translate (only inside busybox shell) accesses to the folder C:/Windows/System32 to C:/Windows/Sysnative using a similar way you use to support linux pathes (/bin/sh)?
In this way you can avoid the use of Windows API completely.

@rmyorston
Copy link
Owner

you can avoid the use of Windows API completely.

Maybe so, but not the complexity.

The best way to avoid the drawbacks of the 32-bit binary on 64-bit Windows is to use the 64-bit binary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants