rmyorston / busybox-w32

WIN32 native port of BusyBox.
https://frippery.org/busybox
Other
691 stars 126 forks source link

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

Open ale5000-git opened 4 weeks ago

ale5000-git commented 4 weeks ago

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 commented 4 weeks ago

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 commented 4 weeks ago

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 commented 4 weeks ago

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.