Skip to content

fix(workspace): prepare cloud placeholders and WSL redirectors without ACL failures (#744, #669, #576, #814) - #1003

Closed
Nicholas023 wants to merge 6 commits into
mainfrom
fix-workspace-wsl-local
Closed

Nicholas023 wants to merge 6 commits into
mainfrom
fix-workspace-wsl-local

Conversation

@Nicholas023

Copy link
Copy Markdown
Collaborator

Closes #744, #669, #576
Refs #814

What was wrong

The change

  • bin/prepare-workspace.ps1: existence/container validation first; the "ready" fast path runs before any reparse inspection, so a ready workspace never needs a write; reparse tags are inspected only on the DACL-writing branch, with a handle-based query of the point itself.
  • bin/workspace-acl.ps1: only the proven cloud-files family (tag & 0xFFFF0FFF) == 0x9000001A is allowed through; other/unreadable tags fail closed with the tag named.
  • WSL redirector prefixes answer ready after existence validation and before Get-Acl; a real ACL error on other paths still fails closed.
  • src/execution/wsl-worker.ts: one fixed /bin/sh -c preparation call with constant text and positional arguments (drive roots then payload), preserving per-call wslpath resolution, digest verification and the Windows-worker fallback.
  • src/shells/host-contract.ts: promoted renders state the full-tree reach of job_kill.

Local validation: workspace-acl 8/8, workspace-wsl-redirector 2/2 (+ opt-in live 9P case), workspace-reparse-ready 3/3, workspace-language 2/2, wsl-prepare-merge 3/3, wsl-readonly 6/6, shells-job-promoted-guidance 2/2; npm run check:size green.

Validation

$ npm run build
build: compiled src/ to lib/ and copied 60 assets

$ node scripts/verify-gate.mjs --skip-install --keep-going
268 suites passed; skipped: linux-attributes, linux-shell, tui-host, tui-native (allowed: file-metadata, linux-attributes, linux-shell, tui-host, tui-native)
manifest: 92/59 checks
win32-x64: gate green

The gate lines above were produced on the local integration head b21274dd (all slices merged) with the pinned local fixtures:
DSH_OPS_TEST_BASH = a verified pinned MSYS bash (sha256 6cc575e9…), DSH_OPS_NIUBASH_ARCHIVE = the shipped frozen archive. Each PR branch was also built and its own suites were run before push; the counts below are from those runs.

CI required run: the pull_request event for this PR triggers ci.yml; paste the aggregate CI required run URL here once it finishes.

Environment

  • OS: Windows x64 25H2; Node.js v24.21.0; DSH 0.2.2-rc.1
  • Based on upstream main commit 58f6e281 (origin/main at submission)
  • Install channel: local source build (npm ci --ignore-scripts --offline, npm run build, npm run stage:niubash -- --offline --archive <frozen archive>)

…nders (#814)

A foreground command that outlived its timeout is promoted to a host job, and the render offered job_output/job_kill as if the kill stopped one command. The host's subprocess and job layer actually terminates the whole tree, so daemons the command started and left attached to its pipes (an adb server, a dev-server watcher) went down with it. The host layer owns that semantics and this repository cannot fix it; the render now states what a job kill reaches and how to keep daemons out of the blast radius.
…tes (#744)

A OneDrive workspace root carries IO_REPARSE_TAG_CLOUD with no target, and the bootstrap's ancestry walk refused any reparse point before the DACL decision could run, so every workspace-write tool failed on an otherwise ready folder. The reparse check moves to the single branch that actually writes the DACL: an already-ready root answers without any tag inspection, the cloud-files family (Microsoft's 0x90000000-0x9FFFFFFF band) passes because a placeholder keeps a real directory entry behind the point, and every other tag fails closed with the tag named, read through FSCTL_GET_REPARSE_POINT on the point itself. Unreadable points fail closed too.
#669)

The WSL 9P redirector (\\wsl.localhost and \\wsl$) exposes no NTFS security descriptor, so the bootstrap's Get-Acl threw on every WSL workspace and all of run_code died in workspace-write mode. Exactly those two Microsoft-fixed prefixes now answer ready before Get-Item or Get-Acl is touched, decided by the pure classifier Get-DshOpsWorkspaceNtfsState. This is a prefix decision, not a catch that swallows ACL errors: every other path keeps its existing behaviour and a real ACL failure there still fails closed; authority inside the distribution remains its own uid/gid mapping.
…669)

The redirector prefix decision ran before Get-Item, which turned '9P has no NTFS ACL' into 'the workspace need not exist': a nonexistent-distro path answered ready. The decision now runs after the existence and container validation and before Get-Acl, so a missing path fails exactly like any other missing workspace and a live 9P root still answers ready without reaching Get-Acl. The live end-to-end case becomes an explicit DSH_OPS_TEST_WSL_DISTRO opt-in that registers only after probing the provider, reports not-run without counting it as passed, and runs before the negative case because touching a nonexistent distribution leaves the redirector unable to answer valid paths for under two seconds.
The tag classifier accepted the whole 0x9xxxxxxx band on the high nibble alone, which is wider than the issue's proven family and let unproven tags through before a DACL write. The rule is now the exact family shape: (Tag -band 0xFFFF0FFF) -eq 0x9000001A, i.e. IO_REPARSE_TAG_CLOUD, CLOUD_ROOT, CLOUD_ON_DEMAND and family members sharing 0x9000?01A; 0x9FFFFFFF and a 0x9 tag whose low 16 bits are not ?01A are pinned as negative cases. Decimal literals keep the Windows PowerShell 5.1 unsigned arithmetic working. Docs state the precise family instead of the reserved band, and the same three files also carry the post-review wording that the 9P allowance runs after existence validation (#669).
…call (#576)

Each optional WSL read drove one wsl.exe invocation per Windows drive mapping, one more for the payload sha256, and a final one for the worker, so a small read paid four WSL startups for one result. Preparation is now a single fixed /bin/sh -c script: the text is a constant and every drive root and the payload path travel as positional arguments, so no Windows path can alter the command shape. The wslpath mappings are still resolved anew per call, the payload digest must still match the packaged receipt, and a refused mapping (exit 9), refused digest (exit 8) or failed spawn still falls back to the Windows worker exactly as before.
@Thatgfsj

Copy link
Copy Markdown
Collaborator

Superseded by #1033:按仓库约定把 #1023 与 #1002–#1008 合并为一个统一 PR(冲突已在 #1033 内解决,CI 在 #1033 上跑)。

@Thatgfsj Thatgfsj closed this Nov 20, 2026
@Thatgfsj
Thatgfsj deleted the fix-workspace-wsl-local branch November 20, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants