Skip to content

fix(workspace): opt in to preparing through local directory links - #1116

Open
buguoshixc wants to merge 1 commit into
T-Auto:mainfrom
buguoshixc:fix/1114-local-directory-link-optin
Open

buguoshixc wants to merge 1 commit into
T-Auto:mainfrom
buguoshixc:fix/1114-local-directory-link-optin

Conversation

@buguoshixc

@buguoshixc buguoshixc commented Dec 5, 2026 •

Copy link
Copy Markdown

Closes #1114

What was wrong

On an install whose DSH_HOME (C:\Users\<user>\.dsh) was moved to another drive and kept at its old
path through a directory junction, every workspace-write shell call failed with
Workspace root must not resolve through a junction or symlink, whatever workdir was selected. The
same directory reached through its real path worked.

prepareWorkspace() walks the path as given and rejects any reparse point in the chain before the ACL
script runs. That pre-check is in fact the only blocker: run() receives realpathSync.native(...), so
bin/prepare-workspace.ps1 never sees the junction — the 0xA0000003 tag is not in its ancestor walk,
and #744's classification and fail-closed behaviour are unaffected by this change.

The change

  • New opt-in DSH_OPS_ALLOW_LOCAL_DIRECTORY_LINKS=1 (environment, read where the preparation runs;
    the row's settings are not available to this module). With it set, the link pre-check is skipped.
  • Default posture is unchanged: without the variable the same refusal fires, and its message now names
    the switch, so a migrated install can find the remedy from the error alone.
  • The ACE is still written to the resolved directory, never to the link, and the ACL script's own tag
    walk still fails closed on every tag it cannot prove. Nothing in bin/*.ps1 changed.
  • A root that no longer resolves now rejects its promise with a named cause
    (... does not resolve to an existing directory) instead of throwing ENOENT synchronously out of
    a function whose contract is a promise.

Validation

$ node test/run.mjs permissions
  ok   the local-directory-link opt-in prepares a junction ancestor and never resolves a dangling one (#1114)
  ok   a root that no longer exists rejects its promise instead of throwing out of the call (#1114)
  ok   a workspace root that is itself a junction is refused before any ACL work
  ok   a junction above the workspace root is refused although the resolved path looks clean
  FAIL owned Modify-only workspace starts real DSH sandbox; three modes and explicit denials
dsh-ops permissions: 1 of 17 check(s) failed

$ node test/run.mjs workspace
dsh-ops niubash-workspace-mode: all 1 checks passed
dsh-ops workspace-language: all 2 checks passed
dsh-ops workspace-acl: all 8 checks passed
dsh-ops workspace-reparse-ready: all 3 checks passed
dsh-ops workspace-wsl-redirector: all 2 checks passed

The one remaining failure is Real bash required for permission matrix: the pinned Bash payload is not
provisioned on this machine. It fails identically at the base commit (1 of 15 check(s) failed at
origin/main 1caf4df2).

The new opt-in test asserts the resolver is called with the realpath, that removing the target turns the
same call into a refusal even with the switch on, and that the default run writes no ACL. Reverting the
allowLinks branch fails the first and the default-posture assertions; reverting the try/catch fails the
missing-root one.

$ gh run view <run-id> --json url,event,conclusion --jq '"\(.url) \(.event) \(.conclusion)"'
https://github.com/T-Auto/dsh-ops/actions/runs/47546382006 (event=pull_request; conclusion=action_required — first run from this fork awaits maintainer approval, template path (a))

Environment

Windows 11 x64, Node v24.13.1, source checkout, base origin/main 1caf4df2, Windows PowerShell 5.1,
NTFS on two local fixed drives; the reporter's install used mklink /J from C: to D:.

prepareWorkspace refused any workspace whose path crossed a junction or
symlink. Moving DSH home to another drive and keeping its path through a
junction is the standard remedy for a full system disk, and it puts every
workspace below one, so every workspace-write shell in such an install was
refused.

The refusal is also the only blocker: the ACL script receives the resolved
directory, so the link is not in its ancestor walk at all.

DSH_OPS_ALLOW_LOCAL_DIRECTORY_LINKS=1 now skips that pre-check. The ACE is
still written to the resolved directory, the script's own tag walk still
fails closed on every tag it cannot prove, and a root that no longer
resolves rejects its promise with a named cause instead of throwing out of
the call. The default posture is unchanged and the message names the
switch, so a migrated install can find it from the error alone.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] 工作区祖先为本地目录 junction 时 workspace-write 全部被拒:Workspace root must not resolve through a junction or symlink

1 participant