Repository navigation
feat(remote): 主机能力报告 WSL 互操作状态 windowsInterop,remote.connect 的会话带上它 (Refs 1lck/Lithe-IDEA#2231) - #172
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue
1lck/Lithe-IDEA#2231(远程开发完整设计)S31:连接窗口显示 WSL 互操作状态,并明确 WSL 不是安全边界、不因此放宽信任。本 PR 是 Core 部分,桌面端显示在随后的桌面 Draft 里。
类型
windowsInterop,remote.connect返回的session带上它。旧服务端不发这个字段,客户端按"未知"处理,所以协议版本不变。不新增命令、错误码或日志事件。判定方法
WSL 在
binfmt_misc注册条目,Linux 程序才能启动 Windows 程序。条目文件第一行是enabled或disabled。条目名有两个:WSLInteropWSLInterop-late:部分 WSL 版本在启用 systemd 的发行版上注册它(WSL 生成的systemd-binfmt.serviceoverride 会重新注册),有时只剩这一个两个可能同时存在,也可能只有一个。要手动关掉互操作,必须两个都关。
windowsInteropenabledtrueenabledfalsenull参考:microsoft/WSL#13449、wslutilities/wslu#319、microsoft/WSL#11471。
改动说明
crates/remote/src/protocol/methods.rsHostCapabilities新增windows_interop: Option<bool>,带#[serde(default, skip_serializing_if = "Option::is_none")],线上字段名为windowsInterop。文档注释写明三种取值和"客户端只显示、不放宽信任(S31)"。windows_interop_is_omitted_unless_the_host_is_wsl:没有字段的 hello 解析为None,序列化时也省略;true和false原样往返。crates/remote/src/server/platform/linux.rswindows_interop()读/proc/sys/fs/binfmt_misc,逻辑在windows_interop_in(directory)里,测试可以换成临时目录。WSLInterop开或关、只有WSLInterop-late开、一关一开、两个都关、第一行内容异常、只有别的解释器条目、目录不存在。crates/remote/src/server/platform/macos.rs:windows_interop()固定返回None,和 Linux 函数签名相同。crates/remote/src/server/platform/mod.rs:host_capabilities()填入host::windows_interop()。crates/workspace/src/sessions.rs(只改连接结果):OpenedSession新增windows_interop,取自服务端的主机能力,序列化为windowsInterop(不在 WSL 时为null)。contracts/remote-workspace-protocol-v1.md:"Host capabilities" 一节列出windowsInterop,写明取值、什么时候省略,以及 WSL 不是安全边界。contracts/rust-core-api.md:remote.connect的session字段表加上windowsInterop,说明它只用来显示。验证
cargo test -p lithe-remote --all-features:lib 206 个和各集成测试全部通过cargo test -p lithe-workspace:83 个全部通过cargo clippy -p lithe-remote -p lithe-workspace --all-features --all-targets -- -D warnings:无告警cargo fmt --allcfg(target_os = "linux")):cargo clippy -p lithe-remote --no-default-features --features server --all-targets --target x86_64-unknown-linux-musl -- -D warnings:无告警WSLInterop一个条目,第一行是enabled,和测试夹具格式一致--all-features的 musl 交叉编译需要 musl C 编译器给 libsqlite3-sys,本机没有,留给 Linux CI。