Repository navigation
fix(remote): 连接接受 Windows 域用户,Motty 导入把被拒的设置标到对应字段 (Refs 1lck/Lithe-IDEA#2231) - #166
Merged
Merged
Conversation
xiaoyumuxi
marked this pull request as ready for review
November 22, 2026 01:53
This was referenced Nov 22, 2026
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
Refs 1lck/Lithe-IDEA#2231(远程开发完整设计)。
类型
remote.mottyHosts把被拒的设置标到对应字段,并给这类主机一个新状态invalid。不新增错误码,不新增日志事件改动说明
问题
从 Motty 导入时,用户名是 Windows 域账户的主机(比如
CONTOSO\admin)被显示成“非 SSH”,地址那一栏写着“Lithe 不接受这个值”。实际有两个问题:is_ssh_user只接受 POSIX 登录名,就是 ASCII 字母、数字和._-,所以 Windows OpenSSH 服务器认的DOMAIN\name和name@domain都被拒了。candidate()不看check()拒的是哪个字段,一律标在address上,状态给unsupported。用户看到的是“非 SSH”和“地址无效”,两个都不对。crates/remote/src/client/transport.rsis_login_name,规则就是原来is_ssh_user的 POSIX 登录名规则。is_ssh_user现在接受三种写法:登录名、DOMAIN\name、name@domain。域名部分要满足is_plain_name,即字母或数字开头,后面只能是字母、数字和._-;一个用户名里最多一个域。OptionSyntax::User跟着放宽。@处切分,所以name@domain@host中的域留在用户名里。valid_ruser只拒绝出现在末尾的反斜杠。-o User=…都作为单个参数直接交给 ssh,不经过 shell。is_wsl_user)改用is_login_name。它本来就是 Linux 账户名,行为不变。is_jump_host)也改用is_login_name。ssh 通过 shell 命令行启动跳板机,反斜杠在 shell 里是转义符,所以跳板机用户仍然只接受登录名,行为不变。crates/remote/src/client/motty.rsStatus新增Invalid(JSON 为invalid)。含义是:这是 SSH 主机,但有一个设置 Lithe 不接受,那个字段会标成skip: invalid。Unsupported只表示“不是 SSH 主机”。ConnectionError.field找出lithe名字相同的那个导入字段,标为Invalid。导入字段的lithe名字(host、user、port、identityFile、proxyJump、keepAliveSeconds)和check()报出的字段名是同一套。找不到对应字段时退回标在address上。invalid和unsupported一样不带connection,导入时不会保存。contracts/rust-core-api.mduser写明接受的三种写法;proxyJump写明其中的用户只接受登录名及原因。remote.mottyHosts:status增加invalid;unsupported只表示不是 SSH 主机;这两种状态都不带connection。客户端影响
RemoteImportInvalid = "invalid"(SSH 配置导入一直在用),显示为红色的“无效”标签,不可勾选导入。所以 Motty 导入这类主机,从“非 SSH”变成“无效”,被拒的设置出现在它自己的那一行。remote_helpers.go里这两个状态的注释。验证
cargo fmt -p lithe-remotecargo clippy -p lithe-remote --all-targets --all-features -- -D warnings:无警告cargo test -p lithe-remote --all-features:全部通过,其中单元测试 197 个。新增和修改的测试:connections::tests::windows_domain_users_reach_ssh_unchanged:CONTOSO\admin和admin@contoso.example生成的 ssh 目的地分别是CONTOSO\admin@192.0.2.10和admin@contoso.example@192.0.2.10。connections::tests::malformed_connections_name_the_field_before_ssh_starts新增 9 个拒绝用例:CONTOSO\,末尾是反斜杠;\admin、@contoso;admin@;A\B\admin、CONTOSO\admin@contoso.example、a@b@c;-开头:-oProxyCommand=x\admin、CONTOSO\-oProxyCommand=x。motty::tests::other_protocols_and_refused_settings_are_not_imported:unsupported;invalid,标在address上;invalid,标在user上,address仍然映射到host。motty::tests::windows_domain_users_are_imported:两种域账户写法都是importable,导入的连接保留原用户名。192.0.2.x、contoso.example等文档保留的占位地址和名字。