Skip to content

Fix config loading through Windows directory junctions - #7250

Closed
Eljees wants to merge 1 commit into
XTLS:mainfrom
Eljees:n/fix-windows-junction-config
Closed

Eljees wants to merge 1 commit into
XTLS:mainfrom
Eljees:n/fix-windows-junction-config

Conversation

@Eljees

@Eljees Eljees commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #7239.

On Windows, xray run -c config.json can fail when its working directory contains a directory junction: opening the file succeeds, but filepath.EvalSymlinks returns "The system cannot find the path specified." Reproduced with the official v26.10.21 Windows release and Go 1.27.3 on Windows 11 (build 26100).

Resolve the final Windows path from the already opened file handle with GetFinalPathNameByHandle, keeping the allowed-extension check on the resolved target. Resolver errors remain fatal. Other platforms retain the existing absolute-path and symlink resolution. The command and regular-file gates are unchanged.

Regression tests use a real directory junction and a child process whose working directory is the junction, covering relative and absolute config paths. Tests also cover UTF-16 buffer growth, closed handles, the extension allowlist, pipe/other-command behavior, and symlink target extensions.

Validation on the submitted commit:

  • Both native Windows junction cases fail on the original implementation and pass with this change. The freshly built CLI reports Configuration OK for the physical path and both junction cases.
  • go test -count=1 ./main/confloader/... ./main/commands/base and affected go vet pass on Windows (Go 1.27.3). The affected suite also passes with -race on Linux (Go 1.27.1).
  • Two Windows file-symlink cases skip with error 1314 (symlink privilege unavailable); both target-extension cases run and pass on Linux.
  • Native Windows CLI build, repository format check on the committed LF source bytes, and git diff --check pass.
  • The full application suite and macOS runtime tests were not run locally.

AI assistance (OpenAI Codex) was used for implementation, tests, and review; the validation commands above were run locally.

@Meo597 Meo597 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

golang/go#63703 (comment)
这搞出许多麻烦,管杀不管埋的

但无论如何都不该去碰句柄,这不合适
这里只是简单检查扩展名,并不是绝对的安全保障,因此不该太复杂

可以把所有原来 EvalSymlinks 的都改为:
先 os.Lstat 再根据 info.Mode()&os.ModeSymlink != 0 来 EvalSymlinks

这么干的话 junction + 符号连接混合的仍然会报错,不照顾这种 edge case

@Meo597

Meo597 commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

No response for a long time; I'll handle it myself.

@Meo597 Meo597 closed this Oct 25, 2026
RPRX pushed a commit that referenced this pull request Oct 28, 2026
RPRX pushed a commit that referenced this pull request Oct 28, 2026
@Meo597

Meo597 commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

被他全自动 agent 蹭到了 co-author
俄罗斯版的 阿酥在coding

@RPRX

RPRX commented Oct 29, 2026

Copy link
Copy Markdown
Member

啥玩意儿,这种情况别人先开了 PR 的情况,我一般会手动加 co-author,虽然似乎不太相关,不过加了就加了吧

@Meo597

Meo597 commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

跟知名大神 阿酥在coding 干的事儿差不多
属于开全自动 Agent 每天扫几个 issue 做最小修复那种
被合并概率比较高,除非修的方向错了就像这个 PR

@Meo597

Meo597 commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

被蹭了就蹭吧,只是吐槽下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants