Win32-OpenSSH
Win32-OpenSSH copied to clipboard
Wrong locale settings used for error hints
Prerequisites
- [X] Write a descriptive title.
- [X] Make sure you are able to repro it on the latest version
- [X] Search the existing issues.
Steps to reproduce
- use non-English as the default display language, e.g. Simplified Chinese,
- enable experimental UTF-8 support, or use command
chcp 65001to enable it for tests - run ssh with a wrong remote address, e.g.
ssh [email protected] - then the error hints will be printed as UTF-8 hexademical values, instead of readable text in Chinese or other languags.
P.S. Expected behaviour is demostrated by SSH from msys2.
Expected behavior
PS C:\Users\stephen> chcp
Active code page: 65001
PS C:\Users\stephen> C:\Users\stephen\workspace0\dev\msys2\usr\bin\ssh.exe [email protected]
ssh: Could not resolve hostname raspberrypi4.locax: Name or service not known
Actual behavior
PS C:\Users\stephen> chcp
Active code page: 65001
PS C:\Users\stephen> ssh [email protected]
ssh: Could not resolve hostname raspberrypi4.locax: \344\270\215\347\237\245\351\201\223\350\277\231\346\240\267\347\232\204\344\270\273\346\234\272\343\200\202
Error details
No Errors occurred.
Environment data
PS C:\Users\stephen> $PSVersionTable
Name Value
---- -----
PSVersion 7.3.6
PSEdition Core
GitCommitId 7.3.6
OS Microsoft Windows 10.0.25393
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Version
OpenSSH_for_Windows_9.2p1, LibreSSL 3.6.2
Visuals
No response
What exact command to I need to enter to reproduce step 1?
I think the display language should be set in settings app. This link would help you to change the display language of Windows 10/11.
Function do_log() calls strnvis() to prepare that string for display, and looking at openbsd-compat/vis.c, I can see there the code that makes these backslash-octal substitutions in function vis(). Right before it there is an #ifdef WINDOWS and if (flag & VIS_LOG_UTF16) to make that function a bit more 8-bit transparent.
I can also see in log.c
#ifdef WINDOWS
#define LOG_SYSLOG_VIS (VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL|VIS_LOG_UTF16)
#else
#define LOG_SYSLOG_VIS (VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL)
#endif
#define LOG_STDERR_VIS (VIS_SAFE|VIS_OCTAL)
which suggests that this only applies to syslog, but not to stderr.
I haven't found yet where any of this substitution behaviour might depend on the locale setting.
I just found this issue could be reproduced in active code page 936, the GBK encoding for simplified Chinese. It is possible this issue is irrelative to encoding.
Then I have no more idea about the root cause. 😕
P.S. It could be reproduced in active code page 437, the US code page, too...
I was trying to get OpenSSH on Ubuntu Linux 20.04 to say Name or service not known in any language other than English, to see if the same problem exists there, but I'm now not sure that is even possible.
Perhaps OpenSSH on Unix-like environments doesn't even support translated error messages, which presumably would require use of stderror_l instead of stderror (and I can't see the former used).
Perhaps only the Windows version will even try to output non-ASCII error messages?
I got this non-ascii output on Windows Powerhell only, the cmd.exe is not tested.