fix(reversesshfs): convert MSYS2 paths to native Windows paths for OpenSSH#108
fix(reversesshfs): convert MSYS2 paths to native Windows paths for OpenSSH#108liketosweep wants to merge 1 commit intolima-vm:masterfrom
Conversation
Signed-off-by: liketosweep <liketosweep@gmail.com>
|
Thanks, could you share how you tested these changes? |
|
Hi @unsuman, I’ve validated this patch natively on a Windows host using the Testing Methodology: Environment: Windows host, Lima v2.1.1, QEMU driver, and Git's OpenSSH client. Action: Swapped in the compiled, patched sshocker.exe and launched an Ubuntu guest with a reverse SSHFS mount targeting my local Windows directory (C:/Users/lts). Results: Validation Evidence:Host Agent Logs (Confirming successful path translation and
Guest Shell Output (Confirming read access to the mounted Windows directory via
Let me know if you need any further testing or logs for this PR! |
|
I wonder if we should have this change inside Lima itself, which lima-vm/lima#4885 already does and solve the chdir issue But this issue still persists: |
|
Thank you for the feedback, @unsuman. Regarding Redundancy with #4885I agree that centralizing the path normalization logic natively within the core Lima codebase (#4885) is the superior architectural approach. If we are confident that the implementation in #4885 covers these specific OpenSSH pathing requirements for Windows hosts, I am happy to close this PR to avoid logic fragmentation. Regarding the
|



What the Issue Was
Reverse SSHFS mounting of the Windows home directory fails on Lima/QEMU
(Windows host) with a
Permission deniederror. The hostagent accepts theMSYS2-style Unix path (
/c/Users/<user>) emitted by Cygwin/msys2 OpenSSHbut forwards it unconverted to the mount layer, which expects a native
Windows path (
C:\Users\<user>). This causeschdirto fail withNo such file or directory, cascading into afusermount3mount failure.The issue is reproducible locally and in CI.
Why It Was There
reversesshfs.gohad detection logic for MSYS2/Cygwin-style paths onruntime.GOOS == "windows"but no subsequent conversion step. Once thepath was identified as MSYS2 format, it was logged and passed through
as-is — Windows OpenSSH has no awareness of the MSYS2 path convention
and cannot resolve
/c/Users/...as a valid filesystem location.Solution
Introduced
convertMSYS2Path(localPath string) stringinreversesshfs.go.The function targets the MSYS2 drive-letter convention — a path of the form
/X/...whereXis a single alphabetic character — extracts and uppercasesthe drive letter, appends
:, and rewrites the remainder with backslashseparators, bypassing WSL/Linux environment path quirks entirely. Paths that
do not conform to this pattern are returned unchanged, ensuring no unintended
side effects on non-Windows or already-native paths.
The function is invoked within
Start()immediately after MSYS2 pathdetection, replacing
rsf.LocalPathwith the converted Windows-nativeequivalent before the mount is attempted. The converted path is logged
for traceability.
Changes
pkg/reversesshfs/reversesshfs.go— AddedconvertMSYS2Path()andintegrated it into the Windows path detection block in
Start(), witha log line confirming the resolved native path.
pkg/reversesshfs/reversesshfs_test.go— AddedTestConvertMSYS2Pathasserting that
/c/Users/ltscorrectly resolves toC:\\Users\\lts,with explicit failure messaging on mismatch.
Result
The hostagent now correctly resolves MSYS2-style paths to their Windows-native
equivalents before invoking OpenSSH, eliminating the
chdirfailure andrestoring reliable reverse SSHFS mounting on Windows/QEMU — both locally
and in CI.
Fixes #4810